PHP speed optimisation

Active3 hr before
Viewed126 times

6 Answers


7. Turn off debugging notifications,4. Cut out unnecessary calculations,3. Cash in on caching techniques,8. Close database connections

load more v

Another Reddit user, Firehed proposed a little but smart solution to improve PHP performance in his answer:,Jimlei replied with a few points that hold importance for enhancing apps performance:,Larry Garfield highlighted the use of Blackfireio for code profiling. He further emphasized on migrating to PHP 7 for optimized performance:,Another user Mike Pearson responded with some useful PHP performance tips to optimize overall app performance:

OpCache is compiled by default on PHP 5.5+. However, it is disabled by default. In order to start using OpCache in PHP 5.5+, you will first have to enable it. To do this you would have to do the following.

Add the following line to your php.ini:
   zend_extension = /full/path / to /
zend_extension = C: \path\ to\ php_opcache.dll(win)
load more v

To improve performance, Composer offers three optimization levels; these are:,So, as you can imagine, an OPcache is one of the least intensive ways to improve the performance of a PHP application, because no code needs to change. Some reports show up to a 70% speed improvement.,Pantheon reported that PHP 7 gave a 64% improvement over version 5.3.,PHP removes unnecessary includes and performs other optimizations.

To enable this optimization level, run the following command:

composer dump - autoload--optimize
load more v

This tutorial provides few tips to optimize PHP code from a developer point of view. , Tagged as: Optimize PHP Code, PHP Code Performance Tuning ,The script below will perform much better.,Top 25 Best Linux Performance Monitoring and Debugging Tools

For example, the following will degrade the performance.

for ($i = 0; i < count($arrA); $i++) {
   echo count($arrA);
load more v

Avoid the PHP mail() function header injection issue., Instantly share code, notes, and snippets. ,@ssi-anik I too could not replicate the claims that the isset trick is faster than strlen.,Can also use sprintf instead of variables contained in double quotes, it’s about 10x faster.

Okay, they both shows that strlen is faster than isset.
Tell me if I am wrong.

load more v

Static: A fixed number of PHP processes will be maintained no matter what.,Dynamic: We get to specify the minimum and maximum number of processes that php-fpm will keep alive at any given point in time.,Finally, we arrive at the source of the matter, the process manager (pm) setting. Generally, you’ll see the defaults as something like this:,A few things should be immediately obvious: the line pid = /run/php/ tells us which file contains the process id of the php-fpm process.

If you’ve done any Nginx setups, or even just pried into them, you’ll come across something like this:

     location~\.php$ {
           try_files $uri = 404;
           fastcgi_split_path_info ^ (. + \.php)(/.+)$;
              fastcgi_pass unix: /run/php / php7 .2 - fpm.sock; fastcgi_index index.php; include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
load more v

Other "speed-undefined" queries related to "PHP speed optimisation"