Give

Give a specific binding contextually

Description: Contextually gives a specific value or binding for the annotated parameter, similar to $this->app->when(...)->needs(...)->give(...).

Namespace: Illuminate\Container\Attributes\Give

Usage

use Illuminate\Container\Attributes\Give;

class NotificationService
{
    public function __construct(
        #[Give('notifications@example.com')] private readonly string $fromEmail
    ) {}
}

Also accepts class names (string bindings):

use App\Services\SmsDriver;

class NotificationService
{
    public function __construct(
        #[Give(SmsDriver::class)] private readonly DriverInterface $driver
    ) {}
}