fabic974 random (binary) wanderings in the philament empires…

PHP: personal notes

Packages and stuff of general interest

Composer, packages

  • https://getcomposer.org/doc/04-schema.md#repositories
  • https://getcomposer.org/doc/05-repositories.md
  • 2017: Developing composer packages locally, johannespichler.com
  • 2017: How To Make a PHP Package (Mahmoud Zalt, Medium)

    Now I will share some standards I consider while developing new package, that you should consider too:

    • Use Semantic versioning. And try not to introduce backwards compatibility (BC) breaks.
    • Write unit tests. Aim for at least 60% coverage in the first version.
    • Try not introduce dependencies on other packages.
    • Conform to PSR-1 and PSR-2 as the coding style guide. (to apply the conventions on an existing package install PHP Code Sniffer.)
    • Conform to PSR-4 for autoloading.
    • DocBlock your code.
    • Have an extensive README. And keep it updated.
    • Default to the use of the Solar vocabulary for method names.
    • Keep ‘Public’ functions names short (maximum of two words).
    • Compose functionality through dependency injection, rather than through inheritance and base classes.
    • Try to limit the levels of indentation per function (one per function is great).
    • Use Continuous Integration tools, to automatically check coding standards and run tests.
    • Prefer explicit configuration over implicit convention.
    • Exclude non-essential files in .gitattributes.
    • It’s always better to have a ‘Changelog’.
    • Do never ever have duplicated code. Mahmoud Zalt