A tool to quickly set up the base files of a PHP library package.
ramsey/php-library-skeleton is a package that may be used to generate a basic PHP library project directory structure, complete with many of the starting files (i.e. README, LICENSE, GitHub issue templates, PHPUnit configuration, etc.) that are commonly found in PHP libraries. You may use the project directory that's created as a starting point for creating your own PHP libraries.
This project adheres to a Contributor Code of Conduct. By participating in this project and its community, you are expected to uphold this code.
Running the command below will create a new repository containing the same files
and structure as this skeleton repository. Afterward, it will run the
Ramsey\Skeleton\Setup::wizard() callable to set up the project, which will
walk you through a series of questions and make changes to files based on your
answers. When complete, it will remove the
directories, leaving everything else in place with an initial commit.
composer create-project ramsey/php-library-skeleton YOUR-PROJECT-NAME
Contributions are welcome! Before contributing to this project, familiarize yourself with CONTRIBUTING.md.
After cloning this repository locally, execute the following commands:
cd /path/to/repository composer install
Now, you are ready to develop!
To see all the commands available in the project
vnd namespace for
composer list vnd
If you'd like to have Composer command auto-completion, you may use bamarni/symfony-console-autocomplete. Install it globally with Composer:
composer global require bamarni/symfony-console-autocomplete
Then, in your shell configuration file — usually
but it could be different depending on your settings — ensure that your global
bin directory is in your
PATH, and evaluate the
symfony-autocomplete command. This will look like this:
export PATH="$(composer config home)/vendor/bin:$PATH" eval "$(symfony-autocomplete)"
Now, you can use the
tab key to auto-complete Composer commands:
lint-staged will run PHP_CodeSniffer before committing. It will attempt to fix any errors it can, and it will reject the commit if there are any un-fixable issues. Many issues can be fixed automatically and will be done so pre-commit.
You may lint the entire codebase using PHP_CodeSniffer with the following commands:
# Lint composer vnd:lint # Lint and autofix composer vnd:lint:fix
lint-staged will run PHPStan and Psalm before committing. The pre-commit hook does not attempt to fix any static analysis errors. Instead, the commit will fail, and you must fix the errors manually.
You may run static analysis manually across the whole codebase with the following command:
# Static analysis composer vnd:analyze
This project uses pds/skeleton as its base folder structure and layout.
|bin/||Commands and scripts for this project|
|build/||Cache, logs, reports, etc. for project builds|
|resources/||Additional resources for this project|
|src/||Project library and application source code|
|tests/||Tests for this project|
I created this project skeleton generator for my own uses, and these are the common files, packages, and tools I use in my PHP libraries. If you like what you see, feel free to use it. If you like some of it but not all, fork it and customize it to fit your needs. I hope you find it helpful!