tighten / ziggy

Use your Laravel routes in JavaScript.
MIT License
3.91k stars 248 forks source link

Manual script generation at Script format cause ArgumentCountError #598

Closed MuriloChianfa closed 1 year ago

MuriloChianfa commented 1 year ago

Ziggy version

v1.5

Laravel version

v7.30.6

Description

When i run the ziggy:generate command with Script output format, an error occurres:

Screenshot from 2022-11-27 12-44-28

To resolve, i remove manually the two parameters of script in vendor folder, $function and $nonce from __construct.

With default output and MergeScript format does not occures errors, only with Script format.

I can contribute with the project if it was a bug really, if you can test i would appreciate it.

Ziggy call and context

Runned command: php artisan ziggy:generate

Ziggy configuration

Config file "ziggy.php":

<?php

use Tightenco\Ziggy\Output\File;
use Tightenco\Ziggy\Output\Script;
use Tightenco\Ziggy\Output\MergeScript;

return [

    /*
    |--------------------------------------------------------------------------
    | Routes output format
    |--------------------------------------------------------------------------
    |
    | Select the output of the routes scripts.
    | Can be: File::class, MergeScript::class, Script::class
    |
    */

    'output' => [
        'file' => Script::class
    ],

    /*
    |--------------------------------------------------------------------------
    | Exclude routes from frontend
    |--------------------------------------------------------------------------
    |
    | Exclude routes from frontend to not expose sensible routes.
    | Examples: _debugbar.*, admin.*
    |
    */

    'except' => ['debugbar.*', 'passport.*', 'oauth.*', 'ignition.*'],

];

Route definition

N/A
MuriloChianfa commented 1 year ago

maybe we can add some tests running this commands to ensure the success case.

bakerkretzmar commented 1 year ago

The File/Script/MergeScript output classes included with Ziggy are not interchangeable. If you want to customize the output of the ziggy:generate command you should create your own new output formatter class and configure ziggy.output.file to use it. Let me know if that makes sense and if you have any questions about implementing your own formatter!

MuriloChianfa commented 1 year ago

this is very relevant to me because I use vanilla javascript, I believe that at least you could describe better in the README how to make and configure these custom formats.

bakerkretzmar commented 1 year ago

The default file output from php artisan ziggy:generate is vanilla javascript, what exactly did you want to change about it? What are you trying to do?