SlideShare ist ein Scribd-Unternehmen logo
1 von 39
PHP Power Tools
   Michelangelo van Dam
  PHPBenelux Meeting 2010, Leuven
Michelangelo van Dam

• Independent Consultant
• Zend Certified Engineer (ZCE)
 - PHP 4 & PHP 5
 - Zend Framework
• Co-Founder of PHPBenelux
• Shepherd of “elephpant” herds
Why PHP Power Tools
• early detection of issues
• cleaner & consistent code
• knowledge about the codebase
• better code
Usual Suspects

            PHP_CodeSniffer
Example Code
•- Zend Framework QuickStart app
   http://framework.zend.com/manual/en/learning.quickstart.intro.html
VirtualHost Settings
<VirtualHost *:80>
 DocumentRoot /srv/www/quickstart/public
 ServerName quickstart.local
 ServerAdmin root@localhost
 <Directory /srv/www/quickstart/public>
  Options Indexes FollowSymlinks
  AllowOverride All
  Order allow,deny
  Allow from all
  DirectoryIndex index.php
 </Directory>
 Alias /reports /srv/www/quickstart/reports
 <Directory /srv/www/quickstart/reports>
  Options Indexes FollowSymlinks
  AllowOverride All
  Order allow,deny
  Allow from all
  DirectoryIndex index.php index.html
 </Directory>
</VirtualHost>
Showtime
Syntax Checking
•- PHPLint
   comes with PHP binary
 - validates code for syntax errors
• Website
 - http://www.icosaedro.it/phplint/
Demo PHPLint
Code Documentation
•- PHPDocumentator
    creates automated API documentation
 - based on inline code blocks
• Installation
 - pear install PhpDocumentor
• Website
 - http://www.phpdoc.org
Demo PHPDoc
Output PHPDoc
Coding Standards
•- PHP_CodeSniffer
    sniffs for coding standard violations
 - ensures code is clean and consistent
 - using standard and custom coding standards
• Installation
 - pear install PHP_CodeSniffer
• Website
 - http://pear.php.net/package/PHP_CodeSniffer
Demo PHP_CodeSniffer
PHPCPD
•- PHP Copy/Paste Detector
     detects code duplication
•- Installation
   pear channel-discover pear.phpunit.de
 - pear channel-discover components.ez.no
 - pear install --alldeps phpunit/phpcpd
• Website
 - http://github.com/sebastianbergmann/phpcpd
Demo PHPCPD
Output
Mess Detection
•- PDepend & PHPMD
     detects code mess
•- Installation
   pear channel-discover pear.pdepend.org
 - pear install pdepend/PHP_Depend
 - pear channel-discover pear.phpmd.org
 - pear install phpmd/PHP_PMD
• Websites
 - http://www.pdepend.org
 - http://www.phpmd.org
Demo detecting mess
Output codesize
Output unused code
Unit Testing
•- PHPUnit
    tests code on unit level
 - includes database tests
 - integrates well with many PHP frameworks
• Installation
 - pear channel-discover pear.phpunit.de
 - pear install phpunit/PHPUnit
• Website
 - http://www.phpunit.de
See other presentation




 http://www.slideshare.net/DragonBe/phpunit-testing-to-zendtest
Automated builds
•- Phing
    automated build tool
 - like Apache Ant
 - integrates well with other PHP tools
• Installation
 - pear channel-discover pear.phing.info
 - pear install phing/phing
• Website
 - http://phing.info
build.xml
<?xml version="1.0"?>

