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

  • 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
    
主站蜘蛛池模板: 阳信县| 正阳县| 宝兴县| 乌兰县| 延吉市| 海林市| 龙海市| 南部县| 莒南县| 托克逊县| 杭锦后旗| 全椒县| 呼玛县| 泰兴市| 阿城市| 黔东| 桃源县| 福州市| 汾西县| 绩溪县| 山东| 鹿邑县| 乌鲁木齐市| 开江县| 许昌市| 正蓝旗| 西宁市| 海口市| 北安市| 宽甸| 绥德县| 澎湖县| 都匀市| 西林县| 太和县| 桃园市| 青州市| 兰州市| 长顺县| 封丘县| 霍林郭勒市|