mitchellvanw / laravel-doctrine

NO LONGER MAINTAINED! A Doctrine 2 implementation that melts with Laravel
MIT License
187 stars 74 forks source link

doctrine:schema:update Fails in Production #94

Closed nateajohnson closed 7 years ago

nateajohnson commented 9 years ago

I am using the develop branch in a Laravel 5 app. If this branch isn't quite ready, just let me know. Anyway, I get the following error with the doctrine artisan commands. It only happens when there is a compiled.php file in storage/framework. Since a local app ignores that file, all is well. But in production it uses that file. If I delete that file, I can run the artisan commands and regenerate the file, but I doubt that is what you are after.

Thanks Nate

$ php artisan doctrine:schema:update
Checking if database needs updating....
PHP Fatal error:  Cannot redeclare class Manage\Providers\ConfigServiceProvider in /home/forge/myapp.com/app/Providers/ConfigServiceProvider.php on line 23
PHP Stack trace:
PHP   1. {main}() /home/forge/myapp.com/artisan:0
PHP   2. Illuminate\Foundation\Console\Kernel->handle() /home/forge/myapp.com/artisan:36
PHP   3. Symfony\Component\Console\Application->run() /home/forge/myapp.com/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php:91
PHP   4. Symfony\Component\Console\Application->doRun() /home/forge/myapp.com/vendor/symfony/console/Symfony/Component/Console/Application.php:126
PHP   5. Symfony\Component\Console\Application->doRunCommand() /home/forge/myapp.com/vendor/symfony/console/Symfony/Component/Console/Application.php:195
PHP   6. Illuminate\Console\Command->run() /home/forge/myapp.com/vendor/symfony/console/Symfony/Component/Console/Application.php:874
PHP   7. Symfony\Component\Console\Command\Command->run() /home/forge/myapp.com/vendor/laravel/framework/src/Illuminate/Console/Command.php:101
PHP   8. Illuminate\Console\Command->execute() /home/forge/myapp.com/vendor/symfony/console/Symfony/Component/Console/Command/Command.php:253
PHP   9. Illuminate\Container\Container->call() /home/forge/myapp.com/vendor/laravel/framework/src/Illuminate/Console/Command.php:115
PHP  10. call_user_func_array:{/home/forge/myapp.com/storage/framework/compiled.php:922}() /home/forge/myapp.com/storage/framework/compiled.php:922
PHP  11. Mitch\LaravelDoctrine\Console\SchemaUpdateCommand->fire() /home/forge/myapp.com/storage/framework/compiled.php:922
PHP  12. Doctrine\Common\Persistence\Mapping\AbstractClassMetadataFactory->getAllMetadata() /home/forge/myapp.com/vendor/mitchellvanw/laravel-doctrine/src/Console/SchemaUpdateCommand.php:17
PHP  13. Doctrine\Common\Persistence\Mapping\Driver\AnnotationDriver->getAllClassNames() /home/forge/myapp.com/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/AbstractClassMetadataFactory.php:114
exception 'Symfony\Component\Debug\Exception\FatalErrorException' with message 'Cannot redeclare class Manage\Providers\ConfigServiceProvider' in /home/forge/myapp.com/app/Providers/ConfigServiceProvider.php:23
Stack trace:
#0 /home/forge/myapp.com/storage/framework/compiled.php(1721): Illuminate\Foundation\Bootstrap\HandleExceptions->fatalExceptionFromError(Array)
#1 [internal function]: Illuminate\Foundation\Bootstrap\HandleExceptions->handleShutdown()
#2 {main}
kirkbushell commented 9 years ago

Develop/master branch should always be considered unstable. That's standard.

We'll be doing a fair amount of work on this in the coming days.

nateajohnson commented 9 years ago

Thanks. I figured so, but wanted to get this out there. I'll wait until the official 1.0 release that supports Laravel 5 and test it then.

kirkbushell commented 9 years ago

0.6 will be released tomorrow or the day after, which is the last L4 release for the project. After that, I imagine either 1.x or 0.7.x will be L5 onwards.

mitchellvanw commented 9 years ago

Could you please share your doctrine.php config, @nateajohnson?

nateajohnson commented 9 years ago

Here it is...

<?php

return [
    'simple_annotations' => false,

    'metadata' => [
        // Paths to entities here...
        base_path('app')
    ],

    'proxy' => [
        'auto_generate' => false,
        'directory'     => null,
        'namespace'     => null
    ],

    // Available: null, apc, xcache, redis, memcache
    'cache_provider' => null,

    'cache' => [
        'redis' => [
            'host'     => '127.0.0.1',
            'port'     => 6379,
            'database' => 1
        ],
        'memcache' => [
            'host' => '127.0.0.1',
            'port' => 11211
        ]
    ],

    'repository' => 'Doctrine\ORM\EntityRepository',

    'repositoryFactory' => null,

    'logger' => null
];
kirkbushell commented 9 years ago

@nateajohnson are your entities in the app directory?

nateajohnson commented 9 years ago

Yeah, they are in the app directory. And it works just fine most of the time. The only thing that was failing was the schema generation when in a laravel production environment (where there is a compiled.php file - all classes in one big file for performance reasons). In a local environment it works fine because laravel doesn't create the compiled.php file. Now if I run the artisan optimize command and create compiled.php locally it fails there too. It appears the schema generator is finding compiled.php with duplicate class declarations which are conflicting with the scanning of the non-compiled classes.

That's my best guess at the issue.

mitchellvanw commented 7 years ago

Closing because project is no longer maintained. Thanks.