constup / php-guidelines

PHP development guidelines with examples.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

PHP Guidelines

php 8 symfony 6 Docker 20 docker—​compose 2

PHP development guidelines repository with examples. This includes, but is not limited to:

  • design patterns

  • SOLID principles

  • OOP principles

All topics are covered with examples. The base for examples is Symfony 6.2 on PHP 8.2. Symfony is used just for convenience. The samples are written in pure PHP and are applicable to any PHP framework or CMS.

Important

This is not yet another repository which participates in the cacophony of those who simply rewrite the theory and add a couple of examples. The purpose of this repository is to go deeper and actually analyze and challenge design patterns, OOP and other concepts/principles, and to provide objectively better alternatives where applicable.

All topics covered here will have a set of examples which you can run immediately - either by CLI (Docker included) or by running implemented PHPUnit tests.

Roadmap and announcements

  • 22.01.2023.:

    • Finished Adapter design pattern

    • Next up: Decorator design pattern

Table of contents

Important

Table of contents is available on a separate page.

How to use this repository

The best way to use this repository is to clone it and open it in an IDE. AsciiDoc documentation and PHP examples are being written in PHPStorm with AsciiDoc plugin. It is recommended to use PHPStorm and AsciiDoc plugin for the best experience.

The documentation uses custom CSS for AsciiDoc rendering. If the documentation text is not rendered correctly in your IDE, make sure that the following configuration is set:

  • File > Settings…​ > Languages & Frameworks > AsciiDoc

    • Preview browser: JCEF Browser

    • Safe mode: UNSAFE

Running the examples

You are free to use this repository as an online resource. However, if you would like to run the provided examples, you can clone this repository and use it on your local machine.

There are two ways of running the examples:

  • On your local machine

    • You need to have PHP 8.2 installed and active. Check it by running php -v.

    • Your local PHP installation must be able to run Symfony 6.2.

    • Run (in root directory of the cloned repository):

composer install
  • Inside a Docker container

    • You need to have Docker installed and running.

    • Run (in root directory of the cloned repository):

docker-compose up --build

All examples in the documentation have both commands (local and docker) included.

Licenses

by nc sa

Author: Nikola D. Stojiljković / constUP

About

PHP development guidelines with examples.

License:Apache License 2.0


Languages

Language:PHP 99.5%Language:Shell 0.3%Language:Dockerfile 0.2%