Skip to content

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

@ruttydm

Description

@ruttydm

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions