1
votes

This is so basic, but driving me mad. In the laracast video https://laracasts.com/series/laravel-from-scratch-2017/episodes/24, right at the start, Jeffery types

App::bind(.....

into web.php.

I have a new install of Laravel 5.4. If I type App::bind

I get "undefined class App". If I give a full path name

\Illuminate\Support\Facades\App::bind 

it says method bind not found in \Illuminate\Support\Facades.

What am I doing wrong. I thought Facades were all registered automatically.

2
Sorry guys, my bad. PHPStorm is telling me that the facade doesn't exist. I need to install an IDE-Helper as PHPStorm can't resolve facades. Finished the code example and it does actually work, just need to ignore all the PHPStorm coding errors. - p.wright
You need to add the Laravel IDE helper as a ServiceProvider into your application. In the app/config/app.php file, add 'Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider' under the providers element and then run the artisan ide-helper:generate command! This will fixed your issue! - Hiren Gohel

2 Answers

2
votes

You can use the app() helper instead of App::bind() facade or use full namespace which is \App::bind().

Also, you really shouldn't do that in web.php, use service providers instead.

https://laravel.com/docs/5.5/container

0
votes

There is no need to use the full App namespace. You need to use \App::bind since App is a facade