PHP Quality Assurance Workshop PHPBenelux

Embed Size (px)

Citation preview

Quality Assurance for PHP projects

Quality Assurance for PHP projects - workshop

Nick Belhomme
PHP Software Architect + conference speaker + book author

29 June 2011

Quality Assurance for PHP projects - workshop

Nick Belhomme
PHP Software Architect + conference speaker + book author

29 June 2011

About me:

Independent Consultant

Int. Conference Speaker

Book Author of Zend Framework 2.0 Cookbook

ZF Contributor since 2008

PHP Community active member

Quality Assurance for PHP projects - workshop

Nick Belhomme
PHP Software Architect + conference speaker + book author

29 June 2011

Benefits

Provides trust into your application

Builds up your confidenceBug fixes

Feature implementations

Refactoring

Software Updates (php update, PEAR library update, )

Stability makes you proud

Strokes your ego (you use Continues Integration tools)

Career opportunities (You follow the current market standards)

Managers like graphs and figures

Apply the power and be a master of the project

Fanboy30

Rob Blatt

Quality Assurance for PHP projects - workshop

Nick Belhomme
PHP Software Architect + conference speaker + book author

29 June 2011

Management

Should give 100% supportQuality Assurance lead Team Lead

Technical requirements

Deployment strategies

Receives:More stable applications

Graphs and figures to support it

More and better documentation for replacement / outsourcing

Progress tracking

Quality Assurance for PHP projects - workshop

Nick Belhomme
PHP Software Architect + conference speaker + book author

29 June 2011

The Demo Application

Prerequisites:Git or SVN with Pre-commit hooks

PHP Tools

Doxygen (potential replacement for PHPDocumentor)

Phing

Jenkins (for Continues Integration)

Quality Assurance for PHP projects - workshop

Nick Belhomme
PHP Software Architect + conference speaker + book author

29 June 2011

Common Pre-Commit Hooks

Commit Message Level:Commit message has a specific formatnumber of characters (not empty, or at least 10)

regex: ^(\[BUGFIX\]|\[FEATURE\]|\[TASK\])+ (.+\n+)+\nbuild: #\d+$

File Level:ascii filenames

file extensions

Code Level:no Tabs

parse errors (php -l )

PHP Codesniffer with certain standard

Quality Assurance for PHP projects - workshop

Nick Belhomme
PHP Software Architect + conference speaker + book author

29 June 2011

SVN Pre-Commit Hook

