Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Build maintainable PHP Packages

Build maintainable PHP Packages

× PHP Composer
× Conventions, folder structure, file and variable naming
× Documentation
× License
× Code Quality
× Continuous Integration
× Code analysis & Security
× Contributors, Versioning and release

Mohamed Meabed

January 24, 2019
Tweet

More Decks by Mohamed Meabed

Other Decks in Technology

Transcript

  1. @meabed Agenda 5 × Why Packages? × Practices: × PHP

    Composer × Conventions, folder structure, file and variable naming × Documentation × License × Code Quality × Continuous Integration × Code analysis & Security × Contributors, Versioning and release
  2. @meabed Why Packages 6 Build for scale × Reusability ×

    Modularity × Isolation × Easier maintenance and upgrades
  3. @meabed PHP Composer 8 × Add all fields with meaningful

    content × Set the correct PHP version × Differentiate require and require-dev, autoload × Use scripts to simplify commands × Customer composer flags with config • https://www.getcomposercat.com/ • https://composer.json.jolicode.com/
  4. @meabed Convention, structure, file and variable naming 9 × PSR

    4 × Consistent folder structure × src, tests, build, vendor, bin ... × UpperCamelCase, lowerCamelCase, snake_case, kebab-case, … × Clear contextual naming convention • https://en.wikipedia.org/wiki/PHP_Standard_Recommendation • https://en.wikipedia.org/wiki/Naming_convention_(programming)
  5. @meabed Documentation 10 Best documentation is self-documentation × Well formatted

    README × Clear “usage” with code example • https://github.com/matiassingers/awesome-readme
  6. @meabed CI, Code Quality 12 × Continuous inspection “Scrutinizer CI”

    × Test code coverage “codecov.io” × Continuous Integration “TravisCI” × Building with nightly builds
  7. @meabed Code Analysis 14 × Vulnerability analysis × Security scan

    × Coding styles • https://github.com/exakat/php-static-analysis-tools • https://github.com/phpstan/phpstan • https://snyk.io/
  8. @meabed Contributors, Release 15 × Contribution guide × Issues and

    PR Templates × Maintain clear changelog × Consistent versioning scheme × Frequent or scheduled release cycle • https://keepachangelog.com/en/1.0.0/ • https://semver.org/
  9. @meabed Build together × Attend the meetups × Follow us

    on Twitter @meiohq × Subscribe to the newsletter × Speak and present × Share and Invite × Give feedback and suggestions × And everything else :) 16
  10. @meabed Thanks! Any questions? You can find me at 17

    @meabed https://github.com/meabed https://meabed.com