Download the PHP package giacomomasseron/php-clean-architecture without Composer

On this page you can find all versions of the php package giacomomasseron/php-clean-architecture. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package php-clean-architecture

Implements Clean Architecture with PHP

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

Implements Clean Architecture as described by Robert C. Martin (Uncle Bob) here:
Clean Architecture

This is an opinionated package that defines levels of the architecture and the dependencies between them.
And uses deptrac to check if the levels are respected.

Installation

You can install the package via composer:

After the installation, you must run the install command to publish the deptrac.yaml, php-clean-architecture.yaml and rector.php config files to your root folder:

Getting started

To check the architecture levels in your project, use the following command:

Commands

All make commands read the php-clean-architecture.yaml config file to know where to put the files created and which namespace they belong to.

Install

The install command publishes needed files your root folder.
If you have already rector installed, you must add these lines of code in your rector.php file:

Check

The check command checks the architecture levels in your project.
You can use it in your CI/CD pipeline to be sure that the architecture levels are respected.

Rector

The rector command adds the needed interfaces to your classes based on namespaces defined in your config files.

Make Entity

To create an Entity, you can use the following command:

Make Repository

To create a Repository, you can use the following command:

Make UseCase

To create a UseCase, you can use the following command:

Make Controller

To create a Controller, you can use the following command:

Make Service

To create a Service, you can use the following command:

In both cases, the created class will be named ThirdyPartyService.

Why Clean Architecture?

Why not?
It is a well-known, well-structured architecture system.

Concepts

Architecture Level

In the Clean Architecture, a level is a layer of the architecture with a specific function, only connected to the upper level.

The rule of thumb of the Clean Architecture is:
An inner circle must never know anything about the circles around it.

UseCase

UseCase is a concept of Use Cases level.

A UseCase is every action your project performs.
Good examples of use cases are:

A use case should be a single, very specific action. It shouldn’t do anything more than its name suggests.

How it works

The package uses deptrac to define the levels and to check the dependencies between them.

Levels

These are the levels defined:

These are the dependencies between the levels:

The Entity level must not depend on any other level.
The Repository level can only depend on Entity or Service levels.
The UseCase level can only depend on Repository or Service levels.
The Controller level can only depend on UseCase levels.

What is the Service level?
The Service level can be used for third-party tools or libraries.

Define a level inside the project

The package comes with these interfaces:

If you want your controller to be part of the Controller level, you need to implement the ControllerInterface.
For example:

UseCases

When you create a UseCase, the class needs to extend the BaseUseCase class, and you need to implement the UseCaseInterface.
For example:

To execute the UseCase, you need to call the run method defined in the BaseUseCase class:

BaseUseCase

The package defines an abstract class for use cases: BaseUseCase.
This class defines variable for the user executing the use case:

You can set the executor using the following example:

If you need to rollback the use case, you can override the rollback method:

Events

The package dispatches two events, one when the use case starts, and one when the use case ends.
It uses the Symfony Event Dispatcher Component.

The events are:

CI/CD

If you want to check the architecture levels in your CI/CD pipeline, you can use the following command:

This command will stop your pipeline if there are architecture violations, based on the deptrac configuration file.

Testing

Frameworks

Laravel

I wrote an article on how to use this package with Laravel

Pulse

Laravel pulse is a package that helps you to monitor the health of your Laravel application.
If you want to monitor use cases execution time, you can:

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.


All versions of php-clean-architecture with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
deptrac/deptrac Version 4.6.1
symfony/yaml Version ^7.4.12
symfony/event-dispatcher Version ^7.3
rector/rector Version ^2.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package giacomomasseron/php-clean-architecture contains the following files

Loading the files please wait ...