An application skeleton for modern PHP projects.
[TOC]
This repository contains an application skeleton following best practices.
- Minimalist project
- Includes frequently used tools such as a Linter, PHPStan, PHPUnit, ClockMock, CodeSniffer and VarDumper.
To use this repository you need:
- Git - The free and open source distributed version control system.
This project was built with Dockerized PHP, a lightweight dockerized environment to build PHP applications.
Just clone the repository into your preferred path:
$ mkdir -p ~/path/to/my-new-project && cd ~/path/to/my-new-project
$ git clone [email protected]:fonil/php-skeleton.git .
.
├── app # Application business logic goes here
├── public # Public folder
│ └── index.php # Application entry point
├── tests # Tests folder
│ └── Unit # Unit Tests folder
├── vendor # Dependencies folder
├── .gitignore # Git ignore file
├── composer.json # Composer dependencies files
├── composer.lock # Composer lock file
├── LICENSE # License document
├── Makefile # Makefile with frequent commands
├── phpcs.xml # PHPCS configuration file
├── phpstan.neon # PHPStan configuration file
├── phpunit.xml # PHPUnit configuration file
└── README.md # This document
Custom commands are added to composer.json
under the scripts
section.
Command | Description |
---|---|
linter |
Runs the linter in parallel mode |
phpcs |
Runs PHP Check Style command following the PSR-12 |
phpcbf |
Runs PHP Code Beautifier and Fixer command following the PSR-12 |
phpstan |
Runs PHPStan with the specs defined at phpstan.neon configuration file |
phpunit |
Runs PHPUnit with the specs defined at phpunit.xml configuration file |
tests |
Runs PHPUnit without code coverage support |
coverage |
Runs PHPUnit with PCOV code coverage support |
Additionally a Makefile is provided with frequently used commands:
~/path/to/my-new-project$ make
╔══════════════════════════════════════════════════════════════════════════════╗
║ ║
║ .: AVAILABLE COMMANDS :. ║
║ ║
╚══════════════════════════════════════════════════════════════════════════════╝
· composer-dump Application: <composer dump-auto>
· composer-install Application: <composer install>
· composer-remove Application: <composer remove>
· composer-require-dev Application: <composer require --dev>
· composer-require Application: <composer require>
· composer-update Application: <composer update>
· linter QA: <composer linter>
· phpcs QA: <composer phpcbs>
· phpcbf QA: <composer phpcbf>
· phpstan QA: <composer phpstan>
· tests QA: <composer tests>
· tests-unit QA: <composer tests-unit>
· coverage QA: <composer coverage>
Note
This file is really useful when you create a container with a project based on this repository and you want to run those commands from outside the container, directly from your host. To do so just copy and paste the included steps on your main Makefile and adjust the constants accordingly.
$ make composer-install
$ make tests [filter="checkInvokeMethod tests/Unit/Providers/FooTest.php"]
$ make tests-unit [filter="checkInvokeMethod tests/Unit/Providers/FooTest.php"]
Coverage report in HTML is generated on a root folder /coverage
Tip
If you want the report is generated on a different path, just update accordingly the composer.json
file under the section scripts
Please review our security policy on how to report security vulnerabilities:
PLEASE DON'T DISCLOSE SECURITY-RELATED ISSUES PUBLICLY
Only the latest major version receives security fixes.
If you discover a security vulnerability within this project, please open an issue here. All security vulnerabilities will be promptly addressed.
The MIT License (MIT). Please see LICENSE file for more information.