so-lean/cleanprospecter

P.O.C. of clean architecture (unclebob)

0.0.1 2018-06-24 08:48 UTC

This package is not auto-updated.

Last update: 2025-07-06 09:31:09 UTC


README

PR CI maintanibility coverage

Cleanprospecter

Cleanprospecter is a php 7.2 business prospect application designed according to Robert C. Martin recommendations for clean architecture.

Add cleanprospecter in your project with composer.

 $ composer require so-lean/cleanprospecter

A symfony 4.1 implementation can be found on github here

Progress

Consider that scope as the minimal viable product.

  • As anonymous, I want to login
  • As main app, I want to refresh user
  • As prospector, I want to create organization
  • As prospector, I want to find my own organizations
  • As prospector, I want to get organization
  • As prospector, I want to update organization
  • As prospector, I want to create organization
  • As user, I want to get my account information
  • As user, I want to update my account information
  • As user, I want to remove my organization logo
  • As prospector, I want to create prospect
  • As prospector, I want to find my own prospects
  • As prospector, I want to create phone call event
  • As prospector, I want to create appointment event
  • As prospector, I want to create email event
  • As prospector, I want to create sms event
  • As prospector, I want to find my own prospects

In the future

  • tags
  • auto import events from email box, short message service etc...
  • email marketing campaign

Clean architecture -Business rules as a simple composer package.-

The Clean Architecture

A good explanation is available in this Uncle Bob talk here

A GOOD ARCHITECTURE MAXIMIZES THE NUMBER OF DECISIONS NOT MADE

  • UNCLE BOB

Terminological differences

In order to clarify some uncle bob concepts

  • Interactors becomes use cases and are locatated in src/UseCase/UseCaseName and take its name from it : ex FindMyOwnOrganizations
  • Request an response are data transfer object and are located at the same place : ex FindMyOwnOrganizationsRequest, FindMyOwnOrganizationsResponse
  • Presenter interface (Dependency inversion) too : ex FindMyOwnOrganizationsPresenter
  • Gateways is not only database abstraction, entity gateway are located in src/Gateway/Entity

How to implement cleanprospecter

Clean architecture use dependency injection to build uses cases.

1 You need to implement all Gateways in your main application

  • Build use cases in the IOC
  • Register it in the facade.
    // in IOC
    
    //OrganizationGatewayImpl implements OrganizationGateway interface
    $organizationGateway = new OrganizationGatewayImpl();
 
    $useCase = new GetOrganizationImpl($organizationGateway);
    
    //Create facade and register use case
    $facade = new UseCasesFacade();
    $facade->addUseCase($useCase);
    // in controller (or somewhere else)
    $request = new GetOrganizationRequest(7);
    
    //presenter implements GetOrganizationPresenter
    $presenter = new GetOrganizationPresenterImpl();
    
    //all use case is accessible by their name 
    $facade->getOrganization($request, $presenter);

A use case can say what it does

   //...
   
   $useCase = new GetOrganizationImpl($organizationGateway);
   
   echo $useCase;
   
   //Display : "As prospector, I want to get organization"

Developer tools

prerequisites

  • docker
  • docker-compose

All common command lines are accessible by the Makefile. Make create a docker image based on official php alpine docker image (php 7.2.3) with xdebug and composer installed globally.

    $ make

Commands

make command

Command comments
build-env Build the docker env file tagged prospecter-run
composer install vendors
composer-update update vendors
test execute tests suite
testdox execute tests and write agile documentation in text format
test-coverage execute tests and generate report in html format
cs code sniffer
cs-fix fix automatically code sniffer errors