When I run ide-helper:generate on lumen project, it ended with the following error and it does not generate _ide_helper.php.
% php artisan ide-helper:generate
In Alias.php line 69:
Class App does not exist
The versions are as follows:
laravel/lumen-framework: v5.6.4
barryvdh/laravel-ide-helper: v2.5.0
composer create-project --prefer-dist laravel/lumen foo
composer require barryvdh/laravel-ide-helper
bootstrap/app.phpUncomment the following two lines.
$app->withFacades();
$app->register(App\Providers\AppServiceProvider::class);
app/Providers/AppServiceProvider.phpRegister IdeHelperServiceProvider in register()
public function register()
{
$this->app->register(\Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider::class);
}
ide-helper:generatephp artisan ide-helper:generate
The error occurs at line 69 of src/Alias.php, which is added since v2.5.0.
//Create a DocBlock and serializer instance
$this->phpdoc = new DocBlock(new ReflectionClass($alias), new Context($this->namespace));
Lumen does not provide an alias App to \Illuminate\Support\Facades\App by default. (see \Laravel\Lumen\Application::withAliases())
So there is no App class, and it will be an error to create RefrectionClass of App. However, the root cause seems to be trying to create an Alias object for a non-existent App class.
This process is based on the alias => original array returned by \Barryvdh\LaravelIdeHelper\Generator::getAliases(). The problem is that the return value of getaliases() contains App which does not exist.
protected function getAliases()
{
// For Laravel, use the AliasLoader
if (class_exists('Illuminate\Foundation\AliasLoader')) {
return AliasLoader::getInstance()->getAliases();
}
$facades = [
'App' => 'Illuminate\Support\Facades\App',
'Auth' => 'Illuminate\Support\Facades\Auth',
'Bus' => 'Illuminate\Support\Facades\Bus',
'DB' => 'Illuminate\Support\Facades\DB',
'Cache' => 'Illuminate\Support\Facades\Cache',
'Cookie' => 'Illuminate\Support\Facades\Cookie',
'Crypt' => 'Illuminate\Support\Facades\Crypt',
'Event' => 'Illuminate\Support\Facades\Event',
'Hash' => 'Illuminate\Support\Facades\Hash',
'Log' => 'Illuminate\Support\Facades\Log',
'Mail' => 'Illuminate\Support\Facades\Mail',
'Queue' => 'Illuminate\Support\Facades\Queue',
'Request' => 'Illuminate\Support\Facades\Request',
'Schema' => 'Illuminate\Support\Facades\Schema',
'Session' => 'Illuminate\Support\Facades\Session',
'Storage' => 'Illuminate\Support\Facades\Storage',
//'Validator' => 'Illuminate\Support\Facades\Validator',
];
$facades = array_merge($facades, $this->config->get('app.aliases', []));
// Only return the ones that actually exist
return array_filter($facades, function ($alias) {
return class_exists($alias);
});
}
There is an array_filter to eliminate aliases that do not exist at the end of this function, but since the class name of alias is on the key side of the $facades array, it is needed to do the following using ARRAY_FILTER_USE_KEY to check its existence:
return array_filter(
$facades,
function ($alias) {
return class_exists($alias);
},
ARRAY_FILTER_USE_KEY
);
I too have this problem.
MBP-van-Yvan:cyberfusion-api yvanwatchman$ php artisan ide-helper:generate
In Alias.php line 69:
Class App does not exist
Can also confirm. Same error as YWatchman.
I don't know will someone of contributors of this package fix this bug, but temporary workaround, while this issue is open, would be to add in app.php something like this:
$classes = [
'App' => Illuminate\Support\Facades\App::class,
'Bus' => Illuminate\Support\Facades\Bus::class,
'Hash' => Illuminate\Support\Facades\Hash::class,
'Request' => Illuminate\Support\Facades\Request::class,
];
foreach ($classes as $alias => $class) {
if (! class_exists($alias)) {
class_alias($class, $alias);
}
}
I am still having same issue. I am using 2.5.1. @iocaste fix solved my problem.
+1 also having this issue.
laravel/lumen-framework: v5.6.4
barryvdh/laravel-ide-helper: v2.5.1
I had to apply @iocaste 's fix for every Class missing
+1
same problem with laravel/lumen-framework: v5.6.4
+1
laravel/lumen-framework: v5.7.1
barryvdh/laravel-ide-helper: v2.5.1
same here
laravel/lumen-framework: v5.7.1
barryvdh/laravel-ide-helper: v2.5.1
Having the same issue "laravel/lumen-framework": "5.5.*" "barryvdh/laravel-ide-helper": "^2.5"
I executed 'steps to reproduce' again on this issue. An error occurred, but it is different from what I reported on this issue.
% php artisan ide-helper:generate
In FilesystemManager.php line 160:
Class 'League\Flysystem\Adapter\Local' not found
So this is another problem.
The root cause has not been investigated, but it can be avoided by installing league/flysystem.
composer require league/flysystem
After installing it, I was able to execute ide-helper:generate successfully.
This has already been reported as #723.
I have a similar problem with Laravel 5.7: ide-helper:meta returns:
In MetaCommand.php line 138:
Class 'CreateMetaTable' not found.
Most helpful comment
I don't know will someone of contributors of this package fix this bug, but temporary workaround, while this issue is open, would be to add in
app.phpsomething like this: