Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

alnahian2003's avatar

Can I instantiate a Controller with by default Model Binding using Artisan Command?

We can easily generate or make a resource controller through php artisan make:controller ControllerName --resource command (notice, we embed --resource flag with the command). It generally created a resource route, to easily perform crud operations through route.

But, is there any persistent way to generate a Controller with automatic Model Binding that corresponds to the controller? e.g. Maybe I run a command like this php artisan make:controller --resource --bind and it will generate a controller with few methods like this,

	use App\Models\MyModel;
	public function edit(MyModel $mymodel) {
		//
	}

Is it really available in laravel or do I have to just manually typehint/inject the Model while working?

Let me know if you still didn't get my question. Thanks!

0 likes
2 replies

Please or to participate in this conversation.