Skip to content

Learn how to implement the most important Design Patterns into your PHP application. This project uses PHP 8. it has examples for each Pattern and an Article explaining how to use them step by step, their advantages, and disadvantages.

License

Notifications You must be signed in to change notification settings

usafhassan/php-design-patterns

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

76 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Logo - PHP 8 Design Patterns

Licence Package Stars

Everyweek a new Pattern + Article on www.medium.com/@anhaia.gabriel and www.medium.com/mestredev

PHP 8 - Design Patterns

This repository was created to show the implementation of a variety of Design Patterns using PHP 8. There is no dependency on a framework, and the examples are the most real as possible based on my own experiences solving real-life problems. Once you learn the design pattern and its concept, it will be effortless to apply it in any PHP project.

Patterns implemented + Article

📖 Pattern ✍️ Article / Post 📚
Template Method LEARN HERE 📖
Strategy LEARN HERE 📖
Adapter LEARN HERE 📖
Facade LEARN HERE 📖
Factory Method Soon

Coming soon

  • Null Object
  • Command
  • Observer
  • Abstract Factory
  • Builder
  • State
  • Decorator
  • Object Pool
  • Prototype
  • Singleton
  • Bridge
  • Composite
  • Fly weight
  • Proxy
  • Chain of Responsability
  • Interpreter
  • Iterator
  • Mediator
  • Money
  • Memento
  • Visitor

Dependencies

  • Docker

Running the project

I strongly recommend that you follow the articles (links above) and run it with Docker. It will be much easier, and you need to install Docker on your computer, independent of the OS you are using. With a few commands, you will run/test all the Design Patterns implemented through the course.

Build de container:

# docker build -t design-patterns . or if you prefer # make build

Run the following command in order to test the design patterns:

# make help and then you will see the list of commands

You just need to run the command with the pattern you want to test, for example:

# make strategy

Additional Information

  • If you take a look at the examples into the blog, or inside the folders /src/{$pattern_name}/ you will notice that all the examples contain a folder called components, those folders are the files/classes used to demonstrate how to use each pattern. Never consider what is in there as part of the pattern! They are not to be followed in your applications.

About

Learn how to implement the most important Design Patterns into your PHP application. This project uses PHP 8. it has examples for each Pattern and an Article explaining how to use them step by step, their advantages, and disadvantages.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • PHP 95.6%
  • Makefile 4.2%
  • Dockerfile 0.2%