Enable Debug mode in Twig Template

Sometimes you need to see your variables or object in Twig template before printing it out. So to enable debug mode in twig template system you just need to tweak few settings upon initializing twig environment. Just follow the below code where I initiated Twig environment with debug mode.

 

And inside your template where you want to dump the variable just write . You can read more about dump function twig template from here

Create INI file in PHP

Write configuration data in a .ini file in PHP. It’s important for large application to store global configurations about the whole/partial system for applications.

Enable OpCache in PHP5 to boost your application

After lots of folk PHP5 has released [Zend OpCache] engine with core PHP5.5 and PHP internals will continue to develop PHP with this Zend OpCache in future releases of PHP.
It’s great news for all the PHP lovers who used APC cache to boost their application performance. But keep in mind, APC is no more supported with PHP5.5 and may not be for future release also.
So here you should love OpCache (original name: Zend OpCache) for tweaking your application performance.
Although this opCache is built-in in PHP5.5 so you just have to enable this from your php.ini file and you are ready to go.
So let’s see how you can enable this OpCache in your environment.

Just open your PHP php.ini file (location may depends on your environment) and search for opcache and here you will see the configuration like below.

Now you just have to remove ; from ;opcache.enable=0 and replace 0 with 1. Also do the same for ;opcache.enable_cli=0.

And if you want to modify share memory storage size then just uncomment it and change the integar value. So after change it should look like

Now you have to restart your apache or if you are using nginx then you have to restart php5-fpm. Enjoy!

Tools to monitor your server’s OpCache status
Founder of PHP Rasmus Lerdorf developed few snippet to test the OpCache status for your environment.
You can download that from here. Download this repo and put it anywhere in your server and browse opcache.php and it will display the current status of your OpCache engine like the following image.
Zend OpCache Status Screenshot

Enable mCrypt extension in your PHP5 in nGinx server in Ubuntu

mCrypt is one of the best and most popular Cryptography Extensions in PHP5. To install it with your PHP5 in your NGinx server for Ubuntu 14.04 please install it with following command

and then restart your NGinx server with sudo service nginx restart. But sometimes it may fails to load your mCrypt extension with your PHP5. If you face those types of problem just execute the following command in your Ubuntu 14.04 command line and restart Nginx.

Now you have mcrypt enabled in your PHP5. Keep coding!