Skip to content

About database dev methodologies: Using Phinx and Doctrine together #1336

@ghost

Description

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.

  1. How can a Data Mapper driven approach as the described above be implemented?
  2. 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.
  3. Are there any similar tools available atm?

Many thanks for your help on using Phinx along with Doctrine.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions