laravel/framework · error · InvalidArgumentException

Method not provided.

Error message

Method not provided.

What it means

Thrown by BoundMethod::callClass() when a Class@method-style target string is resolved but neither the @method segment nor a fallback defaultMethod is available. The container uses the @ sign to split a class name from the method to invoke; if there is no @ and no default, there is nothing callable. This is the framework's way of refusing to guess which method to dispatch.

Solutions

  1. Append the method name using Class@method syntax, e.g. 'UserController@index'.
  2. If calling Container::call() directly, pass the defaultMethod as the 4th argument so it is used when no @ is present.
  3. Pass a proper callable array [$instance, 'method'] or a Closure instead of a string target.
  4. Search the codebase for the exact controller/class string and verify every usage includes the method.

Example fix

// before
Container::call('App\Services\ReportGenerator');
// after
Container::call('App\Services\ReportGenerator@generate');
// or
Container::call('App\Services\ReportGenerator', [], 'generate');
Defensive patterns

Strategy: validation

Validate before calling

// Before calling a Class@method target, ensure it is well-formed.
function ensureCallableTarget(string $target, ?string $defaultMethod = null): void
{
    $segments = explode('@', $target);
    if (count($segments) !== 2 && $defaultMethod === null) {
        throw new InvalidArgumentException("Target [$target] must be 'Class@method' or a default method must be supplied.");
    }
}

ensureCallableTarget($target, $defaultMethod);
$result = Container::call($target, $params, $defaultMethod);

Type guard

function isClassAtMethodTarget(string $target): bool
{
    return count(explode('@', $target)) === 2;
}

Try / catch

try {
    Container::call($target, $params, $defaultMethod);
} catch (\InvalidArgumentException $e) {
    if (str_contains($e->getMessage(), 'Method not provided')) {
        // fix the target string to Class@method and retry / report
    }
    throw $e;
}

Prevention

When it happens

Trigger: Calling Container::call('App\Http\Controllers\UserController') (no @method) without a defaultMethod argument; registering a route as a bare controller string without an action; dispatching a job/queued listener whose handler string omits the method suffix.

Common situations: Route definitions like Route::get('users', 'UserController') missing '@index'; refactoring a controller and forgetting to update a Container::call() target; queue config referencing 'Class' instead of 'Class@handle'; typo dropping the @method portion.

Related errors


AI-assisted analysis of laravel/framework@e0f6eb3518 (2026-08-11). Data as JSON: /api/errors/f1847c566b93e92a. Report an issue: GitHub.

Appendix: source

Thrown at src/Illuminate/Container/BoundMethod.php:63

     * @param  array  $parameters
     * @param  string|null  $defaultMethod
     * @return mixed
     *
     * @throws \InvalidArgumentException
     */
    protected static function callClass($container, $target, array $parameters = [], $defaultMethod = null)
    {
        $segments = explode('@', $target);

        // We will assume an @ sign is used to delimit the class name from the method
        // name. We will split on this @ sign and then build a callable array that
        // we can pass right back into the "call" method for dependency binding.
        $method = count($segments) === 2
            ? $segments[1]
            : $defaultMethod;

        if (is_null($method)) {
            throw new InvalidArgumentException('Method not provided.');
        }

        return static::call(
            $container,
            [$container->make($segments[0]), $method],
            $parameters
        );
    }

    /**
     * Call a method that has been bound to the container.
     *
     * @param  \Illuminate\Container\Container  $container
     * @param  callable  $callback
     * @param  mixed  $default
     * @return mixed
     */
    protected static function callBoundMethod($container, $callback, $default)

View on GitHub (pinned to e0f6eb3518)