ziggy:generate rebases absolute output paths under base_path() instead of writing to the requested location

Open Beginner friendly
#882 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
78/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Quiet
Tech stack
laravel, php
Domain
cli

Research direction

Start by reading src/CommandRouteGenerator.php and trace the ziggy:generate handling for the main output, default name, and types paths. Reproduce the command with an absolute path, then verify that absolute locations are used as requested rather than rebased under the application base path.

Written by the indexing model from the issue text.

Description

I found a path-handling issue in tighten/ziggy v2.6.1.

ziggy:generate appears to wrap both the main output path and the types output path in base_path(...) unconditionally.

That means an absolute path like /tmp/ziggy.js is treated as relative to the Laravel app root instead of being written to /tmp/ziggy.js.

Repro

php artisan ziggy:generate /tmp/ziggy-audit-exists/ziggy.js

Expected output path:

/tmp/ziggy-audit-exists/ziggy.js

Actual output path:

<project root>/tmp/ziggy-audit-exists/ziggy.js

Expected

Absolute paths should be honored as-is.

Actual

Absolute paths are silently rebased under the application base path.

Why this matters

This is easy to miss in automation/CI scripts because the command succeeds, but the file is written to the wrong place.

Relevant code

  • src/CommandRouteGenerator.php
  • the base_path($path) / base_path("{$name}.js") / base_path($typesPath) calls
Dominant language
JavaScript
Stars
4.3k
Forks
273
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from tighten/ziggy

All issues in tighten/ziggy

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.