<project name="zfqs" description="Zend Framework QuickStart" default="build" >
        <target name="version">
                <version releasetype="Bugfix" file="build.version" property="version.number"/>
        </target>

       <target name="phplint">
               <mkdir dir="./reports/phplint" />
               <phplint file="./application/models" haltonfailure="false" tofile="./reports/phplint/errors.txt"/>
       </target>

       <target name="pdepend">
               <mkdir dir="./reports/pdepend" />
               <copy file="./build_pdepend.html" tofile="./reports/pdepend/index.html" overwrite="true" />
               <exec command="/usr/bin/pdepend
                       --summary-xml=./reports/pdepend/summary.xml
                       --jdepend-chart=./reports/pdepend/jdepend.svg
                       --overview-pyramid=./reports/pdepend/pyramid.svg
                       ./application/models"
                       dir="./" />
       </target>

       <target name="phpmd">
               <mkdir dir="./reports/phpmd" />
               <exec command="/usr/bin/phpmd ./application/models html codesize --reportfile ./reports/phpmd/codesize.html" dir="./" />
               <exec command="/usr/bin/phpmd ./application/models html unusedcode --reportfile ./reports/phpmd/unusedcode.html" dir="./" />
       </target>

       <target name="phpcs">
               <mkdir dir="./reports/phpcs" />
               <exec command="/usr/bin/phpcs -n --standard=Zend --report=summary ./application/models > ./reports/phpcs/summary.txt" dir="./" />
               <exec command="/usr/bin/phpcs -n --standard=Zend --report=source ./application/models > ./reports/phpcs/source.txt" dir="./" />
               <exec command="/usr/bin/phpcs -n --standard=Zend --report=checkstyle ./application/models > ./reports/phpcs/checkstyle.xml" dir="./" />
       </target>

       <target name="phpcpd">
               <mkdir dir="./reports/phpcpd" />
               <exec command="/usr/bin/phpcpd --log-pmd ./reports/phpcpd/pmd-cpd.xml ./application/models" dir="./" />
       </target>

       <target name="phpdoc">
               <mkdir dir="./reports/phpdoc" />
               <exec command="phpdoc -d ./application/models -q -t ./reports/phpdoc -o HTML:frames:earthli" dir="./" />
       </target>

        <target name="build" depends="version,phplint,pdepend,phpmd,phpcs,phpcpd,phpdoc">
                <echo msg="Finishing build process ${version.number}" />
        </target>
</project>
project definition
<?xml version="1.0"?>

<project name="zfqs" description="Zend Framework QuickStart" default="build" >
…
</project>
target version
<target name="version">
    <version releasetype="Bugfix"
             file="build.version" property="version.number"/>
</target>




In file “build.version” we have the version number as the following sequence:

MAJOR.MINOR.BUGFIX (starting at 0.0.0)
target phplint
<target name="phplint">
   <mkdir dir="./reports/phplint" />
   <phplint file="./application/models"
            haltonfailure="false" tofile="./reports/phplint/errors.txt"/>
</target>
target pdepend
<target name="pdepend">
    <mkdir dir="./reports/pdepend" />
    <copy file="./build_pdepend.html"
          tofile="./reports/pdepend/index.html" overwrite="true" />
    <exec command="/usr/bin/pdepend
                        --summary-xml=./reports/pdepend/summary.xml
                        --jdepend-chart=./reports/pdepend/jdepend.svg
                        --overview-pyramid=./reports/pdepend/pyramid.svg
                        ./application/models"
                        dir="./" />
</target>
target phpmd
<target name="phpmd">
    <mkdir dir="./reports/phpmd" />
    <exec command="/usr/bin/phpmd ./application/models html codesize
          --reportfile ./reports/phpmd/codesize.html" dir="./" />
    <exec command="/usr/bin/phpmd ./application/models html unusedcode
          --reportfile ./reports/phpmd/unusedcode.html" dir="./" />
</target>
target phpcs
<target name="phpcs">
    <mkdir dir="./reports/phpcs" />
    <exec command="/usr/bin/phpcs -n
            --standard=Zend --report=summary
            ./application/models > ./reports/phpcs/summary.txt"
            dir="./" />
    <exec command="/usr/bin/phpcs -n
            --standard=Zend --report=source
            ./application/models > ./reports/phpcs/source.txt"
            dir="./" />
    <exec command="/usr/bin/phpcs -n
            --standard=Zend --report=checkstyle
            ./application/models > ./reports/phpcs/checkstyle.xml"
            dir="./" />
