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

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
    
主站蜘蛛池模板: 榕江县| 大足县| 兴化市| 老河口市| 海城市| 吉林省| 封开县| 芒康县| 安丘市| 敖汉旗| 吴忠市| 南岸区| 淮安市| 松桃| 大英县| 乌鲁木齐县| 长汀县| 应用必备| 涿州市| 普格县| 沈阳市| 定边县| 松原市| 梁河县| 信丰县| 赫章县| 仪征市| 吉水县| 西乡县| 亚东县| 墨玉县| 乐山市| 华阴市| 务川| 乌兰县| 朝阳市| 长汀县| 阿拉善盟| 宝丰县| 滨海县| 无锡市|