laravel/lumen-framework

'ReflectionException' with message 'Class path.storage does not exist'

Closed this issue Β· 27 comments

after run:
php artisan

get this errors:
PHP Fatal error: Uncaught exception 'ReflectionException' with message 'Class path.storage does not exist' in /Applications/MAMP/htdocs/folder-project/vendor/laravel/framework/src/Illuminate/Container/Container.php:748 Stack trace:

PHP Fatal error: Uncaught exception 'Symfony\Component\Debug\Exception\FatalErrorException' with message 'Uncaught exception 'ReflectionException' with message 'Class path.storage does not exist' in /Applications/MAMP/htdocs/folder-project/vendor/laravel/framework/src/Illuminate/Container/Container.php:748 Stack trace:

Looks like a bug in a package you're using perhapse?

No I do not think depend on some package, because it stopped working suddenly

this is composer.json

{
"name": "laravel/lumen",
"description": "The Laravel Lumen Framework.",
"keywords": ["framework", "laravel", "lumen"],
"license": "MIT",
"type": "project",
"require": {
"php": ">=5.6.4",
"laravel/lumen-framework": "5.3.*",
"vlucas/phpdotenv": "~2.2",
"wn/lumen-generators": "^1.1"
},
"require-dev": {
"fzaninotto/faker": "~1.4",
"phpunit/phpunit": "~5.0",
"mockery/mockery": "~0.9",
"asamaru7/eloquent-model-generator-for-lumen": "^1.0"
},
"autoload": {
"psr-4": {
"App": "app/"
}
},
"autoload-dev": {
"classmap": [
"tests/",
"database/"
]
},
"scripts": {
"post-root-package-install": [
"php -r "copy('.env.example', '.env');""
]
},
"minimum-stability": "dev",
"prefer-stable": true
}

What is the exact version of Lumen that you use?

5.3.1 updated today, but already with 5.3 had problems with php artisan

Looks like it's due to asamaru7/eloquent-model-generator-for-lumen.

No I do not think so.
I deleted that package but the error persists

I'm running into similar weird problems

  1. storage exceptions occasionaly and this message intermittenlty

I think its related

2016-11-11 08:34:12] lumen.ERROR: exception 'ReflectionException' with message 'Class App\Http\Controllers\Request does not exist' in /var/www/html/dbapi/api/vendor/illuminate/container/Container.php:573
Stack trace:
#0 /var/www/html/dbapi/api/vendor/illuminate/container/Container.php(573): ReflectionParameter->getClass()
#1 /var/www/html/dbapi/api/vendor/illuminate/container/Container.php(534): Illuminate\Container\Container->addDependencyForCallParameter(Object(ReflectionParameter), Array, Array)
#2 /var/www/html/dbapi/api/vendor/illuminate/container/Container.php(506): Illuminate\Container\Container->getMethodDependencies(Array, Array)
#3 /var/www/html/dbapi/api/vendor/laravel/lumen-framework/src/Concerns/RoutesRequests.php(610): Illuminate\Container\Container->call(Array, Array)
#4 /var/www/html/dbapi/api/vendor/laravel/lumen-framework/src/Concerns/RoutesRequests.php(577): Laravel\Lumen\Application->callControllerCallable(Array, Array)
#5 /var/www/html/dbapi/api/vendor/laravel/lumen-framework/src/Concerns/RoutesRequests.php(550): Laravel\Lumen\Application->callLumenController(Object(App\Http\Controllers\GuideController), 'show', Array)
#6 /var/www/html/dbapi/api/vendor/laravel/lumen-framework/src/Concerns/RoutesRequests.php(512): Laravel\Lumen\Application->callControllerAction(Array)
#7 /var/www/html/dbapi/api/vendor/laravel/lumen-framework/src/Concerns/RoutesRequests.php(497): Laravel\Lumen\Application->callActionOnArrayBasedRoute(Array)
#8 /var/www/html/dbapi/api/vendor/laravel/lumen-framework/src/Concerns/RoutesRequests.php(467): Laravel\Lumen\Application->handleFoundRoute(Array)
#9 /var/www/html/dbapi/api/vendor/laravel/lumen-framework/src/Concerns/RoutesRequests.php(399): Laravel\Lumen\Application->handleDispatcherResponse(Array)
#10 [internal function]: Laravel\Lumen\Application->Laravel\Lumen\Concerns{closure}(Object(Illuminate\Http\Request))
#11 /var/www/html/dbapi/api/vendor/laravel/lumen-framework/src/Routing/Pipeline.php(52): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#12 /var/www/html/dbapi/api/vendor/palanik/lumen-cors/LumenCors.php(105): Laravel\Lumen\Routing\Pipeline->Laravel\Lumen\Routing{closure}(Object(Illuminate\Http\Request))
#13 /var/www/html/dbapi/api/vendor/illuminate/pipeline/Pipeline.php(137): palanik\lumen\Middleware\LumenCors->handle(Object(Illuminate\Http\Request), Object(Closure))
#14 [internal function]: Illuminate\Pipeline\Pipeline->Illuminate\Pipeline{closure}(Object(Illuminate\Http\Request))
#15 /var/www/html/dbapi/api/vendor/laravel/lumen-framework/src/Routing/Pipeline.php(32): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#16 /var/www/html/dbapi/api/vendor/illuminate/pipeline/Pipeline.php(104): Laravel\Lumen\Routing\Pipeline->Laravel\Lumen\Routing{closure}(Object(Illuminate\Http\Request))
#17 /var/www/html/dbapi/api/vendor/laravel/lumen-framework/src/Concerns/RoutesRequests.php(647): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#18 /var/www/html/dbapi/api/vendor/laravel/lumen-framework/src/Concerns/RoutesRequests.php(400): Laravel\Lumen\Application->sendThroughPipeline(Array, Object(Closure))
#19 /var/www/html/dbapi/api/vendor/laravel/lumen-framework/src/Concerns/RoutesRequests.php(341): Laravel\Lumen\Application->dispatch(NULL)

