Laravel Flashcards
Your own application, as well as all of Laravel’s core services are bootstrapped via
service providers
the central place to configure your application is
Service providers
All service providers extend the
Illuminate\Support\ServiceProvider
Most service providers contain methods:
register and a boot
Within the register method of service provider, you should only bind things into the
service container
You should never attempt to register any event listeners, routes, or any other piece of functionality within the
register method
Within any of your service provider methods, you always have access to the $app property which provides
access to the service container:
This method is called after all other service providers have been registered, meaning you have access to all other services that have been registered by the framework
The Boot Method
To defer the loading of a provider, implement the
\Illuminate\Contracts\Support\DeferrableProvider
Facades provide a ? interface to classes that are available in the application’s service container
Static
All of Laravel’s facades are defined in the
Illuminate\Support\Facades
Using real times facades
You may treat all class in your system like it was facade
For example for App\Contracts\Publisher
Use
Facade\App\Contracts\Publisher
You may modify the prefix and other route group options by modifying your
RouteServiceProvider class
Sometimes you may need to register a route that responds to multiple HTTP verbs. You may do so using the match method. Or, you may even register a route that responds to all HTTP verbs using the any method
Route::match(['get', 'post'], '/', function () { // });
Route::any('/', function () { // });
If you are defining a route that redirects to another URI, you may use the
Route::redirect
By default, Route::redirect returns a
302
You may use the ? method to return a 301 status code:
Route::permanentRedirect
If your route only needs to return a view, you may use the
Route::view method
Route::view(‘/welcome’, ‘welcome’, [‘name’ => ‘Taylor’]);