1

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.

p.wright
  • 131
  • 1
  • 9
  • 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 Dec 20 '17 at 10:28
  • Please check this: https://stackoverflow.com/questions/37419143/undefined-class-route-laravel-in-phpstorm – Hiren Gohel Dec 20 '17 at 10:36
  • 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 Dec 20 '17 at 10:47

2 Answers2

2

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

Alexey Mezenin
  • 158,981
  • 26
  • 290
  • 279
  • Jeffery only types App::bind. Why do I need to enter \App::bind or use a helper function ? I know about not doing it in web.php, only following his video demo. :-) – p.wright Dec 20 '17 at 10:19
0

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

Amando Vledder
  • 1,316
  • 1
  • 13
  • 23