</target>
target phpcpd
<target name="phpcpd">
    <mkdir dir="./reports/phpcpd" />
    <exec command="/usr/bin/phpcpd
            --log-pmd ./reports/phpcpd/pmd-cpd.xml ./application/models"
            dir="./" />
</target>
target phpdoc
<target name="phpdoc">
    <mkdir dir="./reports/phpdoc" />
    <exec command="phpdoc -d ./application/models -q
            -t ./reports/phpdoc -o HTML:frames:earthli"
            dir="./" />
</target>
target build
<target name="build"
        depends="version,phplint,pdepend,phpmd,phpcs,phpcpd,phpdoc">
    <echo msg="Finishing build process ${version.number}" />
</target>
Demo building all
Demo building target
Our reports section
Summary


   PHP offers lots of tools
more consistent and clean code
     automated process
Thank you


            Slides on slideshare
http://www.slideshare.net/group/phpbenelux

    Don’t forget to thank our sponsor

Weitere ähnliche Inhalte

Was ist angesagt?

Linux Webserver Installation Command and GUI.ppt
Linux Webserver Installation Command and GUI.pptLinux Webserver Installation Command and GUI.ppt
Linux Webserver Installation Command and GUI.ppt
webhostingguy
 
Dependency management with Composer
Dependency management with ComposerDependency management with Composer
Dependency management with Composer
Jason Grimes
 
&lt;img src="../i/r_14.png" />
&lt;img src="../i/r_14.png" />&lt;img src="../i/r_14.png" />
&lt;img src="../i/r_14.png" />
tutorialsruby
 

Was ist angesagt? (18)

Apache Presentation
Apache PresentationApache Presentation
Apache Presentation
 
Installing php and my sql locally using xampp
Installing php and my sql locally using xamppInstalling php and my sql locally using xampp
Installing php and my sql locally using xampp
 
Apache
ApacheApache
Apache
 
Creating custom themes in AtoM
Creating custom themes in AtoMCreating custom themes in AtoM
Creating custom themes in AtoM
 
Phalcon 2 - PHP Brazil Conference
Phalcon 2 - PHP Brazil ConferencePhalcon 2 - PHP Brazil Conference
Phalcon 2 - PHP Brazil Conference
 
$ make install
$ make install$ make install
$ make install
 
PHP Dependency Management with Composer
PHP Dependency Management with ComposerPHP Dependency Management with Composer
PHP Dependency Management with Composer
 
How to install and configure LEMP stack
How to install and configure LEMP stackHow to install and configure LEMP stack
How to install and configure LEMP stack
 
Linux Webserver Installation Command and GUI.ppt
Linux Webserver Installation Command and GUI.pptLinux Webserver Installation Command and GUI.ppt
Linux Webserver Installation Command and GUI.ppt
 
How to Submit a plugin to WordPress.org Repository
How to Submit a plugin to WordPress.org RepositoryHow to Submit a plugin to WordPress.org Repository
How to Submit a plugin to WordPress.org Repository
 
Dependency management with Composer
Dependency management with ComposerDependency management with Composer
Dependency management with Composer
 
Debian source list generator
Debian source list generatorDebian source list generator
Debian source list generator
 
Perl
PerlPerl
Perl
 
Dockerizing WordPress
Dockerizing WordPressDockerizing WordPress
Dockerizing WordPress
 
&lt;img src="../i/r_14.png" />
&lt;img src="../i/r_14.png" />&lt;img src="../i/r_14.png" />
&lt;img src="../i/r_14.png" />
 
nir
nirnir
nir
 
PHP Conference - Phalcon hands-on
PHP Conference - Phalcon hands-onPHP Conference - Phalcon hands-on
PHP Conference - Phalcon hands-on
 
PHP and FastCGI Performance Optimizations
PHP and FastCGI Performance OptimizationsPHP and FastCGI Performance Optimizations
PHP and FastCGI Performance Optimizations
 

Andere mochten auch (6)

