model classes destination #119

Closed
Elexy opened this Issue Mar 6, 2012 · 7 comments

Projects

None yet

2 participants

@Elexy

I ran into an issue using the FOSUserBundle: FriendsOfSymfony/FOSUserBundle#560 (comment)

The guys there said it has to do with the way the propelbundle generates it's classes.

To recap:
Many people deploy using git these days. Because the model classes are generated inside the bundles inside 'vendor' they cannot be committed (read only submodules). Thus there is no way to deploy using git as is required by services like Cloudcontrol, phpFog etc.

I ended up just downloading a zip and copying the files in 'vendor/' so I could commit in my repo.

Is this desired behavior?

@havvg
Propel member

I'm on cloudControl, too. That was the main reason, why I added schema inheritance support in the first place, to be able to alter that exact database attribute (by now there are way more changes to the user model).

Imho, it's solved and it's handled in a nice way.
You can alter the database package attribute as I mentioned. Then you got your generated files in place and committed into git.

@Elexy

Ok, I'll try again.

@Elexy

It works mostly, but I still have a little snag:

Fatal error: Cannot redeclare class FOS\UserBundle\Propel\User in .../src/FOS/UserBundle/Propel/User.php on line 22

The FOSUserbundle has these classes also.

@havvg
Propel member

My guess would be, you got your autoloader configured the wrong way. Make sure the src/.. directory is listed before the vendor/.. one related to the FOS namespace.

You also should apply the changes from the bundle to the generated classes, like implemented interfaces (e.g. Group).

@Elexy

Thanks, I modified the autoload.php like you said
My autoloader now has this:

'Propel'           => __DIR__.'/../vendor/bundles',
'FOS'              => array(__DIR__.'/../src/', __DIR__.'/../vendor/bundles'),```

The error is still there.
The strange thing is that I only see the error when I run my unit test WITH code coverage:
phpunit -c app --log-junit "../reports/testresult.xml" --coverage-clover "../reports/coverage.xml

Just navigating the website gives no error....
@havvg
Propel member

No, that's not what I meant. I mean something like:

<?php

use Symfony\Component\ClassLoader\UniversalClassLoader;

$loader = new UniversalClassLoader();
$loader->registerNamespaces(array(
    'FOS\UserBundle\Propel' => __DIR__.'/../src/',
    'FOS' => __DIR__.'/../vendor/bundles',
));
@Elexy

EDIT: Just hit enter when you we're typing I guess. Strange that it works with how I setup the autoload. However I changed it to what you said, that makes more sense. Thanks again

I found my mistake!

I had made a FOSUserBundle, didn't read it right. I changed it to:

namespace FOS\UserBundle;

use Symfony\Component\HttpKernel\Bundle\Bundle;
use FOS\UserBundle\FOSUserBundle;

class UserBundle extends FOSUserBundle
{
}

Now It's all working fine

Just one thing: putting the schema.yml in my bundle didn't override the one from the FOS bundle. I put it in app/Resources like it states in the FOS manual and then it overrides correctly and I get my classes in my 'UserBundle'.

@Elexy Elexy closed this Mar 6, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment