دسته‌ها
PHP آموزشی اسنیپت برنامه‌نویسی

mPDF and PHP Requirement Check

mPDF is a PHP library which generates PDF files from UTF-8 encoded HTML. I have  used it in many projects, including WordPress plugins to generate PDF. The major problem with this library is it works in Test Environment but when you deploy and make live preview, Surprise 😲 IT DOES NOT WORK! And the more you dig in you will find out you cannot debug it! So, I had to make a path through this problem, said to myself why it works in Localhost, my another site, yet another site, but not this client’s site.

Oreka! It’s lacking something. Yeah, mbstring extension was enabled but, mb_regex_encoding was not working and had to enable it by myself or asking Host Provider to do.Thought to myself why not we first check the requirements then if everything was okay, continue to the next level? So I used code below to check if required modules are available and enabled.

So this code checks whether extensions are enabled or not, but what if we don’t want to show users anything unless extension is not enabled? Here is the complete solution which you can use in any production by just a bit of modification.

Do you know any other workaround? let us know by commenting.

دیدگاهتان را بنویسید

نشانی ایمیل شما منتشر نخواهد شد. بخش‌های موردنیاز علامت‌گذاری شده‌اند *