官术网_书友最值得收藏!

  • Mastering Symfony
  • Sohail Salehi
  • 455字
  • 2021-07-16 11:29:03

Installing PHP tools

We installed some plugins in our Jenkins, but to make these plugins work, we need to install some PHP tools on our EC2 instance. We can install these tools via Composer on our Symfony project, but this is not a good practice. They will sit in the vendor/ directory and make our Symfony project big and heavy.

Instead, we are going to install them in the CI server itself and benefit from them for every project we define in Jenkins:

  1. Assuming that the SSH connection to our EC2 instance is still live, open a terminal window and add the following PEAR channels to the system:
    $ sudo pear channel-discover pear.pdepend.org
    $ sudo pear channel-discover pear.phpmd.org
    
    $ sudo pear channel-discover pear.phpdoc.org
    
    $ sudo pear channel-discover pear.symfony-project.com
    
  2. Now install PHP tools as follows:
    $ sudo pear install pdepend/PHP_Depend 
    $ sudo pear install phpmd/PHP_PMD
    $ sudo pear install phpunit/phpcpd
    $ sudo pear install phpunit/phploc
    $ sudo pear install --alldeps phpunit/PHP_CodeBrowser
    
    $ sudo pear install phpdoc/phpDocumentor-alpha
    

    Note

    You might have used some of these tools and some of them might look new to you. I am not going to go through all of them and explain what they do. It needs another book to go through all the details. Instead, I encourage you to have a look at their documentation and briefly familiarize yourself with their functions.

    You can find a list of URLs for these tools on their official website or https://packagist.org/.

One last thing that you may notice is why we didn't install these packages via Composer. Note the following command:

$ sudo pear install phpunit/phpcpd

It is better if you replace the preceding command with this one:

$ sudo composer global require 'sebastian/phpcpd=*'

It is certainly better to use Composer. However, there is a catch to this. I've noticed that when you install packages via Composer, for some reason Jenkins doesn't like it and fixing build bugs might give you a major headache. So, to play it safe, install them via PEAR channel and play with Jenkins for a while. When you master the basics, there is always room for creating more EC2 instances and setting up the required tools like a pro.

You can find more about the basics on the http://jenkins.org/ website.

Sniff Symfony codes

Symfony has its own coding standards. To benefit from CodeSniffer in our project, we need to introduce Symfony standards and make it the default standard:

  1. First, find the PEAR directory:
    $ pear config-show | grep php_dir
    
  2. Now, go to the Standards folder in CodeSniffer (in our EC2 instance, the path is cd /usr/share/php/PHP/CodeSniffer/Standards/) and clone the following repository:
    $ sudo git clone git://github.com/escapestudios/Symfony2-coding-standard.git Symfony2
    
  3. Now make Symfony the default coding standard:
    $ phpcs --config-set default_standard Symfony2
    
主站蜘蛛池模板: 翁源县| 南阳市| 营山县| 胶南市| 岗巴县| 砀山县| 乌拉特中旗| 家居| 黔南| 栾川县| 香港| 武平县| 平泉县| 开江县| 三门峡市| 苍山县| 汉阴县| 安泽县| 十堰市| 开江县| 济宁市| 乐都县| 麦盖提县| 龙井市| 兴国县| 辰溪县| 东源县| 宜城市| 托克逊县| 泗洪县| 彭州市| 洪洞县| 台湾省| 正安县| 驻马店市| 辽源市| 昌都县| 泰州市| 南康市| 襄樊市| 阳江市|