PHP extension development checklist (required for extension development)

write picture description here

To make a successful PHP extension, it's not just about putting the code in a folder, there are many other factors that determine whether your extension is good or not. The contents of the following list will help refine your extension and get more attention in the PHP community.

1. Choose a proper name for your extension

  • Make sure your naming is not used by other projects.
  • The extension name needs to match your PHP namespace.
  • Don't use your own name or anything else personal in your namespace.

2. Open source your extension

  • GitHub is free to manage such public projects.
  • GitHub is very helpful for you to manage this open source project and make it easy for others to get your extensions.
  • If you don't want to use, you can try an alternative: Bitbucket .

3. Be friendly to autoloading

  • Use a PSR-4 compatible autoloader namespace.
  • Please put the code in srcthe folder.

4. Publish via Composer

  • Make sure your class library can be found through Composer , a dependency management tool for PHP
  • Posted on Packagist , the main Composer package repository.

5. Not limited to frameworks

  • Don't limit your projects to only one framework.
  • Special support is provided to the framework through service providers.

6. Follow a coding style

7. Write unit tests

8. Write comments for code

  • Treat comments as built-in documentation.
  • Code comments can also improve code auto-completion in IDEs, such as PhpStorm .
  • Can be automatically converted to API documentation, see phpDocumentor .

9. Use Semantic Versioning

  • Use Semantic Versioning to manage version numbers.
  • Follow the major version.minor version.patch version specification.
  • Let developers upgrade software safely without worrying about breaking changes.
  • Remember to tag releases in time!

10. Keep a regular update log

  • Significant changes between versions are clearly marked and shown.
  • Consider writing in the format of Keep a CHANGELOG .

11. Use Continuous Integration

  • Use a service to automatically check that the code is standard and passes running tests.
  • It would be a good idea to run tests on multiple different PHP versions.
  • Make sure it works automatically when you commit or pull.
  • : Vis Travis-CIScrutinizer , Circle- CI

12. Write extensive usage documentation

  • A good documentation is essential for an extension pack.
  • At the very least make sure that the library has a detailed README (readme) file.
  • Try hosting your documentation in GitHub Pages .
  • Available reference: Read the Docs .

13. Include a license (License)

  • Including a license agreement is a great way to protect your work, and it's easy to do.
  • See choosealicense.com . Most PHP open source projects use the MIT license .
  • At least include the LICENSE file in the codebase.
  • Also consider including your license agreement in Docblocks .

14. Contributions are welcome

  • If you want everyone to help improve the project, you must ask for your contributions!
  • There is a CONTRIBUTING file with a list of contributors.
  • Use this document to explain project environment requirements, such as a test environment.

For more modern PHP knowledge, go to the Laravel / PHP Knowledge Community

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324873163&siteId=291194637