Hi there,
A few months ago I looked at a Doctrine project where the database design was addressed from the Entity layer with annotations. I liked this approach since it was easy to implement, it was just about adding/updating the entities and then run ./doctrine migrations:diff, which would generate a new migration file according to the differences in the schema.
Data Mapper driven approach
From this point on, I will personally call the methodology above a Data Mapper driven approach if that makes sense -- we take advantage of the fact that entities are defined with annotations in order to design the database programmatically through entities (plain PHP objects), and finally migrations:diff will do the magic.
Active Record driven approach
By the way, let me briefly contrast a Data Mapper driven approach with an Active Record driven one. With Active Record there's no such thing as designing the database programmatically with plain PHP objects because all ORM logic is inherited like this:
class User extends Eloquent {
}
With an Active Record driven approach there isn't any problem about maintaining and keeping the migrations in sync with your custom classes extending Eloquent because the latter don't contain information about columns, data types and so on.
And here are my questions!
Now, let's assume we want to use Doctrine entities along with Phinx migrations.
- How can a Data Mapper driven approach as the described above be implemented?
- Correct me if wrong, but in order for this to be possible we need a
diff tool, but Phinx doesn't come out of the box with any.
- Are there any similar tools available atm?
Many thanks for your help on using Phinx along with Doctrine.
Hi there,
A few months ago I looked at a Doctrine project where the database design was addressed from the Entity layer with annotations. I liked this approach since it was easy to implement, it was just about adding/updating the entities and then run
./doctrine migrations:diff, which would generate a new migration file according to the differences in the schema.Data Mapper driven approach
From this point on, I will personally call the methodology above a Data Mapper driven approach if that makes sense -- we take advantage of the fact that entities are defined with annotations in order to design the database programmatically through entities (plain PHP objects), and finally
migrations:diffwill do the magic.Active Record driven approach
By the way, let me briefly contrast a Data Mapper driven approach with an Active Record driven one. With Active Record there's no such thing as designing the database programmatically with plain PHP objects because all ORM logic is inherited like this:
With an Active Record driven approach there isn't any problem about maintaining and keeping the migrations in sync with your custom classes extending Eloquent because the latter don't contain information about columns, data types and so on.
And here are my questions!
Now, let's assume we want to use Doctrine entities along with Phinx migrations.
difftool, but Phinx doesn't come out of the box with any.Many thanks for your help on using Phinx along with Doctrine.