The document provides guidance on creating and maintaining high-quality PHP packages. It discusses defining quality standards, project structure, testing, documentation, releasing packages, and ongoing maintenance. Key aspects include using semantic versioning, writing automated tests, generating documentation, following best practices for code quality, and being responsive to issues and pull requests. The goal is to create packages that are easily installed, well-maintained, and meet community standards.
2. @colinodell
@colinodell
PHP League Leadership Team
Maintainer of popular packages:
league/commonmark
league/html-to-markdown
colinodell/json5
Colin O'Dell
Principal Engineer
at Unleashed Technologies
6. @colinodell
PHP-FIG, PSR-0, & Composer
2009: Framework Interoperability Group adopts PSR-0 autoloading
standard
2011: Composer development begins
2012: Composer released with PSR-0 support
23. @colinodell
Source Code
• Minimal dependencies; wide
constraint ranges
• Make framework agnostic
• Service providers for specific
frameworks okay
• Provide interfaces
• Consistent coding style (PSR-2?)
• Use community standards (PSRs)
• Follow best practices and design
principles
29. @colinodell
Automated Tests
• Not just unit tests:
• Functional tests
• Integration tests
• Acceptance tests
• Other good test frameworks:
• Phpspec
• Behat
• Codeception
• Don’t forget static analysis!
30. @colinodell
Static Analysis
Automated analysis of source code without executing the application
Checks for:
• Missing or incorrect type hints (param/return types and docblocks)
• Type errors
• Existence of methods and properties
• Unnecessary/useless code
• Correct argument types passed to (s)printf()
• etc.
Supports generics too!
49. @colinodell
Documentation:
RTFM
• Advanced usage or configuration
• Additional code samples
• Other functionality
Where to host?
• GitHub Pages
• Jekyll
• MkDocs
• Other static site generator
• readthedocs.org
• Your own hosting
50. @colinodell
Archive Settings
Package consumers (probably) don’t want:
• Tests
• Dev dependencies
• Issue / PR templates
• GitHub Actions configuration
• Your .gitignore development settings
• Images used in README
58. @colinodell
Semantic Versioning – semver.org
2 . 4 . 5
Major . Minor . Patch
Incompatible
Changes
Backwards-
Compatible;
New Features
Bug Fixes
59. @colinodell
2 . 4 . 6
2 . 4 . 5
Major . Minor . Patch
Incompatible
Changes
Backwards-
Compatible;
New Features
Bug Fixes
60. @colinodell
2 . 5 . 0
2 . 4 . 5
Major . Minor . Patch
Incompatible
Changes
Backwards-
Compatible;
New Features
Bug Fixes
61. @colinodell
3 . 0 . 0
2 . 4 . 5
Major . Minor . Patch
Incompatible
Changes
Backwards-
Compatible;
New Features
Bug Fixes
62. @colinodell
Semantic Versioning – semver.org
0 . x . y
Major . Minor . Patch
Any 0.x.y release may break backwards compatibility!
My recommendation: treat X.Y as major.minor
65. @colinodell
Upgrading Notes
• Documentation on upgrading between major versions
• Describe BC breaks
• Provide instructions for users to update their code
UPGRADE.md file or in site docs
79. @colinodell
CODE_OF_CONDUCT.md
• Expresses values and rules that contributors should adhere to
• Promotes inclusion and contributions
• Defines unacceptable behavior and enforcement
• https://www.contributor-covenant.org/