Easy to install if root access, or at least subversion user access: Create a common hooks directory (reuse)Implement a pre-commit hook in the language of choice (#!/usr/bin/php)

Make the hook executable (744) and set right ownership (apache:subversion)

In your PROJECT_PATH_TO_REPOS/hooks folder create a pre-commit filePoint towards previous implemented general pre-commit hook(s)

Enjoy

Quality Assurance for PHP projects - workshop

Nick Belhomme
PHP Software Architect + conference speaker + book author

29 June 2011

Svnlookauthor, cat, changed, info

SVN Pre-Commit Hook

Works on revision $REPOS or transaction $TXN

PHP Access

$repos = $argv[1];$txn = $argv[2];

Quality Assurance for PHP projects - workshop

Nick Belhomme
PHP Software Architect + conference speaker + book author

29 June 2011

SVN Pre-Commit Hook

Quality Assurance for PHP projects - workshop

Nick Belhomme
PHP Software Architect + conference speaker + book author

29 June 2011

SVN Pre-Commit Hook

Quality Assurance for PHP projects - workshop

Nick Belhomme
PHP Software Architect + conference speaker + book author

29 June 2011

SVN Pre-Commit in effect

Quality Assurance for PHP projects - workshop

Nick Belhomme
PHP Software Architect + conference speaker + book author

29 June 2011

SVN Pre-Commit in effect

Quality Assurance for PHP projects - workshop

Nick Belhomme
PHP Software Architect + conference speaker + book author

29 June 2011

Git Pre-Commit Hook

Easy to install: Create a common hooks directory (reuse)Implement a pre-commit hook in the language of choice (#!/usr/bin/php)

Make the hook executable (744)

In your PROJECT_PATH/.git/hooks folder create a pre-commit filePoint towards previous implemented general pre-commit hook(s)

Enjoy

In contrast with svn, Git Hooks are CLIENT side

Quality Assurance for PHP projects - workshop

Nick Belhomme
PHP Software Architect + conference speaker + book author

29 June 2011

PHP Tools

PHP depend (pdepend)

PHP Mess Detector (phpmd)

PHP Copy Paste Detector (phpcpd)

PHP Lines Of Code (phploc)

PHP Codesniffer (phpcs)

PHP Unit (phpunit)

PHP Code Browser (phpcb)

PHP Lint (php -l)

Quality Assurance for PHP projects - workshop

Nick Belhomme
PHP Software Architect + conference speaker + book author

29 June 2011

PHP Tools Install

pear channel-discover pear.pdepend.org

pear channel-discover pear.phpmd.org

pear channel-discover pear.phpunit.de

pear channel-discover components.ez.no

pear channel-discover pear.symfony-project.com

Quality Assurance for PHP projects - workshop

Nick Belhomme
PHP Software Architect + conference speaker + book author

29 June 2011

PHP Tools Install

pear install pdepend/PHP_Depend

pear install phpmd/PHP_PMD

pear install phpunit/phpcpd

pear install phpunit/phploc

pear install PHPDocumentor

pear install PHP_CodeSniffer

pear install --alldeps phpunit/PHP_CodeBrowser

pear install --alldeps phpunit/PHPUnit

Quality Assurance for PHP projects - workshop

Nick Belhomme
PHP Software Architect + conference speaker + book author

29 June 2011

Doxygen

What: Generate Documentation From Source Code

Benefits: Actively maintained, in contrast with PHPDocumentor

Visualize relationships between your code (+ graphviz)

Various output formats

Install:Binary distributions for all major operating systems

Packages for linux

http://doxygen.org/

Quality Assurance for PHP projects - workshop

Nick Belhomme
PHP Software Architect + conference speaker + book author

29 June 2011

Phing

What: PHP project build system, build tool based on Apache Ant

Benefits:Written in PHP, so you can flavor it (maybe even contribute)

If your server can handle PHP it can handle Phing

Install:$> pear config-set preferred_state alpha

$> pear install --alldeps phing/phing

$> pear config-set preferred_state stable

Potential Problems:The correct commands => try first outside phing

Memory

http://www.phing.info

Quality Assurance for PHP projects - workshop

Nick Belhomme
PHP Software Architect + conference speaker + book author

29 June 2011

Jenkins

What: the leading open-source continuous integration server

Benefits:Large plugin base (+300)

Active Community

Install: binaries and packages readily available

Potential Problems:What plugins to install (Phing, Mantis, PHP Tools, ...)

Build Configuration learning curve

http://jenkins-ci.org

Quality Assurance for PHP projects - workshop

Nick Belhomme
PHP Software Architect + conference speaker + book author

29 June 2011

Deployment

Strategies: Whodevelopers, release manager, team lead, Jenkins, ...

Whatnightly builds, successful builds, ...

Wheredeployment to what kind of server

Whenoff-peak traffic, critical, release cycle

Quality Assurance for PHP projects - workshop

Nick Belhomme
PHP Software Architect + conference speaker + book author

29 June 2011

Deployment

Strategies: HowRoll back mechanisms, switchable

Transferrsync, ftp, tar, phar

Permissionsfolders, files

user rightsfolder, files

Quality Assurance for PHP projects - workshop

Nick Belhomme
PHP Software Architect + conference speaker + book author

29 June 2011

Additional Resources

http://svnbook.red-bean.com/

http://git-scm.com/documentation

http://qualityassuranceinphpprojects.com/

http://www.phing.info/docs/guide/stable/

https://wiki.jenkins-ci.org/display/JENKINS/Use+Jenkins

http://jenkins-php.org/

irc.freenode.net #jenkins, #phing

Quality Assurance for PHP projects - workshop

Nick Belhomme
PHP Software Architect + conference speaker + book author

29 June 2011

Sources and Codes

Slides: http://slideshare.net/NickBelhomme

Source: https://github.com/NickBelhomme/SVN-Commit-Hooks

Contact:mail: [email protected]

twitter: @NickBelhomme

facebook: NickBelhomme

irc (freenode ##php, #php_bnl, #zftalk): NickBelhomme

Quality Assurance for PHP projects - workshop

Nick Belhomme
PHP Software Architect + conference speaker + book author

29 June 2011

Lets enjoy the Demo

Chris Devers