In my case (lumen 5.3.3) got fixed by adding following lines right after $app definition in bootstrap/app.php file:

$app = new Laravel\Lumen\Application(
        realpath(__DIR__ . '/../')
);

$app->instance('path.config', app()->basePath() . DIRECTORY_SEPARATOR . 'config');
$app->instance('path.storage', app()->basePath() . DIRECTORY_SEPARATOR . 'storage');

//$app->withFacades();
$app->withEloquent();
lsl commented

This is happening because Illuminate's helpers are being loaded before Lumen's.

My autoload_files.php:

'f0906e6318348a765ffb6eb24e0d0938' => $vendorDir . '/laravel/framework/src/Illuminate/Foundation/helpers.php',
'bee9632da3ca00a99623b9c35d0c4f8b' => $vendorDir . '/laravel/lumen-framework/src/helpers.php',

This seems to happen when laravel/framework gets required by something, composer wipes out lumens vendor/illuminate files with vendor/laravel/framework (laravel/framework composer.json says replace illuminate.) - this in turn includes illuminate/Foundation/helpers.php

What's weirder is it seems like we're beholden to composer and how it scores/sorts autoload_files.php. I managed to get this to load in different (working) orders but I'm not 100% sure how - and frankly don't have time for this. But that does confirm @bthibault's issue.

This issue also persists after removing offending packages from composer.json and running composer update. I suspect this is a caching problem with the laravel replace and composer.

These steps seem to fix the issue, at least intermittently: (and may help reproducing the issue!)

  1. Deleting your composer cache (rm -rf ~/.composer/cache/laravel/framework),
  2. Delete your composer.lock file (not 100% this is required)
  3. Delete your vendor dir (don't worry it mostly gets reloaded from cache)
  4. Run composer update

In my case I was running phpunit from my $PATH (~/.composer/vendor/bin) rather than the project vendor/bin/phpunit file, and I guess for reasons mentioned by @lsl, laravel overloaded lumen helpers.

This only seems to have emerged after I recently added config/filesystems.php.

The solution was to run tests with vendor/bin/phpunit instead.

PHP Fatal error:  Uncaught ReflectionException: Class path.storage does not exist in /Users/stevethomas/Code/Lp/lp-api/vendor/illuminate/container/Container.php:729
Stack trace:
#0 /Users/stevethomas/Code/Lp/lp-api/vendor/illuminate/container/Container.php(729): ReflectionClass->__construct('path.storage')
#1 /Users/stevethomas/Code/Lp/lp-api/vendor/illuminate/container/Container.php(608): Illuminate\Container\Container->build('path.storage')
#2 /Users/stevethomas/Code/Lp/lp-api/vendor/illuminate/container/Container.php(575): Illuminate\Container\Container->resolve('path.storage')
#3 /Users/stevethomas/Code/Lp/lp-api/vendor/laravel/lumen-framework/src/Application.php(208): Illuminate\Container\Container->make('path.storage')
#4 /Users/stevethomas/.composer/vendor/illuminate/support/Illuminate/Support/helpers.php(33): Laravel\Lumen\Application->make('path.storage')
#5 /Users/stevethomas/.composer/vendor/illuminate/support/Illuminate/Support/helpers.php(790): app('path.storage')
#6 /Users/stevethomas/Code/Lp/lp-api/config/filesy in /Users/stevethomas/Code/Lp/lp-api/vendor/illuminate/container/Container.php on line 729

Consider where storage_path() is being called from. In my case, it was called from the app's config file, which was too soon. Moving the call into the app proper fixed this issue for me.

Same issue reported in laravel 5.4

Please check #798 and see if the problem still exists in 5.7. Otherwise feel free to ping me to reopen :)

This issue still exists in 5.7

If you are running lumen and if any required package uses as a dependency laravel/framework it will fail.

Make sure the call to parent::tearDown() is after your own code - the inverse of setUp().

    public function tearDown(): void
    {
        //////////////////////////////
        // Your code should go here //
        //////////////////////////////
        parent::tearDown();
    }

Lumen 5.8 also - I just hit this problem.

I had spatie/laravel-tags installed, which has a laravel/framework dependency, and the only non-Laravel package to do so, from what I could see. Removing that has not helped yet.

Adding the two lines @hpaknia suggests here has solved it for me, though that feels like a hack.

After composer require --dev nunomaduro/larastan you bump into this as well with Lumen 5.8. Which purports to be Lumen compatible: https://github.com/nunomaduro/larastan

It appears it causes illuminate/container to be removed (among others).

If you don't particularly need Larastan, you can recover from this with removing nunomaduro/larastan from your composer.json and running rm -rf vendor composer.lock && composer install. With a remaining composer.lock it seems to linger with a removed illuminate/container even after removing nunomaduro/larastan from your composer.json

Clearing composer cache and install vendor packages fixed in my case.

composer clear-cache
composer install

Try this:

$app->instance('path.config', app()->getConfigurationPath());
$app->instance('path.storage', app()->storagePath());

Hi, I encountered the same problem yesterday. I did some research and end up here. Although this issue didn't help me, I was able to figure out that it was one of the packages which were incompatible with my Lumen app. Later, I figured out that it happened because of the latest version (8.x) of DarkaOnLine/SwaggerLume which I installed together with Lumen version 7.x.

To solve the problem I just removed the latest version of SwaggerLume and installed 7.x as specified in the documentation. Hope this will help people with similar error. Thanks. :)

Yeah, I also encountered the same problem now.

Lumen 8.x ,there are two storage_path helper functions shown below.

image

image

image

I used composer why laravel/framework, found appstract/laravel-opcache,removed it compsoer remove appstract/laravel-opcache (rm -rf vendor/ & composer install) or set path.storage in bootstrap\app.php => #504 (comment)

image

Same issue in lumen 8.x after doing php artisan vapor-ui:install

ClCfe commented

Try this:

$app->instance('path.config', app()->getConfigurationPath());
$app->instance('path.storage', app()->storagePath());

I think for config_path, you should use
$app->instance('path.config', app()->configPath());
that s what they do in laravel8 or lumen8

ClCfe commented

Yeah, I also encountered the same problem now.

Lumen 8.x ,there are two storage_path helper functions shown below.

image

image

image

I used composer why laravel/framework, found appstract/laravel-opcache,removed it compsoer remove appstract/laravel-opcache (rm -rf vendor/ & composer install) or set path.storage in bootstrap\app.php => #504 (comment)

image

I think you found the bug, the definition of storage_path() is wrong in laravel8 helpers.php

looking at config_path(), you can see it is exactly the same definition in lumen and laravel, so no conflict

Same issue with Lumen 8^ version

I installed "darkaonline/l5-swagger": "^8.0" and after run command
php artisan vendor:publish --provider "L5Swagger\L5SwaggerServiceProvider
But got error

Fatal error: Uncaught ReflectionException: Class path.storage does not exist in C:\MyProjects\jpost-api\vendor\laravel\framework\src\Illuminate\Container\Container.php:873

Running

composer clear-cache
composer install

didnt help

Swagger laravel has separate version for lumen
https://github.com/DarkaOnLine/SwaggerLume

So I downloaded this version and all fine now

image

Swagger laravel has separate version for lumen https://github.com/DarkaOnLine/SwaggerLume

So I downloaded this version and all fine now

image

This helped me
Thanks