Skip to main content

Posts

Showing posts from December, 2008

PhpUnderControl Framework For Symfony Projects

Introduction phpUnderControl is an extension for Cruise Control that integrates several PHP development tools, such as PHPUnit Which contains a rich set of features like Unit Testing and Functional Testing, Code Coverage, Project Mess Detection and Software Metrics etc, PHP_Code Sniffer For static code analysis PHPDocumentor For API documentation generation. It comes with a powerful command-line tool that can, among other things, automatically create Cruise Control’s XML configuration files for your project. To know more about PhpUnderControl please visit the blog posted by my friend Anoop: http://anoosphpundercontrol.wordpress.com/2008/07/29/phpundercontrol-framework-for-symfony-projects

Symfony Coding Standards

The golden rule: Imitate the existing symfony code [1] Never use tabulations in the code. Indentation is done by steps of 4 blanks. For yml files 2 blanks should be used. [2] Don't put spaces after an opening parenthesis and before a closing one. if ($reqvalue == _getRequestValue($name)) correct if ( $reqvalue == _getRequestValue($name) ) incorrect [3] Use camelCase, not underscores, for variable, function and method names. [4] Use underscores for helper functions name (only for symfony 1.0 stuff). [5] Use underscores for option/argument/parameter names. [6] Braces always go on their own line. [7] Use braces for indicating control structure body regardless of number of statements it contains. [8] Don't end library files with the usual ?> closing tag. This is because it is not really needed, and because it can create problems in the output if you ever have white space after this tag. [9] In a function body, return stateme

PHP Codesniffer standard for Symfony

I have created a standard for Symfony framework to use with PHP code sniffer. -Download and install PHP code sniffer http://pear.php.net/package/PHP_CodeSniffer -Check out the code from subversion http://subversion.assembla.com/svn/phpsymfony/Symfony%20Code%20sniffer%20standards -Copy the Symfony directory to the code sniffer standard directory -Put --standard=Symfony for validating the file using Symfony coding standards $ phpcs --standard=Symfony /path/to/code/myfile.php