tags:

views:

65

answers:

2

This question involves a lot of symfony but it should be easy enough for someone to follow who only knows YAML and not symfony.

My symfony models come from a three-step process: First, I create the tables in MySQL. Second, I run a symfony command (symfony doctrine:build-schema) to convert my table structure into a YAML file. Third, I run another symfony command (symfony doctrine:build-model) to convert the YAML file into PHP code.

Here's the problem: there are some tables in the database that I don't want to end up in my symfony code. For example, let's say I have two tables: one called my_table and another called wordpress. The YAML file I end up with might look like this:

MyTable:
  connection: doctrine
  tableName: my_table
Wordpress:
  connection: doctrine
  tableName: wordpress

That's great except the wordpress table has nothing to do with my symfony models. The result is that every single time I make a change to my database and generate this YAML file, I have to manually remove wordpress. It's annoying!

I'd like to be able to create a file called baseConfig.php or something that looks like this:

$config = array(
  'MyTable' => array(
    'connection' => 'doctrine',
    'tableName' => 'my_table',
  ),
  'Wordpress' => array(
    'connection' => 'doctrine',
    'tableName' => 'wordpress',
  ),
);

And then I could have a separate file called config.php or something where I could make modifications to the base config:

unset($config['Wordpress']);

So my question is: is there any way to convert YAML into executable PHP code (as opposed to load YAML INTO PHP code like what sfYaml::load() does) to achieve this sort of thing? Or is there maybe some other way to achieve YAML inheritance? Thanks, Jason

A: 

An alternative approach:

I'm not sure if Symphony will let you do this, but Doctrine supports hand-built schema files. You'll need to keep things in sync manually, but depending on how much you change your tables, this might be managable.

Charles
A: 

Correct answer (as far as I can tell): no.

By the way, here's the plugin I ended up writing: http://jasonswett.net/jsdoctrineschemaoverriderplugin/

Jason Swett