Support the ongoing development of Laravel.io →
Configuration IOC Architecture
Last updated 2 years ago.
0

I am an idiot. This is totally possible, but I had my service provider order wrong.

This is what I do now:

class AppServiceProvider extends ServiceProvider {

	/**
	 * Register services.
	 */
	public function register() {
		$this->app->singleton(MyFormBuilder::class, function ($app) {
			return new MyFormBuilder($app, $app[FormHelper::class], $app['events']);
		});

		$this->app->alias(MyFormBuilder::class, 'laravel-form-builder');
		$this->app->alias(MyFormBuilder::class, 'Kris\LaravelFormBuilder\FormBuilder');
	}

}

And that makes every call resolve to my FormBuilder. Injections, app() calls, everything. Perfect.

Last updated 7 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

rudiedirkx rudiedirkx Joined 19 Feb 2017

Moderators

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

Your logo here?

Laravel.io

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

© 2024 Laravel.io - All rights reserved.