Fosuserbundle: PHP Fatal error: Class 'FOS\UserBundle\Propel\om\BaseUser' not found

Created on 15 Sep 2016  ·  41Comments  ·  Source: FriendsOfSymfony/FOSUserBundle

After symfony command cache:warmup there is error:

PHP Fatal error: Class 'FOS\UserBundle\Propel\om\BaseUser' not found in ..../vendor/friendsofsymfony/user-bundle/Propel/User.php on line 18
** [out :: 138.201.93.46] [2016-09-15 16:52:02] php.CRITICAL: Fatal Error: Class 'FOS\UserBundle\Propel\om\BaseUser' not found {"exception":"object"}

Symfony version 3.2.x-dev.

Most helpful comment

👍 for dropping propel. We can (re)add support later, if someone needs this.

All 41 comments

Can you please leave a little more information...

Which bundle versions are you using?

dev-master, latest release of FOSUserBundle.
If you will look at file https://github.com/FriendsOfSymfony/FOSUserBundle/blob/master/Propel/User.php, there is no namespace FOS\UserBundle\Propel\om in the bundle code

that's weird that this file has never been in this bundle (at least till last year). Is there another bundle that provides this file in the same namespace?

The full Propel folder seems to be broken, the whole folder/namespace FOS\UserBundle\Propel\om is not available.

Ok, I think this seems to be an issue with the auto_mapping, this looks familiar: https://github.com/FriendsOfSymfony/FOSUserBundle/issues/1646.

The classes in this namespace will be generated if I'm correct?

Looks like a symfony problem to me, after I downgraded to symfony commit #1f9f87b177126fa67739ab109f8f59659f0dab9a (master, 3.2-dev) it's working again. Something broke/changed after this commit

Event if I remove propel files from autoloader by adding "exclude-from-classmap" option into composer.json, symfony still is trying to autoload propel files.
Yes, seems to be symfony problem on dev-master branch.

Hello, have exactly same issue as BowlingX has, after downgrade to #1f9f87b177126fa67739ab109f8f59659f0dab9a this error "'FOS\UserBundle\Propel\om\BaseUser' not found " not arise

The question is what is trying to access these classes. If you don't use Propel, the bundle should never access these classes. And if you use Propel, the base classes will be generated by Propel.

I do not use Propel, my FOSUserBundle config is:

fos_user:
    db_driver: orm 
    firewall_name: main
    user_class: UserBundle\Entity\BaseUser
    service:
        mailer: fos_user.mailer.noop

friendsofsymfony/user-bundle dev-master 7abb0ff Symfony FOSUserBundle
symfony/symfony dev-master e9e29fa The Symfony PHP framework

cache:clear --env=prod -vvv

 // Clearing the cache for the prod environment with debug false                                                        

 // Warming up cache...                                                                                                 

PHP Fatal error:  Class 'FOS\UserBundle\Propel\om\BaseUser' not found in /var/www/autodial/vendor/friendsofsymfony/user-bundle/Propel/User.php on line 18


  [Symfony\Component\Debug\Exception\ClassNotFoundException]                     
  Attempted to load class "BaseUser" from namespace "FOS\UserBundle\Propel\om".  
  Did you forget a "use" statement for another namespace?                        


Exception trace:
 () at /var/www/autodial/vendor/friendsofsymfony/user-bundle/Propel/User.php:18

Please provide the full stack trace, allowing to know what required the Propel user class

this is full stack but I not found the source what use this class
out.txt

I just encountered the problem and I think the modifications on the composer autoload definition (specifically the autoload-dev section) is to blame. - Maybe in combination with changes in the class scanning in sf.

Here's the comparison between the current the working and the failing commit: https://github.com/FriendsOfSymfony/FOSUserBundle/compare/662463f...FriendsOfSymfony:7abb0ff#diff-b5d0ee8c97c7abd7e3fa29b9a27d1780R54

what you gave me is an extract of your logs, not the stack trace. Run the cache warmup command in verbose mode to get a stack trace.

Btw, autoload-dev of FOSUserBundle has strictly no impact in your own project (composer will NEVER read this setting for packages installed as a dependency)

That's exactly my thought - still: rolling back just these changes fixes the error.

@stof, Did you mean this ?:

bin/console cache:warmup --verbose

 // Warming up the cache for the dev environment with debug true                                                        

PHP Fatal error:  Class 'FOS\UserBundle\Propel\om\BaseUser' not found in /var/www/autodial/vendor/friendsofsymfony/user-bundle/Propel/User.php on line 18
[2016-09-27 09:46:04] php.CRITICAL: Fatal Error: Class 'FOS\UserBundle\Propel\om\BaseUser' not found {"exception":"[object] (Symfony\\Component\\Debug\\Exception\\FatalErrorException(code: 0): Error: Class 'FOS\\UserBundle\\Propel\\om\\BaseUser' not found at /var/www/autodial/vendor/friendsofsymfony/user-bundle/Propel/User.php:18)"} 


  [Symfony\Component\Debug\Exception\ClassNotFoundException]                     
  Attempted to load class "BaseUser" from namespace "FOS\UserBundle\Propel\om".  
  Did you forget a "use" statement for another namespace?                        


Exception trace:
 () at /var/www/autodial/vendor/friendsofsymfony/user-bundle/Propel/User.php:18

cache:warmup [--no-optional-warmers] [-h|--help] [-q|--quiet] [-v|vv|vvv|--verbose] [-V|--version] [--ansi] [--no-ansi] [-n|--no-interaction] [-e|--env ENV] [--no-debug] [--] <command>

I'm having the same problem.

I've attached a stack-trace.

Looks like the ValidatorCacheWarmer uses the available class-loaders to read metadata from all suitable loaders and that's where the error originates.

I am still convinced that it has something to do with the classmap-especially since the ValidatorBuilder uses it to build its metadata.


The stack trace

$ sf --env=prod cache:clear -vvv

 // Clearing the cache for the prod environment with debug false

 // Clearing outdated warmup directory...

 // Warming up cache...

PHP Fatal error:  Class 'FOS\UserBundle\Propel\om\BaseUser' not found in /home/cziel/projects/my-project/vendor/friendsofsymfony/user-bundle/Propel/User.php on line 18
PHP Stack trace:
PHP   1. {main}() /home/cziel/projects/my-project/bin/console:0
PHP   2. Symfony\Component\Console\Application->run() /home/cziel/projects/my-project/bin/console:29
PHP   3. Symfony\Bundle\FrameworkBundle\Console\Application->doRun() /home/cziel/projects/my-project/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:122
PHP   4. Symfony\Component\Console\Application->doRun() /home/cziel/projects/my-project/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Console/Application.php:80
PHP   5. Symfony\Component\Console\Application->doRunCommand() /home/cziel/projects/my-project/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:191
PHP   6. Symfony\Component\Console\Command\Command->run() /home/cziel/projects/my-project/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:846
PHP   7. Symfony\Bundle\FrameworkBundle\Command\CacheClearCommand->execute() /home/cziel/projects/my-project/vendor/symfony/symfony/src/Symfony/Component/Console/Command/Command.php:257
PHP   8. Symfony\Bundle\FrameworkBundle\Command\CacheClearCommand->warmup() /home/cziel/projects/my-project/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Command/CacheClearCommand.php:96
PHP   9. Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerAggregate->warmUp() /home/cziel/projects/my-project/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Command/CacheClearCommand.php:144
PHP  10. Symfony\Bundle\FrameworkBundle\CacheWarmer\ValidatorCacheWarmer->warmUp() /home/cziel/projects/my-project/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/CacheWarmer/CacheWarmerAggregate.php:48
PHP  11. Symfony\Component\Validator\Mapping\Factory\LazyLoadingMetadataFactory->getMetadataFor() /home/cziel/projects/my-project/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/ValidatorCacheWarmer.php:71
PHP  12. class_exists() /home/cziel/projects/my-project/vendor/symfony/symfony/src/Symfony/Component/Validator/Mapping/Factory/LazyLoadingMetadataFactory.php:106
PHP  13. spl_autoload_call() /home/cziel/projects/my-project/vendor/symfony/symfony/src/Symfony/Component/Validator/Mapping/Factory/LazyLoadingMetadataFactory.php:106
PHP  14. Composer\Autoload\ClassLoader->loadClass() /home/cziel/projects/my-project/vendor/symfony/symfony/src/Symfony/Component/Validator/Mapping/Factory/LazyLoadingMetadataFactory.php:106
PHP  15. Composer\Autoload\includeFile() /home/cziel/projects/my-project/vendor/composer/ClassLoader.php:301
PHP  16. include() /home/cziel/projects/my-project/vendor/composer/ClassLoader.php:412


  [Symfony\Component\Debug\Exception\ClassNotFoundException]
  Attempted to load class "BaseUser" from namespace "FOS\UserBundle\Propel\om".
  Did you forget a "use" statement for another namespace?


