Starting of with familiar circumstances that all developers have seen in their career towards using tools that help document, validate and test their code, because that's what CI is all about for PHP development
2. Who am I ?
Michelangelo van Dam
Independent Enterprise PHP consultant
Co-founder PHPBelgium
Mail me at dragonbe [at] gmail [dot] com
Follow me on http://twitter.com/DragonBe
Read my articles on http://dragonbe.com
See my profile on http://linkedin.com/in/michelangelovandam
2
3. Topics
• Development practices • PHP Toolset
- Live Development - Subversion
- Shared Drive - PHPDocumentor
- Staged Environments - PHPUnit
- Version Control - Xdebug
- Automation - Phing
- Continuous - CI
Integration
3
5. Live Development
• development on “live” server
• errors, failures and warnings exposed
• potential security risks
• no way to revert back (w/o backups)
5
6. Shared drive
• using a shared drive to store code base
• risk of overwriting each other’s work
• code is uploaded to “live” server for testing
• quick fixes occur on “live” environments for speed
• same issues as with “live development”
6
7. Staged Environments
• separate platform for each “stage” of development
- LOCAL for local development
- DEV to combine all development of all developers
- TEST to test the application(s)
- ACC for acceptance by the customer(s)
- PROD as production or “live” system
7
8. Version Control
• each change of code is registered (revision)
• code conflicts are detected
• release management possible
• reverting to previous revisions
• backup
8
9. Automation
• write once, run many
• is less vulnerable to human error
- humans still write scripts to automate processes !
• can be scheduled, triggered, pushed and pulled
• behaves always in the same way
- so results can be predictable
9
10. Continuous Integration
• automated process
- build
- test
- deploy
• in a continuous way
- after each commit into versioning system
- at specific intervals (e.g. nightly builds)
• always a “deployable” release
10
12. Versioning your code
• Subversion
- more options then CVS
- can be integrated with GIT
• easy set up / maintain
- all OSes (Windows, Mac, Linux, ...)
- great support in tools (IDE and regular clients)
• good documentation (http://subversion.tigris.org)
12
13. Document your code
• PHPDocumentor
www.phpdocumentor.org
• provides immediate API
documentation
• based on in-code
documentation
13
14. Check your code
• PHPLint
• checks your code on coding errors
• creates documentation based on source code
• http://www.icosaedro.it/phplint/
• or use php -l <file.php>
14
15. Test your code
• PHPUnit (phpunit.de)
- family of the xUnit testing suites
• easy to learn, hard to do ...
• easy to install (using PEAR)
• provides extra features
- code duplication detection (cdd)
- code coverage reporting (with Xdebug)
- test driven documentation
15
16. Debug your code
• Xdebug (xdebug.org)
- advanced debug reporting
- profiling features
• Integrates well with other tools (like PHPUnit)
16
17. Validate your code
• PHP_CodeSniffer
• PEAR package
• checks your code for coding standards
• http://pear.php.net/package/PHP_CodeSniffer
17
18. Build your code
• Phing (phing.info)
• alternate for ANT
• building is more automating previous steps
• ensures you’ll run all steps the same way
18
19. Let’s automate this all !
• CruiseControl as your CI system
• phpUnderControl has a more detailed interface
• uses Phing build files to process all previous steps
• generates reports for each stage
• triggered by
- commits into the repository
- scheduled building processes (e.g. each night)
19
21. Conclusion
CI automates manual processes
continues to do so on each cycle (“continuous”)
reports on successes and failures
frees up versioning system resources
21
22. Credits
Lomo elePHPant
http://www.flickr.com/photos/jakobwesthoff/3231273333/
ElePHPant to the rescue
http://www.flickr.com/photos/tobiasschlitt/2733763988/
22
23. License
This presentation is released under the Creative Commons
Attribution-Share Alike 3.0 Unported License
You are free:
- to share : to copy, distribute and transmit the work
- to remix : to adapt the work
Under the following conditions:
- attribution :You must attribute the work in the manner specified by the author or licensor
- share alike : If you alter, transform, or build upon this work, you may distribute the resulting work
only under the same, similar or a compatible license
See: http://creativecommons.org/licenses/by-sa/3.0/
23
24. Thank you
Slides available on
http://slideshare.net/DragonBe
Vote this presentation on
http://joind.in/444
24
Hinweis der Redaktion
convince audience this is BAD
who knows / does this ???
Versioning essentials
PHPUnit is a separate talk (see Sebastian Bergmann)