Developer guidelines
From PmaWiki
(Redirected from Coding guidelines)
phpMyAdmin is Open Source, so you're invited to contribute to it. Many great features have been written by other people and you too can help to make phpMyAdmin a useful tool.
If you're planning to contribute source, please read the following information:
- All files include libraries/common.inc.php (common functions) at the very top.
- Only configuration data should go in libraries/config.default.php. Please keep it free from other code.
- Commonly used functions should be added to libraries/core.lib.php or libraries/common.lib.php and more specific ones may be added within a library stored into the libraries/ sub-directory.
- Please stick with PEAR coding style and please try to keep your code as simple as possible: beginners are using phpMyAdmin as an example application.
- To verify coding style you can install PHP_CodeSniffer and validate your code using
phpcs --standard=PMAStandard file.php. - As far as possible, we want the scripts to be XHTML1.0 and CSS2 compliant on one hand, they fit the PEAR coding standards on the other hand. Please pay attention to this.
- To verify coding style you can install PHP_CodeSniffer and validate your code using
- Use an indent of 4 spaces, with no tabs.
- See PEAR identation rules for more details.
- If your using vim as an editor, tabs will automatically be converted into 4 spaces by the directive on top of each file in the phpMyAdmin codebase :
/* vim: set expandtab sw=4 ts=4 sts=4: */
Make sure to add this to your .vimrc to make it work :
set modeline
- Please enable showing PHP errors and warnings by the
$cfg['Error_Handler']['display']configuration directive, see Config#Error_Handler. - Please try to keep up the file-naming conventions. Table-related stuff goes to tbl_*.php, db-related code to db_*.php, server-related tools to server_*.php and so on.
- Please use gettext wrappers around all messages (
__('Some text')or_ngettext()function). See Gettext for developers for more information. - The DBG extension (PHP Debugger DBG) is now supported by phpMyAdmin for developers to better debug and profile their code. Please see the Config#DBG configuration options for more information.
- If you want to be really helpful, write an entry for the ChangeLog.
- Join the phpmyadmin-git mailinglist if you are interested in every single commit.
- When you have commit access, make sure you join this list with your sourceforce emailalias, otherwise every commit message email is placed in the moderation queue.
- Use inline documenation.
- PHP-Doc compatible for PHP.
- JS-Doc compatible for JavaScript.
[edit] Author names
Except from "borrowed" libraries like PHPExcel and tcpdf, we do not put author names in source code. Here are the reasons:
- over time, code gets modified so marking that some block of code was authored by X becomes misleading
- the source-code revision control (git for us) already tracks authorship (line by line)
- the author does not "own" the code; he may be more familiar with it but team members can modify it (and the community can propose patches)
- significant authors are credited in Documentation.html.