1

I'm new to Symfony, and I don't even succeed in creating valid models.

I created my project - which use propel - and wrote the following schema.yml:

propel:
  poc:
    id:           ~
    message:      { type: varchar(140), required: true}
    author:       { type: varchar(255), required: true}
    plus:         { type: integer, default: 0}
    minus:        { type: integer, default: 0}
    created_at:   ~

Then I executed the following commands without errors:

$ php symfony propel:build --sql
$ php symfony propel:insert-sql
$ php symfony propel:build --model

But when I try to load fixtures or generate a module, I obtain this error:

$ php symfony propel:data-load             
>> propel    load data from "/home/me/www/poc/data/fixtures"
PHP Fatal error:  Cannot redefine class constant BasePoc::PEER in /home/me/www/poc/lib/model/om/BasePoc.php on line 85

Fatal error: Cannot redefine class constant BasePoc::PEER in /home/me/www/poc/lib/model/om/BasePoc.php on line 85

The class constant PEER is defined twice in the BasePoc.php, but why ?

I googled and recreated the project several times, but I couldn't see my mistake.

1
  • 1
    Sometimes symfony can get a little bit confused with the base classes. Try deleting the whole directory that all of the Base model files live in (be careful not to delete any files that you have edited). These base files get generated any time that you build the model. If that doesn't work, I'd try tracking down where the class constant PEER is defined and check that you haven't accidentally added it to a class. Commented Mar 16, 2011 at 22:32

2 Answers 2

3

If you are using the new sfPropelORMPlugin instead of the sfPropelPlugin bundled with symfony, just read the README file on the plugin, you are missing the last step:

Change the path of the symfony behaviors in the config/propel.ini file of your project:

[ini]
propel.behavior.symfony.class                  = plugins.sfPropelORMPlugin.lib.behavior.SfPropelBehaviorSymfony
propel.behavior.symfony_i18n.class             = plugins.sfPropelORMPlugin.lib.behavior.SfPropelBehaviorI18n
propel.behavior.symfony_i18n_translation.class = plugins.sfPropelORMPlugin.lib.behavior.SfPropelBehaviorI18nTranslation
propel.behavior.symfony_behaviors.class        = plugins.sfPropelORMPlugin.lib.behavior.SfPropelBehaviorSymfonyBehaviors
propel.behavior.symfony_timestampable.class    = plugins.sfPropelORMPlugin.lib.behavior.SfPropelBehaviorTimestampable

Note: a quick "bulk replace" on the file is enough. Note 2: if you are using sfPropel15Plugin, please upgrade to sfPropelORMPlugin.

hope it helps!

Sign up to request clarification or add additional context in comments.

2 Comments

thanks for that, been updating a lot of old propel projects lately and must've missed that!
For those interested in starting new projects with symfony 1.4 + sfPropelORMPlugin, there's a little bash script that aims to automate such process. Check it out here.
-1

It seems propel can not render the entire file. (propel has very bas error reporting, yaml) Make sure to check that there are no tabs in your file and that everything is idented with 2 spaces.

The rest of the seems fine to me. i personally prefer using doctrine, (You would just have to put the created_at parameter in a ActAs behavior)

proc:
  actAs: Timestampable: ~
  columns:
    id:           ~
    message:      { type: varchar(140), required: true}
    author:       { type: varchar(255), required: true}
    plus:         { type: integer, default: 0}
    minus:        { type: integer, default: 0}

2 Comments

He's using propel, you gave a doctrine schema.
I had the error with Propel 1.5.6, using Propel 1.4.x solved the problem (without changing anything in the schema.yml).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.