Common Elements of a PHP Package
- Composer.json: This file defines the package, including its name, version, dependencies, autoloading information, and other metadata.
- Source Code: The actual PHP files containing the classes, functions, or any other code provided by the package. Typically located in the
srcdirectory. - Autoloading: Using PSR-4 or PSR-0 standards to ensure that classes are autoloaded properly without requiring manual includes.
- Tests: Unit tests, often written using PHPUnit, to ensure the package works as expected.
- Documentation: README files and other documentation to help users understand how to use the package.
Basic filestructure of a PHP package
my-package/
├── src/
│ └── MyPackage.php
├── tests/
│ └── MyPackageTest.php
├── .gitignore
├── composer.json
└── README.md