The intent of the repository is to inspire developers to understand and use design patterns through various examples. Please consider adding example for any pattern that may help others understand the pattern well.
Please follow the guidelines in order to run this project.
git clone https://github.com/basherr/PHP-Design-Patterns.git
composer install
composer test
commandpublic/
folder and run the command: php -S localhost:8000
Checkout the routes.php for testing any specific pattern example.
If you find some implementation wrong or vague, please create an issue and let us help each other in the path for learning Design Patterns.
Your contribution may have a very good impact on the community thus try sharing every possible example that you can either think of or had experienced in the past.
The repository is not based on any framework but rather inspired by No Framework
The code structure for the repository is as follows:
app
bootstraps
public
stubs
tests
The life cycle of the application is as follows:
public/index.php
serves as the entry point for the entire application which loads boostrap/autoload.php
bootstrap/autoload.php
processes HTTP
request and forwards the route to the relevant Controller method
defined in bootstrap/routes.php
.In order to contribute and add real world example for the related pattern, please follow the guidelines:
app/Patterns/{Type e.g Creational, Behavioral or Structural}/{Pattern Name}/{Example Name}/your code
unit tests
Application.php
with a method named render
to describe the usage. Example Application.phpbootstraps/routes.php
composer test
and make sure all tests are passingPlease feel free to contribute and create pull requests.
The only console command available for creating tests is:
php .bootstrapsconsole_autoload.php MyAwesomeTestName
Please create an issue or join Discord for any discussion.
All of the codebases are MIT licensed unless otherwise specified.