Save 37% off PRO during our Black Friday Sale! »

Let's Build a Composer Package (php[tek] 2019 Uncon Track)

Let's Build a Composer Package (php[tek] 2019 Uncon Track)

I put together this talk for the php[tek] 2019 uncon track. In it, I show how to create a PHP package for Composer, complete with all the quality and automation tools many of the popular Composer packages use to maintain their code.

(Download the PDF to get a copy with clickable links to resources.)


Ben Ramsey

May 23, 2019


  1. Ben Ramsey @ramsey Let’s Build a Composer Package

  2. Hi. I’m Ben. ✦ Software Architect at ShootProof ✦ Organizer

    at Nashville PHP ✦ Open source advocate ✦ ramsey/uuid library ✦ Craft beer nerd ✦ @ramsey on Twitter ✦ on Mastodon
  3. Getting started

  4. What problem do you want to solve?

  5. You own the code. How do you want others to

    use it?
  6. None
  7. • MIT license • BSD 2-Clause “Simplified” • Apache License

    2.0 • GNU Library or “Lesser” General Public License (LGPL)
  8. The project


  10. None
  11. Live-coding demo

  12. Maintaining your package

  13. • Add your tests/ directory • Add your docs/ directory

    • Add your phpunit.xml.dist file Add anything that shouldn’t be bundled into the distribution when someone requires your package with Composer. .gitattributes
  14. .gitattributes export-ignore .github/ export-ignore .gitignore export-ignore .travis.yml export-ignore docs/ export-ignore

    phpstan.neon export-ignore phpunit.xml.dist export-ignore tests/ export-ignore
  15. None
  16. None
  17. None
  18. "scripts": { "lint": "parallel-lint src tests", "phpcs": "phpcs src tests

    --standard=psr12 -sp --colors", "phpstan": [ "phpstan analyse src -c phpstan.neon --level max --no-progress", "phpstan analyse tests -c phpstan.neon --level 4 --no-progress" ], "phpunit": "phpunit --verbose --colors=always", "phpunit-ci": "phpunit --coverage-clover build/logs/clover.xml", "phpunit-coverage": "phpunit --coverage-html build/coverage", "test": ["@lint", "@phpcs", "@phpstan", "@phpunit"], "test-ci": ["@lint", "@phpcs", "@phpstan", "@phpunit-ci"] }
  19. None
  20. None
  21. None
  22. Building your community

  23. None
  24. None
  25. None
  26. None
  27. None
  28. None
  29. Enjoy the OSS community

  30. None
  31. LINKS TO RESOURCES 1. Composer: 2. Packagist: 3.

    Open Source Licenses: 4. ramsey/php-library-skeleton: 5. PHP Framework Interoperability Group: 6. PHP Package Development Standards: 7. Semantic Versioning: 8. PHP CodeSniffer: 9. PHPUnit: 10. phpstan: 11. Travis CI: 12. 13. Code of Conduct ‣Contributor Covenant: ‣Citizen Code of Conduct: 14. 15. Open Source Guides: 16. A Beginner’s Guide to Creating a Readme: 17. Use .gitattributes:
  32. @ramsey THANK YOU. ANY QUESTIONS? If you

    want to talk more, feel free to contact me. Let’s Build a Composer Package Copyright © 2019 Ben Ramsey This work is licensed under Creative Commons Attribution- ShareAlike 4.0 International. For uses not covered under this license, please contact the author. Ramsey, Ben. “Let’s Build a Composer Package” php[tek]. Loudermilk Conference Center, Atlanta. 23 May 2019. Conference presentation. This presentation was created using Keynote. The text is set in Chunk Five and Helvetica Neue. The source code is set in Source Code Pro. The iconography is provided by Font Awesome. Unless otherwise noted, all photographs are from Unsplash and are used with permission.