konekt/concord
Laravel extension for building modular applications using conventions on top of service providers. Manage in-app and external modules with isolation-friendly structure, version compatibility across Laravel releases, and tooling around module registration and organization.
Freely based on the idea of Magento helpers. These kinds of classes are often required in views where using namespaces isn't very elegant, and pushing instances from controllers would just increase noise.
So Concord's idea is that helpers are generally just services registered
in the service container but they can be reached via an abbreviated call
like helper('money')->helperMethod() or if you register the Helper
facade Helper::get('money')->helperMethod().
Helpers instances are singletons.
You can register helpers with Concord's registerHelper() method:
concord()->registerHelper('helper_name', HelperClass::class);
You can access this helper via helper('helper_name')->someMethod(), which gives you short access to HelperClass's someMethod().
Registering helpers actually adds the class name as a singleton in the container as
concord.helpers.helper_namekey. Thus accessible viaapp('concord.helpers.helper_name')as well.
Helpers need to be registered either in a module's ModuleServiceProvider or in the AppServiceProvider classes boot() method:
public function boot()
{
parent::boot();
// In ModuleServiceProviders:
$this->concord->registerHelper('product', ProductHelper::class);
// in AppServiceProvider:
$this->app->concord->registerHelper('product', ProductHelper::class);
}
This makes you possible using helper('product')->someMethod().
Next: Views »
How can I help you explore Laravel packages today?