Laravel - Type error: Too few arguments?

Laravel - Type error: Too few arguments?

  1. Blog
  2. 15 November 2026
  3. 3 min read

Stefan Bogdanescu

Founder & Senior Architect

Laravel - Type error: Too few arguments?

When you encounter a Type error: Too few arguments in Laravel, it is almost always a direct symptom of a mismatch between your controller signature and your service method signature. Unlike some languages or frameworks that default to null for missing parameters, PHP enforces strict typing when type hints are present. If your controller expects $request but your service requires $plan, passing only the request will result in an immediate runtime failure unless you explicitly handle the missing dependency.

The confusion often stems from Laravel's powerful dependency injection container and its ability to resolve models automatically. You might assume that because Laravel can inject a User or Post model into a controller, it does "magic" to fill in any missing arguments for your service classes as well. However, this automatic resolution only applies to dependencies defined in the Service Provider's boot method or explicitly requested via constructor injection where the container knows how to resolve them.

In your specific case, the error occurs because the todoService::createList method declares a dependency on Plan. When the controller calls $this->todoService->createList($request), Laravel invokes that specific method on an already-resolved service instance. At this point, the container is no longer involved in the call stack; it is simply PHP executing the function with the arguments provided at runtime. Since only one argument ($request) is passed to a method expecting two, PHP throws the type error.

To resolve this without manually instantiating the Plan object in your controller logic, you have three primary architectural options. The most robust approach is injecting the dependency into the service's constructor. By moving the Plan instance resolution to the constructor, you ensure that the service class itself is responsible for managing its dependencies.

// todoService.php
use App\Plan;
use Illuminate\Support\Facades\DB; // Or however Plan is resolved

class TodoService {
    public function __construct(protected Plan $plan) {
        // The Plan instance is now injected here by the container
    }

    public function createList($request) {
        // Access $plan directly here. 
        // Note: If 'createList' requires a specific plan that changes per request,
        // you may need to resolve the new instance inside the method or pass it in.
    }
}

However, if createList is meant to operate on a dynamic Plan object that varies based on the context (e.g., different plans for different users), injecting a single instance via the constructor might not be sufficient. In scenarios where the dependency changes per request, you must resolve it within the method or pass it as an argument.

If you choose to pass the Plan instance as an argument, you must ensure the controller has access to that specific object. This usually means resolving the Plan model inside the controller:

// Controller.php
public function create(CreateRequest $request)
{
    // Resolve the plan based on the request context
    $plan = Plan::find($request->input('plan_id')); 
    
    if (!$plan) {
        return response()->json(['error' => 'Plan not found'], 404);
    }

    return $this->todoService->createList($request, $plan);
}

Alternatively, you can configure Laravel's service container to provide the Plan instance when resolving the TodoService. This requires defining a binding in your Service Provider. If the TodoService constructor expects Plan, Laravel will attempt to resolve it. If the controller is calling a static method or a non-injected instance, this won't help.

The key takeaway is that "magic" injection happens at the point of service resolution (constructor injection), not at the point of method invocation. If your service method requires dynamic data like a specific Plan object that isn't part of the service's static state, you must resolve it before calling the method or restructure the service to accept it as an argument. This ensures type safety and prevents runtime errors that can be frustrating to debug later in the application lifecycle.

Our network