Home / Laravel / The artisan dev Command in Laravel 13.16.0

The artisan dev Command in Laravel 13.16.0

The Laravel team released v13.16.0 with a new artisan dev command for running your development processes, an enum-aware request helper, a withCookies() method on all responses, and an array-based maintenance mode driver for parallel testing.

  • php artisan dev command to run server, queue, logs, and Vite concurrently
  • whenFilledEnum() method on requests for typed enum handling
  • withCookies() promoted from redirects to all response types
  • An array maintenance mode driver for parallel testing

What’s New

The artisan dev Command

The release adds a php artisan dev command that runs your development processes (server, queue worker, log tailing, and Vite) concurrently. By default its behavior matches the existing composer dev script, but it moves the configuration into your application code instead of composer.json.

Commands are registered through the DevCommands class, typically from a service provider. You can add Artisan commands or arbitrary shell commands to the set:

use IlluminateFoundationConsoleDevCommands;
 
DevCommands::artisan('reverb:start');
DevCommands::register('stripe listen --forward-to ' . config('app.url'));

An optional second argument names the process; otherwise the name is the first segment before the first space. You can also assign a color per process:

DevCommands::artisan('reverb:start', 'reverb')->orange();
DevCommands::register('stripe listen --forward-to ' . config('app.url'))->green();

DevCommands prevents packages in the vendor directory from registering commands automatically. A package can still expose a helper that registers commands from your own code. The PR also adds a NodePackageManager helper that detects the package manager from the lockfiles present (npm, yarn, pnpm, or bun) so a generic command resolves to the right runner. See #60412.

Note: upgrade to v13.16.1, which has a fix for registering artisan dev command.

whenFilledEnum() Request Method

The InteractsWithData trait gains a whenFilledEnum() method that converts a request value to a backed enum before invoking the callback. Previously this meant calling whenFilled(), then tryFrom(), then a null check by hand:

$request->whenFilledEnum('status', Status::class, function (Status $status) use ($query): void {
$query->where('status', $status);
});

The callback runs only when the key is filled, the given class is a backed enum, and the value casts to a valid case via tryFrom(). Invalid values are skipped without throwing. An optional default callback runs when the primary callback does not:

$request->whenFilledEnum('status', Status::class, function (Status $status) use ($query): void {
$query->where('status', $status);
}, function () use ($query): void {
$query->where('status', Status::Active);
});

See #60486.

withCookies() on All Responses

The withCookies() method moves from RedirectResponse to ResponseTrait, so you can attach multiple cookies to any response type, including JsonResponse and standard responses, in a single call rather than chaining withCookie():

return response()->json($data)->withCookies([$cookieA, $cookieB, $cookieC]);

The change is additive and non-breaking. See #60503.

array Maintenance Mode Driver

A new array-based maintenance mode driver joins the existing file and cache drivers. It is aimed at parallel testing, where the file driver and Cache facade mocking can trip up tests that call php artisan up and down. See #60489.

Enums in broadcastAs()

Broadcast events can now return an enum from broadcastAs() for the event name. Paired with a typed SDK generator, this keeps event names consistent on both the sending and receiving sides, matching how the #[Queue()] attribute already supports enums. See #60483.

JSON Schema anyOf and Safer Deserialization

The JsonSchema component adds anyOf support, and the deserializer is now guarded against unbounded $ref expansion to prevent runaway recursion. See #60509 and #60517.

Other Fixes and Improvements

  • Fixed shell quoting when scheduled commands run as another user (#60469)
  • Allowed RouteParameter to use the attributed parameter name (#60465)
  • Fixed Batchable::batching for finished batches (#60511)
  • Added support for queue attributes on traits (#60519)
  • Hardened HTTP client request and fake response serialization (#60522)
  • Improved return types across model scopes, connection callbacks, and callback-passthrough helpers (#60481, #60484, #60500, #60513)

References

Source: https://laravel-news.com

Tagged:

Leave a Reply

Your email address will not be published. Required fields are marked *