Home > Backend Development > PHP Tutorial > Share an internal specification for PHP development

Share an internal specification for PHP development

藏色散人
Release: 2023-04-10 19:48:01
forward
3469 people have browsed it

1. PHP Notes

  • 1. The URL request address is split by "-". (Already implemented, some people did not implement it according to the standard)
  • 2. Use camel case method for method names. (It has been implemented, but some people have not implemented it according to the standard)
  • 3. Parameters must be lowercase and separated by underscores. It is strictly prohibited to use camel case or other formats, and the submitted parameters must be consistent with the returned field names. (It has been implemented, but some people have not implemented it according to the standards)
  • 4. GET is used to obtain data, and POST is required for additions and modifications. (Already implemented, some people did not implement it according to the standard)
  • 5. The API return format must call the jsonResult basic method. (Executed)
    6. The error code must call ErrCode, and the error code number cannot be written directly. (Executed)
  • 7. Paging uses the framework’s own, self-built two-dimensional array must be [‘data’ => $arr], and paging entries must use the limit parameter. (Executed)
  • 8. The interface returns remark information (msg), which must be written in the config.msg file. (New)
  • 9. The redis key must be written in the config.redis_key file. (It has been implemented, but some people have not implemented it according to the standard)
  • 10. When composer installs new dependencies, it must be written in the doc/composer.txt file and explain the purpose. (Executed)
  • 11. To add a new scheduled task, the process must be written in the doc/crontab.txt file and explain the purpose. (Executed)
  • 12. Redis must have an expiration time set. Otherwise, save mysql and then cache (newly added)
  • 13. The model name is consistent with the table name (for example: table q_user MODEL: QUser)
  • 14. When requesting an external network address, the request duration must be set 2s
  • 15. Redis does not store long-term data and is only used for caching and temporary data storage (later transfer can easily lead to data loss)

2. Mysql Precautions
New table (responsible person: Liu Jun)

  • 1. Character set utf8mb4 sorting specification utf8mb4_unicode_ci (implemented, some people have not implemented it according to the standard)
  • 2 , database fields must be lowercase and underlined (implemented, some people do not follow the standard)
  • 3. New table fields must have status, created_at, updated_at (associated tables often miss three fields)
  • 4. The status must be 1 to enable, 0 to disable
  • 5. Try not to use NULL
    query
  • 1. The query sql field must be added with the table name (problems have occurred online) )
  • 2. It is strictly prohibited to use * to query
  • 3. The sql statement must be written in model and cannot be written in the controller
    Update, insert, delete
  • 1.Update , inserting and deleting multiple pieces of data, non-log types must use transactions (to ensure consistency)

3. Notes on YAPI documentation

  • 1. Field descriptions must be consistent with the product documentation (front-end feedback verification fields are not clear)
  • 2. Iterative version interfaces need to add a new version directory (to prevent confusion)
  • 3. The interface has changed , the interface document must be updated simultaneously

4. Merging branches

  • 1. You must create a branch development with master and bring your own name (origin/hotfix/huang/slowOpt)
  • 2. When publishing to master, you must first merge master with the development branch.
  • 3. "Test branch" is prohibited from being merged into "development branch"
  • 4. "Pre-release branch" is prohibited from being merged into "development branch"
PHP development internal standards, welcome to make optimization suggestions~
Recommended study: "PHP Video tutorial

The above is the detailed content of Share an internal specification for PHP development. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:learnku.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template