Srs2 Job Portal
Srs2 Job PortalSrs2 Job Portal
Srs2 Job Portal
 
Online Job Portal Document
Online Job Portal DocumentOnline Job Portal Document
Online Job Portal Document
 
JOB PORTAL SYSTEM
JOB PORTAL SYSTEMJOB PORTAL SYSTEM
JOB PORTAL SYSTEM
 
online job portal system
online job portal systemonline job portal system
online job portal system
 
Online job portal
Online job portal Online job portal
Online job portal
 
Project report-on-student-information-management-system-php-mysql
Project report-on-student-information-management-system-php-mysqlProject report-on-student-information-management-system-php-mysql
Project report-on-student-information-management-system-php-mysql
 

Ähnlich wie Php Power Tools

Head First Zend Framework - Part 1 Project & Application
Head First Zend Framework - Part 1 Project & ApplicationHead First Zend Framework - Part 1 Project & Application
Head First Zend Framework - Part 1 Project & Application
Jace Ju
 
Xdebug - Derick Rethans - Barcelona PHP Conference 2008
Xdebug - Derick Rethans - Barcelona PHP Conference 2008Xdebug - Derick Rethans - Barcelona PHP Conference 2008
Xdebug - Derick Rethans - Barcelona PHP Conference 2008
phpbarcelona
 
Continous delivery with Jenkins and Chef
Continous delivery with Jenkins and ChefContinous delivery with Jenkins and Chef
Continous delivery with Jenkins and Chef
defrag2
 

Ähnlich wie Php Power Tools (20)

Improving QA on PHP projects - confoo 2011
Improving QA on PHP projects - confoo 2011Improving QA on PHP projects - confoo 2011
Improving QA on PHP projects - confoo 2011
 
Improving qa on php projects
Improving qa on php projectsImproving qa on php projects
Improving qa on php projects
 
Write php deploy everywhere
Write php deploy everywhereWrite php deploy everywhere
Write php deploy everywhere
 
Write php deploy everywhere tek11
Write php deploy everywhere   tek11Write php deploy everywhere   tek11
Write php deploy everywhere tek11
 
PHP Development Tools
PHP  Development ToolsPHP  Development Tools
PHP Development Tools
 
Building com Phing - 7Masters PHP
Building com Phing - 7Masters PHPBuilding com Phing - 7Masters PHP
Building com Phing - 7Masters PHP
 
Ant vs Phing
Ant vs PhingAnt vs Phing
Ant vs Phing
 
Phing
PhingPhing
Phing
 
Symfony2 for Midgard Developers
Symfony2 for Midgard DevelopersSymfony2 for Midgard Developers
Symfony2 for Midgard Developers
 
Web-Performance
Web-PerformanceWeb-Performance
Web-Performance
 
Head First Zend Framework - Part 1 Project & Application
Head First Zend Framework - Part 1 Project & ApplicationHead First Zend Framework - Part 1 Project & Application
Head First Zend Framework - Part 1 Project & Application
 
Cooking with Chef
Cooking with ChefCooking with Chef
Cooking with Chef
 
Zend
ZendZend
Zend
 
Building Web Applications with Zend Framework
Building Web Applications with Zend FrameworkBuilding Web Applications with Zend Framework
Building Web Applications with Zend Framework
 
Xdebug - Derick Rethans - Barcelona PHP Conference 2008
Xdebug - Derick Rethans - Barcelona PHP Conference 2008Xdebug - Derick Rethans - Barcelona PHP Conference 2008
Xdebug - Derick Rethans - Barcelona PHP Conference 2008
 
Advanced Eclipse Workshop (held at IPC2010 -spring edition-)
Advanced Eclipse Workshop (held at IPC2010 -spring edition-)Advanced Eclipse Workshop (held at IPC2010 -spring edition-)
Advanced Eclipse Workshop (held at IPC2010 -spring edition-)
 
Continous delivery with Jenkins and Chef
Continous delivery with Jenkins and ChefContinous delivery with Jenkins and Chef
Continous delivery with Jenkins and Chef
 