Exception trace:
 () at /home/cziel/projects/my-project/vendor/friendsofsymfony/user-bundle/Propel/User.php:18
PHP Notice:  Undefined index: function in /home/cziel/projects/my-project/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php on line 677
PHP Stack trace:
PHP   1. {main}() /home/cziel/projects/my-project/bin/console:0
PHP   2. Symfony\Component\Console\Application->run() /home/cziel/projects/my-project/bin/console:29
PHP   3. Symfony\Bundle\FrameworkBundle\Console\Application->doRun() /home/cziel/projects/my-project/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:122
PHP   4. Symfony\Component\Console\Application->doRun() /home/cziel/projects/my-project/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Console/Application.php:80
PHP   5. Symfony\Component\Console\Application->doRunCommand() /home/cziel/projects/my-project/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:191
PHP   6. Symfony\Component\Console\Command\Command->run() /home/cziel/projects/my-project/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:846
PHP   7. Symfony\Bundle\FrameworkBundle\Command\CacheClearCommand->execute() /home/cziel/projects/my-project/vendor/symfony/symfony/src/Symfony/Component/Console/Command/Command.php:257
PHP   8. Symfony\Bundle\FrameworkBundle\Command\CacheClearCommand->warmup() /home/cziel/projects/my-project/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Command/CacheClearCommand.php:96
PHP   9. Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerAggregate->warmUp() /home/cziel/projects/my-project/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Command/CacheClearCommand.php:144
PHP  10. Symfony\Bundle\FrameworkBundle\CacheWarmer\ValidatorCacheWarmer->warmUp() /home/cziel/projects/my-project/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/CacheWarmer/CacheWarmerAggregate.php:48
PHP  11. Symfony\Component\Validator\Mapping\Factory\LazyLoadingMetadataFactory->getMetadataFor() /home/cziel/projects/my-project/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/ValidatorCacheWarmer.php:71
PHP  12. class_exists() /home/cziel/projects/my-project/vendor/symfony/symfony/src/Symfony/Component/Validator/Mapping/Factory/LazyLoadingMetadataFactory.php:106
PHP  13. spl_autoload_call() /home/cziel/projects/my-project/vendor/symfony/symfony/src/Symfony/Component/Validator/Mapping/Factory/LazyLoadingMetadataFactory.php:106
PHP  14. Composer\Autoload\ClassLoader->loadClass() /home/cziel/projects/my-project/vendor/symfony/symfony/src/Symfony/Component/Validator/Mapping/Factory/LazyLoadingMetadataFactory.php:106
PHP  15. Composer\Autoload\includeFile() /home/cziel/projects/my-project/vendor/composer/ClassLoader.php:301
PHP  16. include() /home/cziel/projects/my-project/vendor/composer/ClassLoader.php:412
PHP  17. Symfony\Component\Debug\ErrorHandler::handleFatalError() /home/cziel/projects/my-project/vendor/symfony/symfony/src/Symfony/Component/Debug/ErrorHandler.php:0
PHP  18. Symfony\Component\Debug\ErrorHandler->handleException() /home/cziel/projects/my-project/vendor/symfony/symfony/src/Symfony/Component/Debug/ErrorHandler.php:604
PHP  19. call_user_func:{/home/cziel/projects/my-project/vendor/symfony/symfony/src/Symfony/Component/Debug/ErrorHandler.php:542}() /home/cziel/projects/my-project/vendor/symfony/symfony/src/Symfony/Component/Debug/ErrorHandler.php:542
PHP  20. Symfony\Component\HttpKernel\EventListener\DebugHandlersListener->Symfony\Component\HttpKernel\EventListener\{closure}() /home/cziel/projects/my-project/vendor/symfony/symfony/src/Symfony/Component/Debug/ErrorHandler.php:542
PHP  21. Symfony\Component\Console\Application->renderException() /home/cziel/projects/my-project/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/EventListener/DebugHandlersListener.php:113
 () at /home/cziel/projects/my-project/vendor/composer/ClassLoader.php:412
 Composer\Autoload\includeFile() at /home/cziel/projects/my-project/vendor/composer/ClassLoader.php:301
 Composer\Autoload\ClassLoader->loadClass() at /home/cziel/projects/my-project/vendor/symfony/symfony/src/Symfony/Component/Validator/Mapping/Factory/LazyLoadingMetadataFactory.php:106
 spl_autoload_call() at /home/cziel/projects/my-project/vendor/symfony/symfony/src/Symfony/Component/Validator/Mapping/Factory/LazyLoadingMetadataFactory.php:106
 class_exists() at /home/cziel/projects/my-project/vendor/symfony/symfony/src/Symfony/Component/Validator/Mapping/Factory/LazyLoadingMetadataFactory.php:106
 Symfony\Component\Validator\Mapping\Factory\LazyLoadingMetadataFactory->getMetadataFor() at /home/cziel/projects/my-project/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/ValidatorCacheWarmer.php:71
 Symfony\Bundle\FrameworkBundle\CacheWarmer\ValidatorCacheWarmer->warmUp() at /home/cziel/projects/my-project/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/CacheWarmer/CacheWarmerAggregate.php:48
 Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerAggregate->warmUp() at /home/cziel/projects/my-project/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Command/CacheClearCommand.php:144
 Symfony\Bundle\FrameworkBundle\Command\CacheClearCommand->warmup() at /home/cziel/projects/my-project/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Command/CacheClearCommand.php:96
 Symfony\Bundle\FrameworkBundle\Command\CacheClearCommand->execute() at /home/cziel/projects/my-project/vendor/symfony/symfony/src/Symfony/Component/Console/Command/Command.php:257
 Symfony\Component\Console\Command\Command->run() at /home/cziel/projects/my-project/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:846
 Symfony\Component\Console\Application->doRunCommand() at /home/cziel/projects/my-project/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:191
 Symfony\Component\Console\Application->doRun() at /home/cziel/projects/my-project/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Console/Application.php:80
 Symfony\Bundle\FrameworkBundle\Console\Application->doRun() at /home/cziel/projects/my-project/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:122
 Symfony\Component\Console\Application->run() at /home/cziel/projects/my-project/bin/console:29
 {main}() at /home/cziel/projects/my-project/bin/console:0

