Laravel implements the Facades function, laravelfacades. Laravel implements the Facades function. anyone who has used Laravel in laravelfacades knows the power of Facades. let's create a Facades instance together. If any, Laravel implements the Facades function and laravelfacades
Anyone who has used Laravel knows the power of Facades. let's create a Facades instance together. If there are any errors, please do not give me any further advice.
1. implement automatic Laravel loading
Create the app/lib/Myapp directory and add the directory to composer. json.
1 "autoload": { 2 "psr-0":{3 "Myapp":"app/lib"4 }5 }
2. implement function classes
Implementation class app/lib/Myapp/Test. php
1
3. implement ServiceProvider
Implement app/lib/Myapp/TestServiceProvider. php. this class mainly adds the function class to the Ioc container:
app['test'] = $this->app->share( function ($app) { return new \Myapp\Test(); }); }}
4. implement a Facade instance
Implements app/lib/Myapp/Facades/TestFacades. php. this class is mainly beautifying and the calling form of member functions is similar to that of static methods.
1
5. load ServiceProvider
Add the following configuration to providers in app/config/app. php:
1 'providers' => array( 2 'Myapp\TestServiceProvider'3 ),
Add an alias to aliases in app/config/app. php:
1 'aliases' => array(2 'TestClass' => 'Myapp\Facades\TestFacades',3 ),
Next, you can use this function class in the form of TestClass: do () in the project.
Http://www.bkjia.com/PHPjc/944439.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/944439.htmlTechArticleLaravel to achieve the Facades function, laravelfacades using Laravel students know the power of Facades, let us create a Facades instance. If something is incorrect, return...