WordCamp Montreal 2016 WP-API + React with server rendering
WordCamp Montreal 2016  WP-API + React with server renderingWordCamp Montreal 2016  WP-API + React with server rendering
WordCamp Montreal 2016 WP-API + React with server rendering
 
Magento 2 Development
Magento 2 DevelopmentMagento 2 Development
Magento 2 Development
 
Profiling PHP with Xdebug / Webgrind
Profiling PHP with Xdebug / WebgrindProfiling PHP with Xdebug / Webgrind
Profiling PHP with Xdebug / Webgrind
 

Mehr von Michelangelo van Dam

Zf2 how arrays will save your project
Zf2   how arrays will save your projectZf2   how arrays will save your project
Zf2 how arrays will save your project
Michelangelo van Dam
 

Mehr von Michelangelo van Dam (20)

GDPR Art. 25 - Privacy by design and default
GDPR Art. 25 - Privacy by design and defaultGDPR Art. 25 - Privacy by design and default
GDPR Art. 25 - Privacy by design and default
 
Moving from app services to azure functions
Moving from app services to azure functionsMoving from app services to azure functions
Moving from app services to azure functions
 
Privacy by design
Privacy by designPrivacy by design
Privacy by design
 
DevOps or DevSecOps
DevOps or DevSecOpsDevOps or DevSecOps
DevOps or DevSecOps
 
Privacy by design
Privacy by designPrivacy by design
Privacy by design
 
Continuous deployment 2.0
Continuous deployment 2.0Continuous deployment 2.0
Continuous deployment 2.0
 
Let your tests drive your code
Let your tests drive your codeLet your tests drive your code
Let your tests drive your code
 
General Data Protection Regulation, a developer's story
General Data Protection Regulation, a developer's storyGeneral Data Protection Regulation, a developer's story
General Data Protection Regulation, a developer's story
 
Leveraging a distributed architecture to your advantage
Leveraging a distributed architecture to your advantageLeveraging a distributed architecture to your advantage
Leveraging a distributed architecture to your advantage
 
The road to php 7.1
The road to php 7.1The road to php 7.1
The road to php 7.1
 
Open source for a successful business
Open source for a successful businessOpen source for a successful business
Open source for a successful business
 
Decouple your framework now, thank me later
Decouple your framework now, thank me laterDecouple your framework now, thank me later
Decouple your framework now, thank me later
 
Deploy to azure in less then 15 minutes
Deploy to azure in less then 15 minutesDeploy to azure in less then 15 minutes
Deploy to azure in less then 15 minutes
 
Azure and OSS, a match made in heaven
Azure and OSS, a match made in heavenAzure and OSS, a match made in heaven
Azure and OSS, a match made in heaven
 
Getting hands dirty with php7
Getting hands dirty with php7Getting hands dirty with php7
Getting hands dirty with php7
 
Zf2 how arrays will save your project
Zf2   how arrays will save your projectZf2   how arrays will save your project
Zf2 how arrays will save your project
 
Create, test, secure, repeat
Create, test, secure, repeatCreate, test, secure, repeat
Create, test, secure, repeat
 
The Continuous PHP Pipeline
The Continuous PHP PipelineThe Continuous PHP Pipeline
The Continuous PHP Pipeline
 
PHPUnit Episode iv.iii: Return of the tests
PHPUnit Episode iv.iii: Return of the testsPHPUnit Episode iv.iii: Return of the tests
PHPUnit Episode iv.iii: Return of the tests
 
Easily extend your existing php app with an api
Easily extend your existing php app with an apiEasily extend your existing php app with an api
Easily extend your existing php app with an api
 

Kürzlich hochgeladen

Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 

Kürzlich hochgeladen (20)

Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 

