I am running out of options. We try to run a Laravel 8 project on Azure App Engine. For some reason this error keeps coming back. When I run the same codebase on my VPS everything is working fine. Any ideas are welcome!
user@eb917e1a0ab0:/home/site/wwwroot# php artisan
[15-Feb-2024 08:34:03 UTC] PHP Warning: require(/storage/bootstrap/cache): Failed to open stream: Success in /home/site/wwwroot/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/LoadConfiguration.php on line 28
[15-Feb-2024 08:34:04 UTC] PHP Fatal error: Uncaught ReflectionException: Class "config" does not exist in /home/site/wwwroot/vendor/laravel/framework/src/Illuminate/Container/Container.php:877
Stack trace:
#0 /home/site/wwwroot/vendor/laravel/framework/src/Illuminate/Container/Container.php(877): ReflectionClass->__construct('config')
#1 /home/site/wwwroot/vendor/laravel/framework/src/Illuminate/Container/Container.php(758): Illuminate\Container\Container->build('config')
#2 /home/site/wwwroot/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(851): Illuminate\Container\Container->resolve('config', Array, true)
#3 /home/site/wwwroot/vendor/laravel/framework/src/Illuminate/Container/Container.php(694): Illuminate\Foundation\Application->resolve('config', Array)
#4 /home/site/wwwroot/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(836): Illuminate\Container\Container->make('config', Array)
#5 /home/site/wwwroot/vendor/laravel/framework/src/Illuminate/Container/Container.php(1419): Illuminate\Foundation\Application->make('config')
#6 /home/site/wwwroot/vendor/laravel/framework/src/Illuminate/Log/LogManager.php(469): Illuminate\Container\Container->offsetGet('config')
#7 /home/site/wwwroot/vendor/laravel/framework/src/Illuminate/Log/LogManager.php(520): Illuminate\Log\LogManager->getDefaultDriver()
#8 /home/site/wwwroot/vendor/laravel/framework/src/Illuminate/Log/LogManager.php(112): Illuminate\Log\LogManager->parseDriver(NULL)
#9 /home/site/wwwroot/vendor/laravel/framework/src/Illuminate/Log/LogManager.php(590): Illuminate\Log\LogManager->driver()
#10 /home/site/wwwroot/vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php(252): Illuminate\Log\LogManager->error('Failed opening ...', Array)
#11 /home/site/wwwroot/app/Exceptions/Handler.php(57): Illuminate\Foundation\Exceptions\Handler->report(Object(Error))
#12 /home/site/wwwroot/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(366): App\Exceptions\Handler->report(Object(Error))
#13 /home/site/wwwroot/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(131): Illuminate\Foundation\Console\Kernel->reportException(Object(Error))
#14 /home/site/wwwroot/artisan(37): Illuminate\Foundation\Console\Kernel->handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#15 {main}
Next Illuminate\Contracts\Container\BindingResolutionException: Target class [config] does not exist. in /home/site/wwwroot/vendor/laravel/framework/src/Illuminate/Container/Container.php:879
Stack trace:
#0 /home/site/wwwroot/vendor/laravel/framework/src/Illuminate/Container/Container.php(758): Illuminate\Container\Container->build('config')
#1 /home/site/wwwroot/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(851): Illuminate\Container\Container->resolve('config', Array, true)
#2 /home/site/wwwroot/vendor/laravel/framework/src/Illuminate/Container/Container.php(694): Illuminate\Foundation\Application->resolve('config', Array)
#3 /home/site/wwwroot/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(836): Illuminate\Container\Container->make('config', Array)
#4 /home/site/wwwroot/vendor/laravel/framework/src/Illuminate/Container/Container.php(1419): Illuminate\Foundation\Application->make('config')
#5 /home/site/wwwroot/vendor/laravel/framework/src/Illuminate/Log/LogManager.php(469): Illuminate\Container\Container->offsetGet('config')
#6 /home/site/wwwroot/vendor/laravel/framework/src/Illuminate/Log/LogManager.php(520): Illuminate\Log\LogManager->getDefaultDriver()
#7 /home/site/wwwroot/vendor/laravel/framework/src/Illuminate/Log/LogManager.php(112): Illuminate\Log\LogManager->parseDriver(NULL)
#8 /home/site/wwwroot/vendor/laravel/framework/src/Illuminate/Log/LogManager.php(590): Illuminate\Log\LogManager->driver()
#9 /home/site/wwwroot/vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php(252): Illuminate\Log\LogManager->error('Failed opening ...', Array)
#10 /home/site/wwwroot/app/Exceptions/Handler.php(57): Illuminate\Foundation\Exceptions\Handler->report(Object(Error))
#11 /home/site/wwwroot/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(366): App\Exceptions\Handler->report(Object(Error))
#12 /home/site/wwwroot/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(131): Illuminate\Foundation\Console\Kernel->reportException(Object(Error))
#13 /home/site/wwwroot/artisan(37): Illuminate\Foundation\Console\Kernel->handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#14 {main}
thrown in /home/site/wwwroot/vendor/laravel/framework/src/Illuminate/Container/Container.php on line 879
/storage is a storage bucket mounted RW
/home/site/wwwroot/vendor is mounted as RW
/home/site/wwwroot/storage is mounted as RW
/home/site/wwwroot/bootstrap is mounted as RW
It looks like Laravel is having trouble loading the configuration because it cannot access the /storage/bootstrap/cache directory. This could be due to incorrect permissions or an incorrect path. Since you mentioned that /storage is a storage bucket, it's possible that Laravel is expecting the bootstrap/cache directory to be within the local filesystem, but it's actually in a remote storage bucket.
Here's what you can try to resolve the issue:
Ensure that the bootstrap/cache directory exists and is writable by the web server. If it doesn't exist, you need to create it and set the correct permissions.
Clear the cached configuration to make sure there are no stale configuration values. You can do this by running the following command:
php artisan config:clear
If the bootstrap/cache directory is indeed in a remote storage bucket, you might need to adjust the configuration to ensure Laravel knows where to find it. Check your filesystems configuration in config/filesystems.php to make sure the paths are set correctly.
Since Azure App Service has a different file system structure, you might need to modify the bootstrap/app.php file to set the correct storage path. You can do this by adding the following line before the return statement:
Then, set the APP_STORAGE environment variable to the correct path in your Azure App Service configuration.
If you're using Azure Blob Storage for your application's storage, ensure that you have correctly set up the driver and that your .env file has the correct Azure Blob Storage credentials and configuration.
Lastly, check the logs for any Azure-specific issues that might be causing the problem. Azure App Service might have certain restrictions or require additional configuration that is not immediately obvious.
If you've tried all of the above and the issue persists, it might be helpful to check the Laravel and Azure communities for similar issues or to reach out to Azure support for help with the App Service environment.