Skip to content

basherr/PHP-Design-Patterns

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

79 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Design-Patterns

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.

Installation

Please follow the guidelines in order to run this project.

  • Clone the repo using git clone https://github.com/basherr/PHP-Design-Patterns.git
  • Run the following command inside the cloned folder: composer install
  • Make sure all the test cases passes by running composer test command
  • To serve the project, navigate inside public/ 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.

Example Creational Design Patterns

Example Structural Design Patterns

Example Behavior Design Patterns

Contribution-Guides

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:

  • Fork the repository
  • Create a folder inside app/Patterns/{Type e.g Creational, Behavioral or Structural}/{Pattern Name}/{Example Name}/your code
  • Please create a READMe.md and include a UML diagram. Example README.md
  • Add unit tests
  • Create Application.php with a method named render to describe the usage. Example Application.php
  • Add a method in the relevant controller(e.g creational) and add a route in bootstraps/routes.php
  • Please run composer test and make sure all tests are passing
  • Create a PR against the master branch

Please feel free to contribute and create pull requests.

Console Commands

The only console command available for creating tests is:

php .\bootstraps\console_autoload.php MyAwesomeTestName

Discussions

Please create an issue or join Discord for any discussion.

Licenese

All of the codebases are MIT licensed unless otherwise specified.

Releases

No releases published

Packages

No packages published

Languages