Add a flag to skip database connection

Merged
SW
4d ago
+112-5

Summary

Supporting vite-plugin-wayfinder PR

wayfinder:generate looks up route model binding types from the database schema. In private cloud build environments the database is not reachable, and Laravel retries the connection after it times out. Each distinct model therefore blocks for twice the connection timeout. A generate that should take about a minute can hang for more than 30 minutes.

This adds a --model-docblocks option. When it is set, binding types are read from the Eloquent model's @property docblocks and the schema query is skipped, so generation never opens a database connection. Without the flag, behavior is unchanged: Wayfinder still queries the schema and falls back to the docblock only if that query throws.

php artisan wayfinder:generate --model-docblocks

The flag is applied before both actions and named routes are written, so actions/ and routes/ stay consistent. --skip-actions and --skip-routes are unaffected.

Test plan

  • Generate without the flag against a model whose id column is an integer and confirm the parameter type is number
  • Generate again with --model-docblocks for a model whose docblock says @property string $id and confirm the parameter type is string
  • Run vendor/bin/phpunit