Laravel Rust cheat sheet: from php artisan to the laravel CLI
Every common Artisan command next to its Laravel Rust equivalent: creating apps, running locally, migrations, queues, the scheduler, keys, tests and production.
- cli
- cheat-sheet
- getting-started
On this page
In Laravel Rust, the laravel command does the job of php artisan. Most command names are the same, so the quickest translation is to swap the prefix. This page lists the ones you’ll use every week, and the few that work differently or don’t exist.
Two things to know before the tables:
laravelcompiles first. Running a command through the CLI builds your app, then runs the command. It shows compiler output only when the build fails.- On a server, there’s no
laravel. You run your compiled binary with the same arguments:./app migrate --force. Running the binary with no command starts the HTTP server.
Setting up
| Laravel PHP | Laravel Rust |
|---|---|
composer global require laravel/installer |
curl -fsSL https://laravel.com/install.sh | sh (PowerShell: irm https://laravel.com/install.ps1 | iex) |
laravel new shop |
laravel new shop --rust (or answer “Rust” when asked) |
php artisan key:generate |
laravel key:generate (the new app already has a key) |
php artisan --version |
laravel --version, which should start with “Laravel CLI” |
Tip: check which
laravelyou’re running. Herd and the old Composer installer also install alaravelcommand. Iflaravel --versiondoesn’t start with “Laravel CLI”, another one is earlier on yourPATH.
Running the app locally
| Laravel PHP | Laravel Rust |
|---|---|
composer run dev |
laravel dev (server, queue worker and Vite together) |
php artisan serve |
laravel serve |
php artisan list |
laravel list |
php artisan help route:list |
laravel help route:list |
php artisan route:list |
laravel route:list (-v shows middleware, --path=admin, --handler=users, --json) |
php artisan inspire |
laravel inspire, the example command in new apps |
laravel dev rebuilds and restarts the server and the queue worker when you save a file in src/, Cargo.toml, Cargo.lock or .env, then refreshes the browser. Frontend files reload through Vite as usual. If the laravel CLI isn’t installed somewhere, cargo run -- route:list runs a command through Cargo instead.
Database
| Laravel PHP | Laravel Rust |
|---|---|
php artisan make:migration create_bikes_table |
laravel make:migration create_bikes_table |
php artisan migrate |
laravel migrate |
php artisan migrate:status |
laravel migrate:status |
php artisan migrate:fresh --seed |
laravel migrate:fresh --seed |
php artisan migrate:rollback |
None. Migrations are forward-only: write a new one |
php artisan db:seed |
laravel db:seed |
php artisan db:seed --class=BikeSeeder |
laravel db:seed bikes |
php artisan schema:dump --prune |
laravel schema:dump --prune |
php artisan migrate --database=reporting |
laravel migrate --database reporting |
More in Migrations and the database in Laravel Rust.
Queues
| Laravel PHP | Laravel Rust |
|---|---|
php artisan queue:work |
laravel queue:work |
php artisan queue:work --queue=high,default |
laravel queue:work --queue=high,default |
| Several worker processes | laravel queue:work --concurrency=8 (one process, several jobs at once) |
php artisan queue:restart |
laravel queue:restart |
php artisan queue:failed |
laravel queue:failed |
php artisan queue:retry all |
laravel queue:retry all |
php artisan queue:forget {id} |
laravel queue:forget {id} |
php artisan queue:flush --hours=48 |
laravel queue:flush --hours=48 |
php artisan queue:clear redis --queue=emails |
laravel queue:clear redis --queue=emails |
php artisan queue:pause emails |
laravel queue:pause emails (and queue:continue) |
php artisan queue:retry-batch {id} |
laravel queue:retry-batch {id} |
php artisan queue:prune-batches |
laravel queue:prune-batches |
More in Queues and jobs in Laravel Rust.
Scheduler
| Laravel PHP | Laravel Rust |
|---|---|
php artisan schedule:work |
laravel schedule:work |
php artisan schedule:list |
laravel schedule:list |
php artisan schedule:clear-cache |
laravel schedule:clear-cache |
php artisan schedule:interrupt |
./app schedule:interrupt after a deploy |
Cron: php artisan schedule:run |
Cron: ./app schedule:run |
The scheduler runs everything in UTC, and it doesn’t catch up on minutes it missed while the server was down.
Tests and code checks
| Laravel PHP | Laravel Rust |
|---|---|
php artisan test |
cargo test |
php artisan test --filter=holds |
cargo test holds |
vendor/bin/pint |
cargo fmt |
vendor/bin/phpstan |
cargo clippy --all-targets |
npm run lint, npm run types |
npm run check, npm run types:check (npm run check:fix to fix) |
More in Testing in Laravel Rust.
On a server
| Laravel PHP | Laravel Rust |
|---|---|
composer install --no-dev |
cargo build --release |
| PHP-FPM behind a web server | ./app (the binary serves HTTP itself) |
php artisan migrate --force |
./app migrate --force |
php artisan key:generate --show |
./app key:generate --show |
php artisan queue:work under Supervisor |
./app queue:work under your process supervisor |
To try a production build locally, run npm run build and then cargo run --release. Before deploying, check that APP_ENV is production and APP_DEBUG is false.
More in Deploying Laravel Rust to Laravel Cloud.
What doesn’t carry over
make:generators. Of themake:commands, onlymake:migrationis documented so far. Models, handlers, jobs, inputs and commands are ordinary Rust files you write yourself. Runlaravel listto see what your version has.migrate:rollback. Migrations have nodownmethod. Undo a change with a new migration.- Caching commands. The docs don’t mention
config:cache,route:cacheoroptimize. The release build is the build step. tinker. There’s no documented equivalent yet.
Writing your own command
php artisan make:command becomes an async fn with #[command]. Its arguments are the command’s arguments and options, and its doc comments become the help text. There’s no registration step:
// src/console/close_overdue_rentals.rs
use laravel::console::{Console, command};
/// Mark rentals overdue when their bike wasn't returned in time.
#[command("rentals:close-overdue")]
pub async fn close_overdue_rentals(
/// Hours past the due time before a rental counts as overdue.
#[arg(long, default_value_t = 2)]
grace_hours: i64,
console: &mut Console,
) -> laravel::Result<()> {
// ...find and update the overdue rentals...
console.success(format!("Closed overdue rentals (grace: {grace_hours}h)."));
Ok(())
}
laravel rentals:close-overdue --grace-hours=4
laravel rentals:close-overdue --help
A command can also take services with Inject<T> and config with Section<T>, just as a PHP command’s handle method gets dependencies injected.