Laravel Tutorials

Exclude Vendor and Default Commands in `php artisan dev`

Published
Exclude Vendor and Default Commands in `php artisan dev` image

The php artisan dev command starts your development processes in one command. Those processes include framework defaults, vendor packages via a service provider, and the application.

In Laravel 13.30, we get two new methods for the DevCommands class, which allow you to opt out of vendor and default commands:

use Illuminate\Foundation\DevCommands;

DevCommands::withoutVendorCommands();
DevCommands::withoutDefaultCommands();

This gives you complete control over what runs and locks everything down to whatever you define:

namespace App\Providers;

use Illuminate\Foundation\DevCommands;
use Illuminate\Support\ServiceProvider;

class AppServiceProvider extends ServiceProvider
{
    public function boot(): void
    {
        DevCommands::withoutVendorCommands();
        DevCommands::withoutDefaultCommands();

        DevCommands::artisan('serve', 'server');
        DevCommands::artisan('queue:work --queue=notifications', 'queue:notifications');
        DevCommands::node('dev', 'vite');
    }
}

You can also get more granular, using only() and except(). Let's say that you don't want to allow any vendor commands, but you want everything from the framework except logs:

DevCommands::withoutVendorCommands();
DevCommands::except('logs');

Default Commands

The default commands come from the framework's registerDefaults() and registers four processes at the time of writing:

  • server
  • queue
  • logs (when pcntl_fork() exists)
  • vite, (when the project has a package.json)

Checking the List

If you want to see which processes will run, you can use the dev:list command:

php artisan dev:list

  server php artisan serve .................................. Illuminate\Foundation\Providers\ArtisanServiceProvider@boot
  queue  php artisan queue:listen --tries=1 --timeout=0 ..... Illuminate\Foundation\Providers\ArtisanServiceProvider@boot
  logs   php artisan pail --timeout=0 ....................... Illuminate\Foundation\Providers\ArtisanServiceProvider@boot
  vite   npm run dev ........................................ Illuminate\Foundation\Providers\ArtisanServiceProvider@boot

Using the --json flag gives you JSON output, which could be helpful for agents:

php artisan dev:list --json | jq
[
  {
    "command": "php artisan serve",
    "name": "server",
    "color": "#93c5fd",
    "source": "Illuminate\\Foundation\\Providers\\ArtisanServiceProvider@boot",
    "priority": 0
  },
  {
    "command": "php artisan queue:listen --tries=1 --timeout=0",
    "name": "queue",
    "color": "#c4b5fd",
    "source": "Illuminate\\Foundation\\Providers\\ArtisanServiceProvider@boot",
    "priority": 0
  },
  {
    "command": "php artisan pail --timeout=0",
    "name": "logs",
    "color": "#fb7185",
    "source": "Illuminate\\Foundation\\Providers\\ArtisanServiceProvider@boot",
    "priority": 0
  },
  {
    "command": "npm run dev",
    "name": "vite",
    "color": "#fdba74",
    "source": "Illuminate\\Foundation\\Providers\\ArtisanServiceProvider@boot",
    "priority": 0
  }

To learn more, check out the Artisan Dev Command docs. Opting out of default and vendor dev commands was contributed by Jack Bayliss in #61344 and part of the Laravel 13.30 release.

Paul Redmond photo

Staff writer at Laravel News. Full stack web developer and author.

Sponsored

serpapi logo
SerpApi

The Web Search API for Your LLM and AI Applications

Visit SerpApi

The latest

View all →
Slow Job Alerts and Replica Commit IDs in Laravel 13.40 image

Slow Job Alerts and Replica Commit IDs in Laravel 13.40

Read article
Flock: A Free, Native Herd Alternative for Laravel image

Flock: A Free, Native Herd Alternative for Laravel

Read article
Live Props for Real-Time Updates in Inertia.js v3.11 image

Live Props for Real-Time Updates in Inertia.js v3.11

Read article
Cooldown Dependency Policy now in Composer 2.11 image

Cooldown Dependency Policy now in Composer 2.11

Read article
Email Sending and Testing for Laravel in One Account image

Email Sending and Testing for Laravel in One Account

Read article
Decide with Jev: Tie Every AI Check to the Exact Draft image

Decide with Jev: Tie Every AI Check to the Exact Draft

Read article