[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-8112":3},{"id":4,"name":5,"fullName":6,"owner":5,"repo":5,"description":7,"homepage":8,"htmlUrl":9,"language":10,"languages":9,"totalLinesOfCode":9,"stars":11,"forks":12,"watchers":13,"openIssues":14,"contributorsCount":14,"subscribersCount":14,"size":14,"stars1d":14,"stars7d":14,"stars30d":15,"stars90d":14,"forks30d":14,"starsTrendScore":14,"compositeScore":16,"rankGlobal":9,"rankLanguage":9,"license":17,"archived":18,"fork":18,"defaultBranch":19,"hasWiki":18,"hasPages":18,"topics":20,"createdAt":9,"pushedAt":9,"updatedAt":30,"readmeContent":31,"aiSummary":32,"trendingCount":14,"starSnapshotCount":14,"syncStatus":33,"lastSyncTime":34,"discoverSource":35},8112,"DesignPatternsPHP","DesignPatternsPHP\u002FDesignPatternsPHP","Sample code for several design patterns in PHP 8.x","",null,"PHP",22188,4523,1183,0,6,70.6,"MIT License",false,"main",[21,22,23,24,25,26,27,28,29],"code-examples","design-pattern","design-patterns","designpatternsphp","modern-php","oop","php","php8","phpunit","2026-06-12 04:00:37","# DesignPatternsPHP\n\n[![Build Status](https:\u002F\u002Fgithub.com\u002FDesignPatternsPHP\u002FDesignPatternsPHP\u002Fworkflows\u002FCI\u002Fbadge.svg?branch=main)](https:\u002F\u002Fgithub.com\u002FDesignPatternsPHP\u002FDesignPatternsPHP\u002Factions)\n[![Documentation Status](https:\u002F\u002Freadthedocs.org\u002Fprojects\u002Fdesignpatternsphp\u002Fbadge\u002F?version=latest)](https:\u002F\u002Fdesignpatternsphp.readthedocs.io\u002F?badge=latest)\n\n[Read the Docs of DesignPatternsPHP](http:\u002F\u002Fdesignpatternsphp.readthedocs.org)\nor [Download as PDF\u002FEpub](https:\u002F\u002Freadthedocs.org\u002Fprojects\u002Fdesignpatternsphp\u002Fdownloads\u002F)\n\nThis is a collection of known design patterns and some sample codes on how to implement them in PHP. Every pattern has a small list of examples.\n\nI think the problem with patterns is that often people do know them but don't know when to apply which. Remember that each pattern has its own trade-offs. And you need to pay attention more to why you're choosing a certain pattern than to how to implement it.\n\n## Installation\nYou should look at and run the tests to see what happens in the example.\nTo do this, you should install dependencies with `Composer` first:\n\n```bash\n$ composer install\n```\n\nRead more about how to install and use `Composer` on your local machine [here](https:\u002F\u002Fgetcomposer.org\u002Fdoc\u002F00-intro.md#installation-linux-unix-osx).\n\nTo run the tests use `phpunit`:\n\n```bash\n$ .\u002Fvendor\u002Fbin\u002Fphpunit\n```\n\n## Using Docker (optional)\n\nYou can optionally build and browse the documentation using [Docker for Mac, Windows or Linux](https:\u002F\u002Fdocs.docker.com\u002Fcompose\u002Finstall\u002F).\n\nJust run:\n\n```bash\n$ docker-compose up --build\n```\n\nGo to [http:\u002F\u002Flocalhost:8080\u002F](http:\u002F\u002Flocalhost:8080\u002F) to read the generated documentation.\n\nIf you want to localize your documentation you can pass the locale as an argument to the docker build:\n\n```bash\n$ docker-compose build --build-arg language=de\n$ docker-compose up\n```\n\n## Patterns\n\nThe patterns can be structured in roughly three different categories. Please click on the [:notebook:](http:\u002F\u002Fen.wikipedia.org\u002Fwiki\u002FSoftware_design_pattern) for a full explanation of the pattern on Wikipedia.\n\n### [Creational](Creational)\n\n* [AbstractFactory](Creational\u002FAbstractFactory) [:notebook:](http:\u002F\u002Fen.wikipedia.org\u002Fwiki\u002FAbstract_factory_pattern)\n* [Builder](Creational\u002FBuilder) [:notebook:](http:\u002F\u002Fen.wikipedia.org\u002Fwiki\u002FBuilder_pattern)\n* [FactoryMethod](Creational\u002FFactoryMethod) [:notebook:](http:\u002F\u002Fen.wikipedia.org\u002Fwiki\u002FFactory_method_pattern)\n* [Pool](Creational\u002FPool) [:notebook:](http:\u002F\u002Fen.wikipedia.org\u002Fwiki\u002FObject_pool_pattern)\n* [Prototype](Creational\u002FPrototype) [:notebook:](http:\u002F\u002Fen.wikipedia.org\u002Fwiki\u002FPrototype_pattern)\n* [SimpleFactory](Creational\u002FSimpleFactory)\n* [Singleton](Creational\u002FSingleton) [:notebook:](http:\u002F\u002Fen.wikipedia.org\u002Fwiki\u002FSingleton_pattern)\n* [StaticFactory](Creational\u002FStaticFactory)\n\n### [Structural](Structural)\n\n* [Adapter](Structural\u002FAdapter) [:notebook:](http:\u002F\u002Fen.wikipedia.org\u002Fwiki\u002FAdapter_pattern)\n* [Bridge](Structural\u002FBridge) [:notebook:](http:\u002F\u002Fen.wikipedia.org\u002Fwiki\u002FBridge_pattern)\n* [Composite](Structural\u002FComposite) [:notebook:](http:\u002F\u002Fen.wikipedia.org\u002Fwiki\u002FComposite_pattern)\n* [DataMapper](Structural\u002FDataMapper) [:notebook:](http:\u002F\u002Fen.wikipedia.org\u002Fwiki\u002FData_mapper_pattern)\n* [Decorator](Structural\u002FDecorator) [:notebook:](http:\u002F\u002Fen.wikipedia.org\u002Fwiki\u002FDecorator_pattern)\n* [DependencyInjection](Structural\u002FDependencyInjection) [:notebook:](http:\u002F\u002Fen.wikipedia.org\u002Fwiki\u002FDependency_injection)\n* [Facade](Structural\u002FFacade) [:notebook:](http:\u002F\u002Fen.wikipedia.org\u002Fwiki\u002FFacade_pattern)\n* [FluentInterface](Structural\u002FFluentInterface) [:notebook:](http:\u002F\u002Fen.wikipedia.org\u002Fwiki\u002FFluent_interface)\n* [Flyweight](Structural\u002FFlyweight) [:notebook:](https:\u002F\u002Fen.wikipedia.org\u002Fwiki\u002FFlyweight_pattern)\n* [Proxy](Structural\u002FProxy) [:notebook:](http:\u002F\u002Fen.wikipedia.org\u002Fwiki\u002FProxy_pattern)\n* [Registry](Structural\u002FRegistry) [:notebook:](http:\u002F\u002Fen.wikipedia.org\u002Fwiki\u002FService_locator_pattern)\n\n### [Behavioral](Behavioral)\n\n* [ChainOfResponsibilities](Behavioral\u002FChainOfResponsibilities) [:notebook:](http:\u002F\u002Fen.wikipedia.org\u002Fwiki\u002FChain_of_responsibility_pattern)\n* [Command](Behavioral\u002FCommand) [:notebook:](http:\u002F\u002Fen.wikipedia.org\u002Fwiki\u002FCommand_pattern)\n* [Interpreter](Behavioral\u002FInterpreter) [:notebook:](https:\u002F\u002Fen.wikipedia.org\u002Fwiki\u002FInterpreter_pattern)  \n* [Iterator](Behavioral\u002FIterator) [:notebook:](http:\u002F\u002Fen.wikipedia.org\u002Fwiki\u002FIterator_pattern)\n* [Mediator](Behavioral\u002FMediator) [:notebook:](http:\u002F\u002Fen.wikipedia.org\u002Fwiki\u002FMediator_pattern)\n* [Memento](Behavioral\u002FMemento) [:notebook:](http:\u002F\u002Fen.wikipedia.org\u002Fwiki\u002FMemento_pattern)\n* [NullObject](Behavioral\u002FNullObject) [:notebook:](http:\u002F\u002Fen.wikipedia.org\u002Fwiki\u002FNull_Object_pattern)\n* [Observer](Behavioral\u002FObserver) [:notebook:](http:\u002F\u002Fen.wikipedia.org\u002Fwiki\u002FObserver_pattern)\n* [Specification](Behavioral\u002FSpecification) [:notebook:](http:\u002F\u002Fen.wikipedia.org\u002Fwiki\u002FSpecification_pattern)\n* [State](Behavioral\u002FState) [:notebook:](http:\u002F\u002Fen.wikipedia.org\u002Fwiki\u002FState_pattern)\n* [Strategy](Behavioral\u002FStrategy) [:notebook:](http:\u002F\u002Fen.wikipedia.org\u002Fwiki\u002FStrategy_pattern)\n* [TemplateMethod](Behavioral\u002FTemplateMethod) [:notebook:](http:\u002F\u002Fen.wikipedia.org\u002Fwiki\u002FTemplate_method_pattern)\n* [Visitor](Behavioral\u002FVisitor) [:notebook:](http:\u002F\u002Fen.wikipedia.org\u002Fwiki\u002FVisitor_pattern)\n\n### [More](More)\n\n* [EAV](More\u002FEAV) [:notebook:](https:\u002F\u002Fen.wikipedia.org\u002Fwiki\u002FEntity%E2%80%93attribute%E2%80%93value_model)\n* [Repository](More\u002FRepository)\n* [ServiceLocator](More\u002FServiceLocator) [:notebook:](http:\u002F\u002Fen.wikipedia.org\u002Fwiki\u002FService_locator_pattern)\n\n\n## Localization & Supported Languages\n  The following languages are currently available. However not all are actively supported. \n  The current policy is: if there are no native-speaking maintainers we cannot support the given language. \n  We will still leave the translation as is but we will not update it as the base (English) changes.\n  The table below list which language version is considered \"supported\" and who maintains it.\n\n  We're sorry. We would love to maintain them but it is not possible for us. So if you would like to take care\n  of one or more languages - contact us.\n\n| Code  | Language  |    Documentation   |  Actively Supported?  | Maintainer |\n| ------------------|-------------|------|-----------------------|------------|\n| en    | English   | [Docs :notebook:](https:\u002F\u002Fdesignpatternsphp.readthedocs.io\u002Fen\u002Flatest\u002F) | YES | -- |\n| de    | German    | [Docs :notebook:](https:\u002F\u002Fdesignpatternsphp.readthedocs.io\u002Fde\u002Flatest\u002F) | NO | - |\n| ca    | Catalan   | [Docs :notebook:](https:\u002F\u002Fdesignpatternsphp.readthedocs.io\u002Fca\u002Flatest\u002F) | NO | - |\n| zh_CN | Chinese   | [Docs :notebook:](https:\u002F\u002Fdesignpatternsphp.readthedocs.io\u002Fzh_CN\u002Flatest\u002F) | NO | - |\n| nl    | Dutch     | [Docs :notebook:](https:\u002F\u002Fdesignpatternsphp.readthedocs.io\u002Fnl\u002Flatest\u002F) | NO | - |\n| bg    | Bulgarian | [Docs :notebook:](https:\u002F\u002Fdesignpatternsphp.readthedocs.io\u002Fbg\u002Flatest\u002F) | YES | -- |\n| ja    | Japanese  | [Docs :notebook:](https:\u002F\u002Fdesignpatternsphp.readthedocs.io\u002Fja\u002Flatest\u002F) | NO | - |\n| pl    | Polish    | [Docs :notebook:](https:\u002F\u002Fdesignpatternsphp.readthedocs.io\u002Fpl\u002Flatest\u002F) | NO | - |\n| pt_BR | Portuguese-Brazil | [Docs :notebook:](https:\u002F\u002Fdesignpatternsphp.readthedocs.io\u002Fpt_BR\u002Flatest\u002F) | NO | - |\n| ru    | Russian   | [Docs :notebook:](https:\u002F\u002Fdesignpatternsphp.readthedocs.io\u002Fru\u002Flatest\u002F) | NO | - |\n| es    | Spanish   | [Docs :notebook:](https:\u002F\u002Fdesignpatternsphp.readthedocs.io\u002Fes\u002Flatest\u002F) | NO | - |\n| es_MX | Spanish-Mexican | [Docs :notebook:](https:\u002F\u002Fdesignpatternsphp.readthedocs.io\u002Fes_MX\u002Flatest\u002F) | NO | - |\n| tr    | Turkish   | [Docs :notebook:](https:\u002F\u002Fdesignpatternsphp.readthedocs.io\u002Ftr\u002Flatest\u002F) | NO | - |\n| fr    | French | [Docs :notebook:](https:\u002F\u002Fdesignpatternsphp.readthedocs.io\u002Ffr\u002Flatest\u002F) | NO | - |\n| it    | Italian | [Docs :notebook:](https:\u002F\u002Fdesignpatternsphp.readthedocs.io\u002Fit\u002Flatest\u002F) | NO | - |\n| uk    | Ukrainian | [Docs :notebook:](https:\u002F\u002Fdesignpatternsphp.readthedocs.io\u002Fuk\u002Flatest\u002F)    | NO | - |\n","DesignPatternsPHP 是一个提供多种设计模式 PHP 8.x 实现示例的项目。它涵盖了创建型、结构型和行为型等三类主要的设计模式，每种模式都附有具体的代码实例，帮助开发者更好地理解和应用这些模式。该项目使用现代 PHP 特性编写，并通过 PHPUnit 进行了全面测试，确保了代码质量和兼容性。适合于希望在 PHP 项目中引入良好设计实践的开发者学习参考，或是作为教学资源用于软件设计模式的教学与培训。",2,"2026-06-11 03:16:09","top_language"]