PHP Extended Development Inspection Checklist

Source: Internet
Author: User
Tags coding standards php coding standards

This article introduces the content of the PHP extension development test List, has a certain reference value, now share to everyone, the need for friends can refer to

To make a successful PHP expansion package, not just simply put the code in the folder, but there are a lot of factors to determine whether your extension is good. The contents of the following checklist will help refine your extension and get more attention in the PHP community.

1. Choose a proper name for your extension

    • Make sure that your naming is not used by other projects.

    • The name of the extension needs to be consistent with your PHP namespace.

    • Don't use your name or any other personal color in your namespace.

2. Expand your open source

    • GitHub can manage this category of public projects for free.

    • GitHub can help you manage this open source project and make it easier for others to get your extensions.

    • If you don't want to use it, you can try a substitute: bitbucket.

3. Friendly to auto-loading

    • Use the PSR-4 compatible Autoloader namespace.

    • Please put the code in the src folder.

4. Release via Composer

    • Make sure you can find your class library through Composer, Composer is a dependency management tool for PHP

    • Posted on Packagist, Packagist is a major Composer-pack warehouse.

5. Not limited to the framework

    • Do not limit projects to only use on one frame.

    • Provide special support to the framework through a service provider.

6. Follow a coding style

    • It is strongly recommended that you stick to the PSR-2 coding style.

    • Use code Auto-formatting tools, such as PHP Coding standards Fixer.

    • Use code style detection tools, such as PHP code Sniffer.

7. Writing unit Tests

    • Cover most of the code.

    • Using PHPUnit, a common PHP unit testing framework.

    • Other options: Phpspec, Behat, Atoum, Codeception.

8. Write a comment for the code

    • Treat annotations as a built-in document.

    • Code annotations can also improve the IDE's code autocomplete capabilities, such as Phpstorm.

    • can be automatically converted into API documentation to view Phpdocumentor.

9. Semantic versioning of the language

    • Use the semantic version number to manage the version number.

    • Follow the main version. Minor version. Patch version specification.

    • Let developers safely upgrade software without worrying about disruptive changes.

    • Please remember to label the release version in time!

10. Keep the log updated regularly

    • Clearly Mark and show the significant changes between versions.

    • Consider following the Keep a CHANGELOG format for writing.

11. Using Continuous Integration

    • Use the service to automatically check whether the encoding is standard and to run the test.

    • It's a good idea to run tests in several different versions of PHP.

    • Be sure to run automatically when you submit or pull.

    • Reference: Travis-ci,scrutinizer, Circle-ci.

12. Write a large number of use documents

    • An excellent document is essential for an expansion package.

    • At a minimum, make sure that you have a detailed readme file in the library.

    • You can try to host the document in GitHub Pages.

    • Available References: Read the Docs.

13. Include an Authorization (License)

    • Includes an authorization agreement that can effectively protect the results of your work and is easy to do.

    • Refer to choosealicense.com. Most PHP open source projects use the MIT protocol.

    • At a minimum, include the LICENSE file in the code base.

    • You may also consider adding your license agreement to the Docblocks.

14. Welcome the contribution of all

    • Want to help improve the project, it must be a lot of requests for the contribution of everyone!

    • There is a copy of the contributing file that lists the contributors ' names.

    • Use this document to interpret project environmental requirements, such as test environments.

For more modern PHP knowledge, go to the laravel/php knowledge community

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.