OK, I think I will move the propel integration into a separate bundle for v2 (and look for a maintainer for it, as I'm not using Propel myself), to avoid such issue.

How about just gutting Propel? Version 2 will never be finished (it's been
in alpha for years, Version 1 is deprecated. There's no good reason for
using Propel.

Alternatively, you could create the \Propel\om\BaseUser class and check it
into the repo.

On Tue, Oct 11, 2016 at 11:36 AM, Christophe Coevoet <
[email protected]> wrote:

OK, I think I will move the propel integration into a separate bundle for
v2 (and look for a maintainer for it, as I'm not using Propel myself), to
avoid such issue.


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/FriendsOfSymfony/FOSUserBundle/issues/2224#issuecomment-252954303,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAl0QUTMWJIj4TGaGyg9t6QQmoS6acnDks5qy6z9gaJpZM4J-Aqi
.

Alternatively, you could create the \Propel\om\BaseUser class and check it
into the repo

This is not how propel should work

Alternatively, you could create the \Propel\om\BaseUser class and check it into the repo.

As this class would extend from a Propel class, you would still have the same issue about the missing base class. It would just be the next one.

Any update on this? This issue prevents me from updating to Symfony 3.2 right now.

@stephanvierkant you can "pin" a healthy commit in the require section in your composer.json.

The last healthy commit is a24e799c8febbae675d41a42b552574887fa1784, so I use this right now and postpone the need to deal with the broken dependency for now:

  "friendsofsymfony/user-bundle": "2.0.x-dev#a24e799c8febbae675d41a42b552574887fa1784",

this commit a24e799 does not resolve issue for me

I just double checked it. Works fine for me, but I recall having trouble until i manually removed the cache dir.

same issue here and downgrading to a24e799 won't help either! :(

Friends don't let friends use Propel.

How about dropping Propel support until Propel2 is at least in beta? For
Propel1 support, use an older version of FOSUserBundle.

If you're upgrading to Symfony 3, you probably should be using an ORM
that's not obsolete or in alpha.

On Wed, Nov 2, 2016 at 11:53 AM, Kevin Saliou [email protected]
wrote:

same issue here and downgrading to a24e799
https://github.com/FriendsOfSymfony/FOSUserBundle/commit/a24e799c8febbae675d41a42b552574887fa1784
won't help either! :(


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/FriendsOfSymfony/FOSUserBundle/issues/2224#issuecomment-257907803,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAl0QQj5Od2bPzff7eNYNKLA5L6GtFSiks5q6LINgaJpZM4J-Aqi
.

👍 for dropping propel. We can (re)add support later, if someone needs this.

I've done a little further digging into this, and have a temporary workaround, but not a solution.

vendor/friendsofsymfony/user-bundle/Resources/config/validation.xml

https://github.com/FriendsOfSymfony/FOSUserBundle/blob/v2.0.0-alpha3/Resources/config/validation.xml#L97

comment out lines 97 > 183

Cache should now clear.

The issue appears to have been triggered by the inclusion of the ValidatorCacheWarmer in Symfony 3.2.

My theory goes that extracting the propel part of the validation.xml file to e.g. validation_propel.xml, and selectively loading that if using propel would solve the problem. Unfortunately, my current attempt to fix this problem is hitting this issue - something to do with the way I'm loading the config, but not sure exactly what yet:

 [InvalidArgumentException]                                                                                        
  [ERROR 1845] Element '{http://symfony.com/schema/dic/constraint-mapping}constraint-mapping': No matching global   
  declaration available for the validation root. (in /var/www/api.tribecount.dev/ - line 5, column 0)     

I have same issue on symfony/symfony@a4edafbd

@XWB - just checked #59f9949 of Symfony, and #4ea37a5 of FOSUserBundle, and the cache clears fine for me :thumbsup:

@ryzhov You need to use the 3.2 branch, Symfony master branch has not been updated yet.

still not work in this environment

symfony/symfony 3.2.x-dev 59f9949 The Symfony PHP framework
friendsofsymfony/user-bundle dev-master dd966ca Symfony FOSUserBundle

Does not work.
After add to te composer.json

        "exclude-from-classmap": [
            "vendor/friendsofsymfony/user-bundle/Propel/"
        ]

composer still creating autoload class map with Propel files (composer bug?)
Event if I remove manually Propel files from composer autload class, still does not work.

Composer\Autoload\ClassLoader->loadClass function if will not find class in the class map, will find
file friendsofsymfony/user-bundle/Propel/User.php by path.

ValidatorCacheWarmer class (XmlFileLoader) is trying to load Propel classes because in the file

/friendsofsymfony/user-bundle/Resources/config/validation.xml 

there is

<class name="FOS\UserBundle\Propel\User">

and Symfony parsing this file is trying to load class FOS\UserBundle\Propel\User.

The solution is to split file

/friendsofsymfony/user-bundle/Resources/config/validation.xml 

into Doctrine and Propel validation_{orm}.xml files and load files manually by compiler pass:

see for example
http://stackoverflow.com/questions/24064813/how-to-split-validation-yaml-files-in-symfony-2-5/24210501#24210501

Exactly to fix it you can update file https://github.com/FriendsOfSymfony/FOSUserBundle/blob/master/DependencyInjection/Compiler/ValidationPass.php

by add something like

$validationFile = __DIR__.'/../../Resources/config/validation/orm.xml';
 if ($storage == 'propel') {
     $validationFile = __DIR__ . '/../../Resources/config/validation/propel.xml';
 }
 $container->getDefinition('validator.builder')
      ->addMethodCall('addXmlMapping', array($validationFile));

and split /friendsofsymfony/user-bundle/Resources/config/validation.xml into orm.xml and propel.xml
and update documentaion

@dkorsak not a composer bug. As these files are in the FOSUserBundle package, the exclude rule would have to be added in the FOSUserBundle metadata

now cache:clear works as expected, thanks !

Was this page helpful?
0 / 5 - 0 ratings