> ## Documentation Index
> Fetch the complete documentation index at: https://docs.pushctl.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Laravel quickstart

> Install and configure the Pushctl Laravel SDK and send your first notification.

The package supports PHP 8.3+ and Laravel 12 or 13.

<Steps>
  <Step title="Install the package">
    ```bash theme={null}
    composer require pushctl/pushctl-laravel
    ```
  </Step>

  <Step title="Configure a Server send token">
    ```dotenv theme={null}
    PUSHCTL_TOKEN=push_live_your_server_token
    ```

    The default service URL is `https://pushctl.com` and the default timeout is 10 seconds.
  </Step>

  <Step title="Create a Laravel notification">
    ```php theme={null}
    use Illuminate\Notifications\Notification;
    use Pushctl\PushctlLaravel\Channels\PushctlChannel;
    use Pushctl\PushctlLaravel\Messages\PushctlMessage;

    final class OrderReady extends Notification
    {
        public function __construct(private readonly Order $order) {}

        public function via(object $notifiable): array
        {
            return [PushctlChannel::class];
        }

        public function toPushctl(object $notifiable): PushctlMessage
        {
            return PushctlMessage::create(
                'Order ready',
                'Your order is ready for collection.',
            )->actionUrl("myapp://orders/{$this->order->id}");
        }
    }
    ```
  </Step>

  <Step title="Route the recipient">
    ```php theme={null}
    use Illuminate\Notifications\Notification;

    public function routeNotificationForPushctl(Notification $notification): string|array
    {
        return $this->pushctl_user_id;
    }
    ```
  </Step>

  <Step title="Dispatch through Laravel">
    ```php theme={null}
    $user->notify(new OrderReady($order));
    ```
  </Step>
</Steps>

<Warning>Keep `PUSHCTL_TOKEN` in the server environment. Do not commit it or expose it to browser or mobile code.</Warning>
