Trying to make the ide-helper work for all the cases. I enabled helper support in the config, cleared the cache, built the _ide_helper.php and the .phpstorm.meta.php, restarted PhpStorm as described in the documentation. Code completion works for many cases, but not for all. For instance:
public/index.php
$kernel = $app->make(Illuminate\Contracts\Http\Kernel::class); // $kernel unresolved
$response = $kernel->handle( // Method 'handle' not found
$request = Illuminate\Http\Request::capture()
);
$response->send(); // Method 'send' not found
$kernel->terminate($request, $response); // Method 'terminate' not found
database/factories/ModelFactory.php
// Method 'define' not found in TheSeer\Autoload\Factory
$factory->define(App\User::class, function (Faker\Generator $faker) {
database/migrations/2014_10_12_000000_create_users_table.php
// Method 'unique' not found in Illuminate\Support\Fluent
$table->string('email')->unique();
app/Http/Middleware/Authenticate.php
// Method 'guard' not found in \Illuminate\Support\Facades\Auth
if (Auth::guard($guard)->guest()) {
if ($request->ajax() || $request->wantsJson()) {
return response('Unauthorized.', 401);
} else {
return redirect()->guest('login'); // Method 'guest' not found in
}
}
In such cases just adding /** @var $kernel
\Illuminate\Contracts\Http\Kernel */ will do the trick. Unfortunately
this package can't solve all situations of
auto-completion/object-recognition. Also, everything \Fluent related is
not supported yet, because that class is generic thing used for many
things: from collections to Db.
On 08-05-2016 13:44, danilcha wrote:
Trying to make the ide-helper work for all the cases. I enabled helper
support in the config, cleared the cache, built the _ide_helper.php
and the .phpstorm.meta.php, restarted PhpStorm as described in the
documentation. Code completion works for many cases, but not for all.
For instance:_public/index.php_
$kernel = $app->make(Illuminate\Contracts\Http\Kernel::class); //
$kernel unresolved
$response = $kernel->handle( // Method 'handle' not found
$request = Illuminate\HttpRequest::capture()
);
$response->send(); // Method 'send' not found
$kernel->terminate($request, $response); // Method 'terminate' not found_database/factories/ModelFactory.php_
// Method 'define' not found in TheSeer\Autoload\Factory
$factory->define(App\User::class, function (Faker\Generator $faker) {_database/migrations/2014_10_12_000000_create_users_table.php_
// Method 'unique' not found in Illuminate\Support\Fluent
$table->string('email')->unique();_app/Http/Middleware/Authenticate.php_
// Method 'guard' not found in \Illuminate\Support\FacadesAuth
if (Auth::guard($guard)->guest()) {
if ($request->ajax() || $request->wantsJson()) {
return response('Unauthorized.', 401);
} else {
return redirect()->guest('login'); // Method 'guest' not found in
}
}—
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub
https://github.com/barryvdh/laravel-ide-helper/issues/348
Additionally, instead of Facades, I recommend using
app('facade-shortcut-here'), in your case app('auth.driver')
On 08-05-2016 13:44, danilcha wrote:
Trying to make the ide-helper work for all the cases. I enabled helper
support in the config, cleared the cache, built the _ide_helper.php
and the .phpstorm.meta.php, restarted PhpStorm as described in the
documentation. Code completion works for many cases, but not for all.
For instance:_public/index.php_
$kernel = $app->make(Illuminate\Contracts\Http\Kernel::class); //
$kernel unresolved
$response = $kernel->handle( // Method 'handle' not found
$request = Illuminate\HttpRequest::capture()
);
$response->send(); // Method 'send' not found
$kernel->terminate($request, $response); // Method 'terminate' not found_database/factories/ModelFactory.php_
// Method 'define' not found in TheSeer\Autoload\Factory
$factory->define(App\User::class, function (Faker\Generator $faker) {_database/migrations/2014_10_12_000000_create_users_table.php_
// Method 'unique' not found in Illuminate\Support\Fluent
$table->string('email')->unique();_app/Http/Middleware/Authenticate.php_
// Method 'guard' not found in \Illuminate\Support\FacadesAuth
if (Auth::guard($guard)->guest()) {
if ($request->ajax() || $request->wantsJson()) {
return response('Unauthorized.', 401);
} else {
return redirect()->guest('login'); // Method 'guest' not found in
}
}—
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub
https://github.com/barryvdh/laravel-ide-helper/issues/348
Thank you. I'm starting to understand why it does not work in all cases. The facades defined in _ide_helper.php are in global namespace and work only if a php script does not explicitly import the original version, right? So it works with Route, for instance, but does not work with Auth.
The whole Laravel looks like it is written by someone with a Notepad as the IDE. All those Fluent (why not define a custom class for column definitions?), magic methods, Facades, etc. The very fact that some facades I have to import, and some I don't...
There is a PhpStorm ticket about implementing external PHPDoc annotations, hope it will improve the situation with Laravel.
You must have gotten all this upside down :) Because you technically make no sense:
Whatever Facade you want to use in a namespaced script, you need to import it:
use \Route,
\Auth;
You don't need to import Route in routes.php, because config and bootstrapping files are not namespaced. And this import topic is not only about Facades, this is how PHP works: e.g. use \Exception;. I strongly recommend you acquaint yourself with PHP 5 features, namespaces in particular.
Laravel has quite advanced abstraction and design pattern implementation, mostly ported from Ruby.
@barryvdh , I recommend closing this issue, it's rapidly becoming "PHP 101".
Getting the same problem in RedirectIfAuthenticated Middleware on a fresh Laravel install. The problem is that by default, Auth is included with use Illuminate\Support\Facades\Auth;, so I have to remove that line and use \Auth instead, so that PhpStorm knows to look into _ide_helper.php
Seeing the same issue as @clytemnestra, when we include the full class path for Facades. We do this for clarity on which specific class is being loaded.
@barryvdh, is there any chance the IDE Helper could add support for full class paths when importing Facades? e.g. use Illuminate\Support\Facades\Request;
Just another voice asking for this too. Thank you Barry.
Nope, only by modifying the vendor files
Ok thanks for the information Barry.
I take it by your response that Taylor and others have already said no to any changing or updating of Laravel docblocks?
I know Graham Campbell is always very "we program for humans not IDE's" orientated - which is fairly frustrating. When you're immersed in the code it's easy to be dismissive of how easy it all is, but for others like me, a little hand holding by the IDE is very welcome and saves me hours of mistakes.
BTW Barry, If I could star this repo more than once I would. It's just SO crazy useful. Thanks for creating it!
Well I think Taylor actually was open to adding some phpdocs and accepted some pull requests lately.. I just meant this package can't do that.
I'm not sure if there has been a breaking change made in PHPStorm lately, but I can't get this working for the life of me:
http://itsolutionstuff.com/post/how-to-create-custom-facade-in-laravel-52example.html
I've tried both the pre-generated, and generated my own, _ide_helper, generated .phpstorm.meta.php, made sure I have the Laravel Plugin installed, but no matter what I do, the "most working" I can get it when I Ctrl-Click on the Facade invocation, it navigates to the class definition in _ide_helper or the Facade class, instead of the concrete class being facaded.
Is this package broken for the latest versions of PHPStorm?
Thanks!
still get same issue, is there have solution now?
This is a problematic issue; there are so many different things pointed out, some may already been fixed, some are still present (namespaced returned values in Facades don't work correctly, there are already multiple issues about this)
I encourage everyone still having issues to a) search the existing issues and vote/comment there or b) create new individual issues per encountered problem.
@barryvdh I think https://github.com/barryvdh/laravel-ide-helper/issues/348#issuecomment-218684683 made already the right call and therefore I too suggest to close this issue :}
Most helpful comment
Getting the same problem in
RedirectIfAuthenticatedMiddleware on a fresh Laravel install. The problem is that by default, Auth is included withuse Illuminate\Support\Facades\Auth;, so I have to remove that line and use\Authinstead, so that PhpStorm knows to look into_ide_helper.php