Support the ongoing development of Laravel.io →
IOC Packages
Last updated 3 months ago.
0
<?php namespace Example\Facades;

use Illuminate\Support\Facades\Facade;
class ExampleFacade extends Facade {
    protected static function getFacadeAccessor() { return 'example'; }
}

You can write a Facade class like this which has to implement the getFacadeAccessor() method. The string it returns is the string you have defined in your ServiceProvider and the Facade will "point" to the Object created from that string.

After that you need to register your Facade in config/app.php in the aliases array.

0

Can i get any example on how to create package and register facades for that package

i had used this tools http://packalyst.com/packages/package/xtwoend/workbench

but failed

Last updated 6 years ago.
0

Sign in to participate in this thread!

Cloudways

Your banner here too?

mukeshp004 mukeshp004 mukeshp004 Joined 23 Jun 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

The Laravel portal for problem solving, knowledge sharing and community building.

© 2022 Laravel.io - All rights reserved.