laravel / framework

The Laravel Framework.
https://laravel.com
MIT License
32.45k stars 11k forks source link

Issue with config:cache and collect() #23984

Closed leenooks closed 6 years ago

leenooks commented 6 years ago

Description:

In config/app.php I have used many collections, eg:

        // Details on the financial periods for each key
        'financial_periods' => collect([
                0=>['name'=>'1Q','tag'=>'q1'],
                1=>['name'=>'2Q','tag'=>'q2'],
                2=>['name'=>'3Q','tag'=>'q3'],
                3=>['name'=>'4Q','tag'=>'q4'],
        ]),

And while this works fine for the application (HTTP or console), if I use artisan config:cache which completes successfully, the app (HTTP or Console) then fails with

Fatal error: Uncaught ReflectionException: Class config does not exist in /var/www/html/vendor/laravel/framework/src/Illuminate/Container/Container.php:767
Stack trace:
#0 /var/www/html/vendor/laravel/framework/src/Illuminate/Container/Container.php(767): ReflectionClass->__construct('config')
#1 /var/www/html/vendor/laravel/framework/src/Illuminate/Container/Container.php(646): Illuminate\Container\Container->build('config')
#2 /var/www/html/vendor/laravel/framework/src/Illuminate/Container/Container.php(601): Illuminate\Container\Container->resolve('config', Array)
#3 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(734): Illuminate\Container\Container->make('config', Array)
#4 /var/www/html/vendor/laravel/framework/src/Illuminate/Container/Container.php(1210): Illuminate\Foundation\Application->make('config')
#5 /var/www/html/vendor/laravel/framework/src/Illuminate/Log/LogManager.php(436): Illuminate\Container\Container->offsetGet('config')
#6 /var/www/html/vendor/laravel/framework/src/I in /var/www/html/vendor/laravel/framework/src/Illuminate/Container/Container.php on line 767

Removing bootstrap/cache/config.php clears the problem.

Is it not possible to use collections in config/app.php?

Steps To Reproduce:

In config/app.php just add a value using a collect().

tillkruss commented 6 years ago

Nope.