Atlas is a database framework for PHP to help you work with your persistence model, while providing a path to refactor towards a richer domain model as needed.
Atlas helps developers to get started about as easily as they would with Active Record for their persistence model, and provides a path to refactor more easily towards a richer domain model as needed.
A persistence model is a model of your database, not your business domain. More specifically, it is an object-oriented representation of the tables and rows in the database.
Very often, a developer does not have a good, clean domain model to work with, especially early in the project. But there is almost always a database of some sort. Atlas models that database structure so you can use it more easily in PHP code.
A persistence model alone should get your application a long way, especially at the beginning of a project. The Row, Record, and RecordSet objects in Atlas are disconnected from the database, which should make the refactoring and integration process a lot cleaner than with Active Record.
Because Atlas works with your database schema as-it-is, and not as-the-ORM-thinks it-should-be, Atlas is a very good fit for projects with pre-existing databases. (Indeed, Atlas supports both composite primary keys and composite foreign keys -- for some legacy systems, composite keys are absolutely necessary.)
At a high level, Atlas is mini-framework built from a stack of packages, where any "lower" package can be used indepdendently of the the ones "above" it. This means you can pick the exact level of functionality you need right now, and expand to the next greater set of functionality only as is becomes necessary.
The package hierarchy, from bottom to top, looks like this:
Atlas.Pdo provides a database Connection object and a ConnectionLocator. If all you need is convenience wrapper around PDO with fetch and yield methods, this is the package for you.
Atlas.Query is a query builder that wraps an Atlas.Pdo Connection. If you just want to build and perform SQL queries using an object-oriented approach, the Atlas query objects can handle that.
Atlas.Table is a table data gateway implementation that uses Atlas.Query under the hood. If you don't need a full data mapper system and only want to interact with individual tables and their row objects, this will do the trick.
Atlas.Mapper is a data mapper implementation that models the relationships between tables. It allows you to build Record and RecordSet objects whose Row objects map naturally back to Table objects; you can write them back to the database one by one, or persist an entire Record graph back to the database in one go.
Atlas.Orm is the overarching ORM package; it provides a convenience wrapper around the Mapper system, as well as several strategies for transaction management.
Thus, Atlas uses a table data gateway for the underlying table Rows, then composes those Rows into Records and RecordSets via a data mapper; the PDO connection and query system move the data back and forth between PHP and the database.
At the beginning, your domain logic layer (e.g. service layer, application service, interactor, use case, etc.) can manipulate the Atlas persistence objects (Records and RecordSets) directly. You can add simple behavior methods to your Records and RecordSets as well.
Then, as a domain model grows within your application, Mehdi Khalili shows that the refactoring process can move along one of two paths:
Here some further considerations regarding Atlas:
You may not find Atlas suitable for your needs because of the following: