Looking to hire Laravel developers? Try LaraJobs

laravel maintained by cattleman-dev

Description
An artisan command palette for setting up Cattleman modules (Sockets first) in a Laravel app.
Last update
2026/11/23 15:44 (dev-main)
License
Downloads
0

Comments
comments powered by Disqus

Cattleman for Laravel

Artisan commands that set up Cattleman modules in a Laravel 11 or 12 app. Install it as a dev dependency:

composer require --dev cattleman-dev/laravel

Then open the palette:

php artisan cattleman

Sockets

php artisan cattleman:sockets

Points the app's broadcasting at your Cattleman Sockets deployment. It asks for the deployment's credentials, from its page in Cattleman: enter each value, or paste a .env block with CATTLEMAN_* or PUSHER_* variables (handy when moving an app off Pusher). Then it:

  • publishes config/broadcasting.php if it isn't there, and adds a cattleman connection: Laravel's own Pusher driver, pointed at your worker;
  • creates routes/channels.php and registers it in bootstrap/app.php;
  • installs pusher/pusher-php-server, which the Pusher driver needs (as a normal dependency);
  • sets BROADCAST_CONNECTION=cattleman and the CATTLEMAN_* values in .env, and adds the same keys, without secrets, to .env.example;
  • optionally sets up Laravel Echo: the VITE_CATTLEMAN_* variables, resources/js/echo.js, and the laravel-echo and pusher-js packages.

Every step checks first, so running it again is safe. It never replaces an existing value or another broadcaster without asking (or --force), and it leaves an existing echo.js alone, printing the settings to use instead.

Without prompts, for scripts and CI:

php artisan cattleman:sockets --no-interaction \
    --app-id=123 --key=your-key --secret=your-secret \
    --host=https://your-sockets.your-subdomain.workers.dev \
    --with-echo --without-node
Option
--app-id, --key, --secret The deployment's credentials
--host The worker's hostname or URL (a URL sets --scheme and --port too)
--port, --scheme Default 443 and https
--local Use the cattleman/sockets image on this machine (see below)
--with-echo / --without-echo Set up Laravel Echo, or don't ask
--without-composer Don't install pusher/pusher-php-server
--without-node Don't install laravel-echo and pusher-js
--composer The Composer binary to use
--force Replace existing values without asking

Local development

To build against Sockets without a deployment, run the cattleman/sockets image, which runs the same worker on your machine:

docker run --rm -p 6001:6001 cattleman/sockets
php artisan cattleman:sockets --local

--local fills in the image's defaults (app-id, app-key, app-secret, localhost, port 6001, http), so it asks for no credentials. Give any of --app-id, --key, --secret, --host or --port to change one: for an app that runs in a container beside it, --host is the image's service name. The browser still reaches it on localhost, so set VITE_CATTLEMAN_HOST to that.

Checking the connection

php artisan cattleman:sockets:check

Confirms the cattleman connection is configured, that the app broadcasts through it, and that the worker accepts the credentials. --trigger also sends a test event to the cattleman-check channel.

The connection it adds:

'cattleman' => [
    'driver' => 'pusher',
    'key' => env('CATTLEMAN_APP_KEY'),
    'secret' => env('CATTLEMAN_APP_SECRET'),
    'app_id' => env('CATTLEMAN_APP_ID'),
    'options' => [
        'host' => env('CATTLEMAN_HOST'),
        'port' => env('CATTLEMAN_PORT', 443),
        'scheme' => env('CATTLEMAN_SCHEME', 'https'),
        'encrypted' => true,
        'useTLS' => env('CATTLEMAN_SCHEME', 'https') === 'https',
    ],
],

Development

composer install
vendor/bin/phpunit

Licence

MIT. See LICENSE.