Php Development specifications

Source: Internet
Author: User
Tags coding standards modx
Php Development specifications: This specification should be a basic specification. Most programmers know this specification, which should be developed using ZendFramework.

Refer:

Development Principles

1. Business logic is written in the stored procedure of the database, and data query and combination are completed in the program.
2. the stored procedure must be modified with a dedicated program. modification is prohibited directly on the client.
3. the business process description for this operation must be written in the stored procedure header.
4. The database uses the DECIMAL type for all numbers with DECIMAL points. The FLOAT type is not allowed.
5. use BIGINT (20) unsigned auto increment for database primary keys
6. all CSS/JavaScript files are written in independent files based on their respective functions.
7. all JavaScript are written in the form of jQuery App plug-ins
8. only the page control is used to output data in the view.
9. the controller is only responsible for obtaining data, setting page controls, or calling model operations.
10. each business operation of the controller allows only one method of calling one model.
11. the model does not necessarily operate on the database, but must define or save data. Otherwise, the model should be an assistant.
12. the helper can be a pure static class or instantiated object.
13. use PHPDoc to comment out basic information about each object, method, function, and variable
14. key processing or logic must be described in detail
15. The Assistant name must end with Helper
16. you do not need to add Model to the Model name.
17. use Igou: modx () instead of global $ modx
18. use Zend_Db_Select to assemble SQL statements

Database naming rules

1. id is used as the field name for the primary key of the data table.
2. use _ to separate the names of fields in the database. two words cannot be written together.
3. add the igou _ prefix to all the self-built data tables on the Internet to facilitate differentiation from modx.
4. Data tables use the singular form

Coding Standards

1. variables, methods, and functions are case sensitive and the first letter is lowercase.
2. the object name is separated by a hyphen, and the first letter of the word is capitalized.
3. constants use the singular form.
4. add the IGOU _ prefix to the custom constants.
5. do not write at the end of a pure PHP file?>
6. no spaces (including blank lines) are left at the end of the source code file line)
7. non-public method or attribute (variable) name plus _ prefix

Note 1. use external code snippets [! Fragment name!] Call, not [[Segment name]
2. you can use the external code snippet [! Controller: Action!] Call the method of the Index controller if no controller is specified
3. use $ this-> _ response-> setBody ('content') when the code snippet corresponds to the content returned by the Action ');
4. all external code snippets are called by the SnippetsController of the Plugins.
5. globally shared View Helper is placed under library/Igou/View/Helper

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.