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!

ThebestapproachforsendingemailsinPHPisusingthePHPMailerlibraryduetoitsreliability,featurerichness,andeaseofuse.PHPMailersupportsSMTP,providesdetailederrorhandling,allowssendingHTMLandplaintextemails,supportsattachments,andenhancessecurity.Foroptimalu

The reason for using Dependency Injection (DI) is that it promotes loose coupling, testability, and maintainability of the code. 1) Use constructor to inject dependencies, 2) Avoid using service locators, 3) Use dependency injection containers to manage dependencies, 4) Improve testability through injecting dependencies, 5) Avoid over-injection dependencies, 6) Consider the impact of DI on performance.

PHPperformancetuningiscrucialbecauseitenhancesspeedandefficiency,whicharevitalforwebapplications.1)CachingwithAPCureducesdatabaseloadandimprovesresponsetimes.2)Optimizingdatabasequeriesbyselectingnecessarycolumnsandusingindexingspeedsupdataretrieval.

ThebestpracticesforsendingemailssecurelyinPHPinclude:1)UsingsecureconfigurationswithSMTPandSTARTTLSencryption,2)Validatingandsanitizinginputstopreventinjectionattacks,3)EncryptingsensitivedatawithinemailsusingOpenSSL,4)Properlyhandlingemailheaderstoa

TooptimizePHPapplicationsforperformance,usecaching,databaseoptimization,opcodecaching,andserverconfiguration.1)ImplementcachingwithAPCutoreducedatafetchtimes.2)Optimizedatabasesbyindexing,balancingreadandwriteoperations.3)EnableOPcachetoavoidrecompil

DependencyinjectioninPHPisadesignpatternthatenhancesflexibility,testability,andmaintainabilitybyprovidingexternaldependenciestoclasses.Itallowsforloosecoupling,easiertestingthroughmocking,andmodulardesign,butrequirescarefulstructuringtoavoidover-inje

PHP performance optimization can be achieved through the following steps: 1) use require_once or include_once on the top of the script to reduce the number of file loads; 2) use preprocessing statements and batch processing to reduce the number of database queries; 3) configure OPcache for opcode cache; 4) enable and configure PHP-FPM optimization process management; 5) use CDN to distribute static resources; 6) use Xdebug or Blackfire for code performance analysis; 7) select efficient data structures such as arrays; 8) write modular code for optimization execution.

OpcodecachingsignificantlyimprovesPHPperformancebycachingcompiledcode,reducingserverloadandresponsetimes.1)ItstorescompiledPHPcodeinmemory,bypassingparsingandcompiling.2)UseOPcachebysettingparametersinphp.ini,likememoryconsumptionandscriptlimits.3)Ad


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

SublimeText3 English version
Recommended: Win version, supports code prompts!

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool
