All Projects → RefactoringGuru → Design Patterns Php

RefactoringGuru / Design Patterns Php

Licence: other
Design Pattern Examples in PHP

Projects that are alternatives of or similar to Design Patterns Php

Cloud Design Patterns
Prescriptive Architecture Guidance for Cloud Applications
Stars: ✭ 484 (-29.03%)
Mutual labels:  design-patterns
Sml
SML: C++14 State Machine Library
Stars: ✭ 540 (-20.82%)
Mutual labels:  design-patterns
Coordinator
Implementation of Coordinators app design pattern.
Stars: ✭ 616 (-9.68%)
Mutual labels:  design-patterns
Design Patterns In Kotlin
Design Patterns implemented in Kotlin
Stars: ✭ 5,009 (+634.46%)
Mutual labels:  design-patterns
Javacodeacc
Java代码积累 | 大话设计模式(Java实现版本)、线程协作
Stars: ✭ 537 (-21.26%)
Mutual labels:  design-patterns
Entitas Csharp
Entitas is a super fast Entity Component System (ECS) Framework specifically made for C# and Unity
Stars: ✭ 5,393 (+690.76%)
Mutual labels:  design-patterns
Service Pattern Go
Simple clean Go REST API architecture with dependency injection and mocking example, following SOLID principles.
Stars: ✭ 449 (-34.16%)
Mutual labels:  design-patterns
Iosdesignpatternsamples
This is Github user search demo app which made by many variety of design patterns. You can compare differences in MVC, MVP, MVVM and Flux.
Stars: ✭ 622 (-8.8%)
Mutual labels:  design-patterns
Designpatterns
经典设计模式讲解以及项目实战(Java版)
Stars: ✭ 540 (-20.82%)
Mutual labels:  design-patterns
Rude Java
Java Practice Projects. 以Java语言为主的各种项目实践,涵盖各个业务、各个功能,并附上高质量文章讲解,其中一些甚至可以单开一个仓库。让你再也不用寻找各种框架demo、项目脚手架。
Stars: ✭ 583 (-14.52%)
Mutual labels:  design-patterns
Modular Monolith With Ddd
Full Modular Monolith application with Domain-Driven Design approach.
Stars: ✭ 6,210 (+810.56%)
Mutual labels:  design-patterns
Rust Design Pattern
rust design patterns
Stars: ✭ 529 (-22.43%)
Mutual labels:  design-patterns
Cp Ddd Framework
A lightweight flexible development framework for complex business architecture with full ecosystem!轻量级业务中台开发框架,中台架构的顶层设计和完整解决方案!
Stars: ✭ 566 (-17.01%)
Mutual labels:  design-patterns
Designpatternslibrary
A comprehensive design patterns library implemented in C#, which covers various design patterns from the most commonly used ones to the lesser-known ones. Get familiar with and learn design patterns through moderately realistic examples.
Stars: ✭ 485 (-28.89%)
Mutual labels:  design-patterns
Node.js design patterns second edition code
Code repository for Node.js Design Patterns Second Edition, published by Packt
Stars: ✭ 617 (-9.53%)
Mutual labels:  design-patterns
Restaurant App
Restaurant App 🍔 is a sample open-source e-Commerce 🛒 application for ordering foods, powered by polyglot microservices architecture and cross-platform development including mobile and web
Stars: ✭ 471 (-30.94%)
Mutual labels:  design-patterns
Java design patterns
Java 实现的面向对象设计模式示例, 创建者、抽象工厂、工厂方法、原型、单例、适配器、桥接、组合、装饰器、备忘录、观察者、状态、策略、模板方法、访问者
Stars: ✭ 547 (-19.79%)
Mutual labels:  design-patterns
Rest Api Design Guide
NBB's REST-ish API Design Guide
Stars: ✭ 643 (-5.72%)
Mutual labels:  design-patterns
Clean Ts Api
API em NodeJs usando Typescript, TDD, Clean Architecture, Design Patterns e SOLID principles
Stars: ✭ 619 (-9.24%)
Mutual labels:  design-patterns
Javamtp
《Java多线程编程实战指南(设计模式篇)》源码
Stars: ✭ 575 (-15.69%)
Mutual labels:  design-patterns

Design Patterns in PHP

This repository is part of the Refactoring.Guru project.

It contains PHP examples for all classic GoF design patterns.

Each pattern includes two examples:

  • Conceptual examples show the internal structure of patterns, including detailed comments.

  • RealWorld examples show how patterns can be used in real-world PHP applications.

Requirements

These examples require PHP 7.3 and newer, although they can be easily replicated in older versions of PHP.

This version provides explicit argument and return type declarations, which help to understand better some patterns' features that are not very obvious in dynamically typed language.

All examples can be launched via the command line, using the PHP executable as follows:

php src/Path-to-example/index.php

For the best experience, I recommend working with examples with these IDEs:

Roadmap

  • [ ] Memento: RealLife
  • [ ] State: RealLife

I'm out of decent ideas for real-world usages for these two in PHP apps. If you had used them in your project, feel free to suggest me an idea by posting an Issue.

FAQ

1. What is the Client Code?

Client means client of classes, defined as part of a pattern, which is merely a caller of the given methods or a user of the given classes. In other words, it's the part of your application's code that uses the pattern's classes.

2. I don't understand the roles you're referring to in RealWorld examples.

Take a look at the conceptual example first. There you'll find detailed descriptions of each class in a pattern, its role, and connection to other classes.

Contributor's Guide

I appreciate any help, whether it's a simple fix of a typo or a whole new example. Just make a fork, make your change and submit a pull request.

Here's a style guide which might help you to keep your changes consistent with the rest of the project's code:

  1. All code should match the PSR2 coding style guide

  2. Try to hard-wrap the code at 80th's character. It helps to list the code on the website without scrollbars.

  3. Examples should match following namespace convention: RefactoringGuru\{pattern-name}\{example-name}. For instance:

    <?php
    
    namespace RefactoringGuru\FactoryMethod\Example\Buttons;
    
    class Button {
    ...
    
  4. Aim to put all code within one file. Yes, I realize that it's not how it supposed to be done in production. However, it helps people to understand examples better, since all code fits into one screen.

  5. Comments may or may not have language tags in them, such as this:

    /**
     * EN: All products families have the same varieties (MacOS/Windows).
     *
     * This is a MacOS variant of a button.
     *
     * RU: Все семейства продуктов имеют одни и те же вариации (MacOS/Windows).
     *
     * Это вариант кнопки под MacOS.
     */
    

    This notation helps to keep the code in one place while allowing the website to generates separate versions of examples for all listed languages. Don't be scared and ignore the non-English part of such comments. If you want to change something in a comment like this, just do it. Even if you do it wrong, we'll tell you how to fix it during the Pull Request.

License

This work is licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License.

Creative Commons License

Credits

Authors: Alexander Shvets (@neochief) and Alexey Pyltsyn (@lex111)

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].