A tool to quickly set up the base files of a PHP library package.

Fund package maintenance!

Installs: 186

Dependents: 0

Suggesters: 0

Security: 0

Stars: 58

Watchers: 5

Forks: 8

Open Issues: 0


2.1.4 2020-05-29 18:34 UTC

This package is auto-updated.

Last update: 2020-07-14 17:49:04 UTC


Source Code Latest Version Software License PHP Version Build Status Coverage Status Total Downloads

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 ./src/Skeleton and ./tests/Skeleton 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.

To develop this project, you will need PHP 7.4 or greater and Composer.

After cloning this repository locally, execute the following commands:

cd /path/to/repository
composer install

Now, you are ready to develop!


This project uses Husky and lint-staged to validate all staged changes prior to commit.

Composer Commands

To see all the commands available in the project vnd namespace for Composer, type:

composer list vnd
Composer Command Autocompletion

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 ~/.bash_profile or ~/.zshrc, but it could be different depending on your settings — ensure that your global Composer 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:

composer vnd:[TAB][TAB]

Coding Standards

This project follows a superset of PSR-12 coding standards, enforced by PHP_CodeSniffer. The project PHP_CodeSniffer configuration may be found in phpcs.xml.dist.

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

Static Analysis

This project uses a combination of PHPStan and Psalm to provide static analysis of PHP code. Configurations for these are in phpstan.neon.dist and psalm.xml, respectively.

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

Project Structure

This project uses pds/skeleton as its base folder structure and layout.

Name Description
bin/ Commands and scripts for this project
build/ Cache, logs, reports, etc. for project builds
docs/ Project-specific documentation
resources/ Additional resources for this project
src/ Project library and application source code
tests/ Tests for this project


Why did you include package/tool x and not y?

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!

Copyright and License

The ramsey/php-library-skeleton library is copyright © Ben Ramsey and licensed for use under the MIT License (MIT). Please see LICENSE for more information.