Php Power Tools

  • 1. PHP Power Tools Michelangelo van Dam PHPBenelux Meeting 2010, Leuven
  • 2. Michelangelo van Dam • Independent Consultant • Zend Certified Engineer (ZCE) - PHP 4 & PHP 5 - Zend Framework • Co-Founder of PHPBenelux • Shepherd of “elephpant” herds
  • 3. Why PHP Power Tools • early detection of issues • cleaner & consistent code • knowledge about the codebase • better code
  • 4. Usual Suspects PHP_CodeSniffer
  • 5. Example Code •- Zend Framework QuickStart app http://framework.zend.com/manual/en/learning.quickstart.intro.html
  • 6. VirtualHost Settings <VirtualHost *:80> DocumentRoot /srv/www/quickstart/public ServerName quickstart.local ServerAdmin root@localhost <Directory /srv/www/quickstart/public> Options Indexes FollowSymlinks AllowOverride All Order allow,deny Allow from all DirectoryIndex index.php </Directory> Alias /reports /srv/www/quickstart/reports <Directory /srv/www/quickstart/reports> Options Indexes FollowSymlinks AllowOverride All Order allow,deny Allow from all DirectoryIndex index.php index.html </Directory> </VirtualHost>
  • 8. Syntax Checking •- PHPLint comes with PHP binary - validates code for syntax errors • Website - http://www.icosaedro.it/phplint/
  • 10. Code Documentation •- PHPDocumentator creates automated API documentation - based on inline code blocks • Installation - pear install PhpDocumentor • Website - http://www.phpdoc.org
  • 13. Coding Standards •- PHP_CodeSniffer sniffs for coding standard violations - ensures code is clean and consistent - using standard and custom coding standards • Installation - pear install PHP_CodeSniffer • Website - http://pear.php.net/package/PHP_CodeSniffer
  • 15. PHPCPD •- PHP Copy/Paste Detector detects code duplication •- Installation pear channel-discover pear.phpunit.de - pear channel-discover components.ez.no - pear install --alldeps phpunit/phpcpd • Website - http://github.com/sebastianbergmann/phpcpd
  • 18. Mess Detection •- PDepend & PHPMD detects code mess •- Installation pear channel-discover pear.pdepend.org - pear install pdepend/PHP_Depend - pear channel-discover pear.phpmd.org - pear install phpmd/PHP_PMD • Websites - http://www.pdepend.org - http://www.phpmd.org
  • 22. Unit Testing •- PHPUnit tests code on unit level - includes database tests - integrates well with many PHP frameworks • Installation - pear channel-discover pear.phpunit.de - pear install phpunit/PHPUnit • Website - http://www.phpunit.de
  • 23. See other presentation http://www.slideshare.net/DragonBe/phpunit-testing-to-zendtest
  • 24. Automated builds •- Phing automated build tool - like Apache Ant - integrates well with other PHP tools • Installation - pear channel-discover pear.phing.info - pear install phing/phing • Website - http://phing.info
  • 25. build.xml <?xml version="1.0"?> <project name="zfqs" description="Zend Framework QuickStart" default="build" > <target name="version"> <version releasetype="Bugfix" file="build.version" property="version.number"/> </target> <target name="phplint"> <mkdir dir="./reports/phplint" /> <phplint file="./application/models" haltonfailure="false" tofile="./reports/phplint/errors.txt"/> </target> <target name="pdepend"> <mkdir dir="./reports/pdepend" /> <copy file="./build_pdepend.html" tofile="./reports/pdepend/index.html" overwrite="true" /> <exec command="/usr/bin/pdepend --summary-xml=./reports/pdepend/summary.xml --jdepend-chart=./reports/pdepend/jdepend.svg --overview-pyramid=./reports/pdepend/pyramid.svg ./application/models" dir="./" /> </target> <target name="phpmd"> <mkdir dir="./reports/phpmd" /> <exec command="/usr/bin/phpmd ./application/models html codesize --reportfile ./reports/phpmd/codesize.html" dir="./" /> <exec command="/usr/bin/phpmd ./application/models html unusedcode --reportfile ./reports/phpmd/unusedcode.html" dir="./" /> </target> <target name="phpcs"> <mkdir dir="./reports/phpcs" /> <exec command="/usr/bin/phpcs -n --standard=Zend --report=summary ./application/models > ./reports/phpcs/summary.txt" dir="./" /> <exec command="/usr/bin/phpcs -n --standard=Zend --report=source ./application/models > ./reports/phpcs/source.txt" dir="./" /> <exec command="/usr/bin/phpcs -n --standard=Zend --report=checkstyle ./application/models > ./reports/phpcs/checkstyle.xml" dir="./" /> </target> <target name="phpcpd"> <mkdir dir="./reports/phpcpd" /> <exec command="/usr/bin/phpcpd --log-pmd ./reports/phpcpd/pmd-cpd.xml ./application/models" dir="./" /> </target> <target name="phpdoc"> <mkdir dir="./reports/phpdoc" /> <exec command="phpdoc -d ./application/models -q -t ./reports/phpdoc -o HTML:frames:earthli" dir="./" /> </target> <target name="build" depends="version,phplint,pdepend,phpmd,phpcs,phpcpd,phpdoc"> <echo msg="Finishing build process ${version.number}" /> </target> </project>
  • 26. project definition <?xml version="1.0"?> <project name="zfqs" description="Zend Framework QuickStart" default="build" > … </project>
  • 27. target version <target name="version"> <version releasetype="Bugfix" file="build.version" property="version.number"/> </target> In file “build.version” we have the version number as the following sequence: MAJOR.MINOR.BUGFIX (starting at 0.0.0)
  • 28. target phplint <target name="phplint"> <mkdir dir="./reports/phplint" /> <phplint file="./application/models" haltonfailure="false" tofile="./reports/phplint/errors.txt"/> </target>
  • 29. target pdepend <target name="pdepend"> <mkdir dir="./reports/pdepend" /> <copy file="./build_pdepend.html" tofile="./reports/pdepend/index.html" overwrite="true" /> <exec command="/usr/bin/pdepend --summary-xml=./reports/pdepend/summary.xml --jdepend-chart=./reports/pdepend/jdepend.svg --overview-pyramid=./reports/pdepend/pyramid.svg ./application/models" dir="./" /> </target>
  • 30. target phpmd <target name="phpmd"> <mkdir dir="./reports/phpmd" /> <exec command="/usr/bin/phpmd ./application/models html codesize --reportfile ./reports/phpmd/codesize.html" dir="./" /> <exec command="/usr/bin/phpmd ./application/models html unusedcode --reportfile ./reports/phpmd/unusedcode.html" dir="./" /> </target>
  • 31. target phpcs <target name="phpcs"> <mkdir dir="./reports/phpcs" /> <exec command="/usr/bin/phpcs -n --standard=Zend --report=summary ./application/models > ./reports/phpcs/summary.txt" dir="./" /> <exec command="/usr/bin/phpcs -n --standard=Zend --report=source ./application/models > ./reports/phpcs/source.txt" dir="./" /> <exec command="/usr/bin/phpcs -n --standard=Zend --report=checkstyle ./application/models > ./reports/phpcs/checkstyle.xml" dir="./" /> </target>
  • 32. target phpcpd <target name="phpcpd"> <mkdir dir="./reports/phpcpd" /> <exec command="/usr/bin/phpcpd --log-pmd ./reports/phpcpd/pmd-cpd.xml ./application/models" dir="./" /> </target>
  • 33. target phpdoc <target name="phpdoc"> <mkdir dir="./reports/phpdoc" /> <exec command="phpdoc -d ./application/models -q -t ./reports/phpdoc -o HTML:frames:earthli" dir="./" /> </target>
  • 34. target build <target name="build" depends="version,phplint,pdepend,phpmd,phpcs,phpcpd,phpdoc"> <echo msg="Finishing build process ${version.number}" /> </target>
  • 38. Summary PHP offers lots of tools more consistent and clean code automated process
  • 39. Thank you Slides on slideshare http://www.slideshare.net/group/phpbenelux Don’t forget to thank our sponsor

Hinweis der Redaktion