Skip to content

Project containing real examples of design patterns, contain a guide to help the developers interest in this solutions

License

Notifications You must be signed in to change notification settings

andersoncontreira/php-design-patterns-guide

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

40 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

php-design-patterns-guide (Work in progress...)

Project containing real examples of design patterns, contain a guide to help the developers interest in this solutions

All the information provided has been compiled & adapted from many references, some of them cited at the end of the document. The guidelines are illustrated by my own examples, fruit of my personal experience writing and reviewing unit tests.

Table of contents

  1. Architectural
    1. Data access
    2. Performance
      • [CQRS]
  2. Behavioral
    1. Main patterns
      • [Chain of responsibility]
      • [Command]
      • [Interpreter]
      • [Iterator]
      • [Memento]
      • [Null object]
      • [State]
      • [Strategy]
      • [Template method]
      • [Visitor]
    2. Other patterns
      • [Caching]
      • [Feature toggle]
      • [Mediator]
      • [Pipeline]
      • [Circuit breaker]
  3. Cloud
    • [Health Check Pattern]
    • Claim Check Pattern (Does not apply to this project)
  4. Concurrency
    • [Saga]
  5. Creational
    1. Main patterns
    2. Other patterns
  6. Functional
    • There are no examples yet
  7. Structural
    • [Adapter]
    • [Bridge]
    • [Composite]
    • [Decorator]
    • Facade
    • [Flyweight]
  8. Tests Strategies
    1. Main types
    2. Other types
    3. Main resources concepts

Installing

Downloading the composer.

./script/install.sh

Enabling the extensions

Check the extensions:

php -m

Install the other requires extensions:

sudo apt install php8.1-xml
sudo apt install php8.1-mbstring
sudo apt install php8.1-mysql

Check the extensions:

php -m

Swagger

To configure the swagger the first step is to execute the follow command:

php artisan swagger-lume:publish

Commands details:

  • Run php artisan swagger-lume:publish-config to publish configs (config/swagger-lume.php)
  • Run php artisan swagger-lume:publish-views to publish views (resources/views/vendor/swagger-lume)
  • Run php artisan swagger-lume:publish to publish everything
  • Run php artisan swagger-lume:generate to generate docs

Path changes

Open the generated file config/swagger-lume.php and change the follow lines:

'api' => '/docs',
'docs' => '/openapi.json',
'annotations' => base_path('src/Application'),
'docs_json' => 'openapi.json',

Create the Swagger files

Execute the follow command:

php artisan swagger-lume:generate

Generate the required folder structure for views

Execute the follow command:

./scripts/lumen/create-storage.sh

See the docs page

Access the follow endpoint:

http://localhost:8000/docs

Expected result: Swagger.

Migrations

Creating migrations

php artisan make:migration orders

Running the migrations

Error Solutions

ERROR: Network service-php-v1 declared as external, but could not be found. Please create the network manually using docker network create service-php-v1 and try again.

Solution:

./scripts/docker/create-network.sh

References

About

Project containing real examples of design patterns, contain a guide to help the developers interest in this solutions

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published