PHP Classes

PHP Design Patterns with Real World Examples: Implementation of design patterns with examples

Recommend this page to a friend!
     
  Info   Example   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not yet rated by the usersTotal: 96 All time: 9,863 This week: 64Up
Version License PHP version Categories
php-design-patterns 1.0MIT/X Consortium ...5PHP 5, Design Patterns
Description 

Author

This package provides an implementation of design patterns with examples.

It provides classes that implement well-known design patterns with real examples classes to demonstrate how to use each design pattern in practice.

There are two groups of implemented design patterns:

- Creational for creating new class objects

* Abstract Factory
* Builder
* Factory Method
* Pool
* Prototype
* Simple Factory
* Singleton
* Static Factory

- Structural for structuring class objects

* Adapter
* Bridge
* Composite
* Data Mapper
* Decorator
* Dependency Injection
* Facade
* Fluent Interface
* Flyweight

Picture of Niko Peikrishvili
  Performance   Level  
Innovation award
Innovation award
Nominee: 4x

 

Example

<?php
require __DIR__ . '/../../vendor/autoload.php';

$windowsWriterFactory = new \DesignPatterns\Creational\AbstractFactory\WinWriterFactory();
$unixWriterFactory = new \DesignPatterns\Creational\AbstractFactory\UnixWriterFactory();

$csvWriter = $windowsWriterFactory->createCSVWriter();
$csvWriterUnix = $unixWriterFactory->createCSVWriter();

var_dump($csvWriter->write(["A", "V"]));
var_dump($csvWriterUnix->write(["A", "V"]));


  Files folder image Files (94)  
File Role Description
Files folder imagesrc (2 directories)
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file composer.lock Data Auxiliary data

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 100%
Total:96
This week:0
All time:9,863
This week:64Up