This is a starting point for applications with complex business logic. It is a PHP MVC skeleton with a Domain (Domain Model), Data Mapper and Service Layer. It uses Zend Framework 2 however may be ported to other frameworks quite easily. You are welcome to use it as the foundation for your next application.
The Starter Application includes:
A means of organising business logic (the Domain),
A flexible mechanism for database interaction (the Data Mapper),
A clean, clear API for client code (the Service Layer),
Factories for creating complex Domain objects,
An identity map to avoid duplicating Domain objects in memory,
Custom collections for Domain objects, and
Proxies for efficient loading of individual Domain objects and collections.
The Starter Application is aimed at intermediate-level developers who have ZF2 experience and are addressing problems which are too complex for transaction scripts or table modules. I am planning to maintain and improve both the code and this discussion, so please contribute any improvements by forking the code on github.
The Starter Application consists of two modules: Core and Mapper. All codes lives in Core, with the exception of the Data Mapper which is declared in Core and implemented in Mapper.
The presentation layer of the Starter Application (i.e. views and controllers), is straightforward. All the interesting work takes place in the model which includes the Domain, Data Mapper and Service Layer.
To start building your own application you can:
Install the Starter Application using the method described here
Read each of the topics that follow, exploring the installed code as you go