cattleman-dev / laravel
An artisan command palette for setting up Cattleman modules (Sockets first) in a Laravel app.
Requires
- php: ^8.2
- illuminate/console: ^11.0 || ^12.0
- illuminate/support: ^11.0 || ^12.0
- laravel/prompts: ^0.1.18 || ^0.2 || ^0.3
Requires (Dev)
- orchestra/testbench: ^9.0 || ^10.0
- phpunit/phpunit: ^11.0
- pusher/pusher-php-server: ^7.2
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
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.phpif it isn't there, and adds acattlemanconnection: Laravel's own Pusher driver, pointed at your worker; - creates
routes/channels.phpand registers it inbootstrap/app.php; - installs
pusher/pusher-php-server, which the Pusher driver needs (as a normal dependency); - sets
BROADCAST_CONNECTION=cattlemanand theCATTLEMAN_*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 thelaravel-echoandpusher-jspackages.
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.