說明
這兩天是 Zend 的研討會,有很多大師級人物主講。其中 Best Practices of PHP Development 是 10/31 號的一個議題,提到了一些在 PHP 開發上比較好的規則,大家可以參考看看。
其他還有很多不錯的議題,有空再去收集相關的資訊。
重點節錄
Source Documentation
- PHPDoc is the defacto documentation standard, it can be parsed by PHPDocumentor and Doxygen
- Use @category and @package to manage your documentation
- Using PHPDoc allows all developers to immediately understand your code
Unit Testing
- Focusing on PHPUnit
- Test religiously
- Without tests, code is fragile and will regress - there is nothing to tell you when you break your code.
- You are not wasting time by creating tests, you're wasting time by peppering your code with var_dump() and trying to debug code manually.
- Learning to write good object oriented code that is testable takes practice and discipline. Learn to design for usability.
- Test-First methodology allows the tests to become the specification of code you are writing.
- Using Classes is not Object Oriented Design
Source Control
- Source control was on the benefits of using SVN to manage your code.
- Learn to use tagging and branching instead of committing everything to HEAD
- Trac is cool (I caught up on emails during this section - great wifi)
Deployment
- Never edit code on the server
- Check out tagged branches from your svc software
- Deploy to a staging server on your production server, test first then modify the symlink.
- Write acceptance and integration tests: http://manuals.rubyonrails.com/read/book/17)
- Monitor Health of Servers: http://www.plope.com/software/supervisor/
- Store schema of your database by committing the schema into your svc server - suggestion: http://www.mysqldiff.org/ and pre-commit hooks