PHP performance

前端 未结 13 2209
庸人自扰
庸人自扰 2020-12-28 19:03

What can I do to increase the performance/speed of my PHP scripts without installing software on my servers?

13条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-28 19:40

    You can optimized the code with two basic things:

    Optimizing PHP associated library and server

    Go through https://www.digitalocean.com/community/articles/how-to-optimize-apache-web-server-performance Or

    You can use profiling tool like xhprof to view what part of your code can by optimized and here is the link to follow: http://michaelsanford.com/compiling-xhprof-for-php-5-4/

    Optimizing your code using code profiler and code analyzer

    You need to install Netbeans in order to use this plugin. Here are the steps you need to follow:

    1) Open NetBeans then select option from menu bar Tools > Plugin. Then search plug-in name "phpcsmd" in the available plug-in tab and install it from there.

    2) Now open the terminal and be there as the super user by typing command "sudo su".

    3) Install PEAR library (if it is not installed) into your system by running following commands into your terminal

    a) wget http://pear.php.net/go-pear.phar
    b) php go-pear.phar
    

    As we need this for the installation of further addons.

    4) Then run the command

    "pear config-set auto_discover 1"
    

    This will be used to set auto discover the path "true" for the required plug-ins. So they get install to the desired location automatically.

    5) Then run below command to install PHP code sniffer.

    "pear install --alldeps pear/PHP_CodeSniffer"
    

    6) Now to install the PHP Mess Detector by running following command

    "pear install --alldeps phpmd/PHP_PMD"
    

    If you get the error like "invalid package name/package file "phpmd/PHP_PMD"" while installing this module. You need to use this "pear channel-discover pear.phpmd.org" command to get rid of this error. After this command you can run the above command again to install Mess detector.

    7) Now to install the PHP Depend by running following command

    "pear install --alldeps pdepend/PHP_Depend"
    

    8) Now install the PHP Copy Paste Detector by running following command

    "pear install --alldeps phpunit/phpcpd"
    

    9) Then run the command

    "pear config-set auto_discover 0"
    

    This will be used to set auto discover path "false".

    10) Then open net beans and follow the path Tools>Options>PHP>PHPCSMD

提交回复
热议问题