dev-master
9999999-dev https://github.com/pmjones/adrAn alternative to MVC for server-side applications.
MIT
The Requires
The Development Requires
Wallogit.com
2017 © Pedro Peláez
An alternative to MVC for server-side applications.
This example shows an Action Domain Responder user interface subsystem, with the corresponding domain logic and data source elements, for a naive blogging system., (*1)
This is not a running example, in the sense that it cannot be dropped onto a web server and begin operating properly., (*2)
However, there is a full test suite in the tests/ directory. (These are more properly considred integration rather than unit tests, but they will do for the purpose of this example.) Issue composer install followed by ./vendor/bin/phpunit to run the tests., (*3)
There is no authentication, authorization, or session mechanism included. While necessary in a real system, they would increase the complexity of the example and make it more difficult to discern the separation of concerns., (*4)
The Action classes depend on 3rd-party HTTP Request and Response interfaces., (*5)
Each Action picks apart the incoming request to pass individual typehinted Domain method arguments. A differently-constructed Domain might require a different input signature, such as a data transfer object or a catch-all array of all possible request values., (*6)
The base ApplicationService class protects all the "real" service methods behind the magic __call() method. This allows the service to implement some functionality common to all the service methods, such as exception handling, though it does get in the way of IDE auto-completion., (*7)
The BlogService methods return a domain Payload that wraps the domain results and includes a status indicator. This standardizes the domain return signature, makes the BlogResponder work much more readable., (*8)
The domain logic uses a Data Mapper for data source interactions (_BlogMapper_ et al.)., (*9)
Each Responder calls a method corresponding to the domain Payload status to build the HTTP Response., (*10)
The base Responder class depends on a 3rd-party HTTP Request interface and Response object., (*11)
The base BlogResponder class depends on a 3rd-party PHP-based Template View system. The templates are located in resources/templates/blog/., (*12)
An alternative to MVC for server-side applications.
MIT