sohelamin / crud-generator

Laravel CRUD Generator
https://packagist.org/packages/appzcoder/crud-generator
MIT License
1.41k stars 426 forks source link

Fail execute command crud:generate #242

Closed mfrancaleal closed 5 years ago

mfrancaleal commented 5 years ago

Message: Too many arguments, expected arguments "command" "name".

Command: php artisan crud:generate Fornecedores --fields_from_file="/resources/crudGenerator/fornecedorFields" --view-path=admin --controller-namespace=Admin --route-group=admin form-helper=html

My .json { "fields": [ { "name": "razao_social", "type": "string" }, { "name": "cnpj", "type": "text" }, { "name": "estado", "type": "select", "options": { "AC": "Acre", "AL": "Alagoas", "AP": "Amapá", "AM": "Amazonas", "BA": "Bahia", "CE": "Ceará", "DF": "Distrito Federal", "ES": "Espírito Santo", "GO": "Goiás", "MA": "Maranhão", "MT": "Mato Grosso", "MS": "Mato Grosso do Sul", "MG": "Minas Gerais", "PA": "Pará", "PB": "Paraíba", "PR": "Paraná", "PE": "Pernambuco", "PI": "Piauí", "RJ": "Rio de Janeiro", "RN": "Rio Grande do Norte", "RS": "Rio Grande do Sul", "RO": "Rondônia", "RR": "Roraima", "SC": "Santa Catarina", "SP": "São Paulo", "SE": "Sergipe", "TO": "Tocantins" } }, { "name": "cidade", "type": "text" }, { "name": "logradouro", "type": "select", "options": { "avenida": "Avenida", "alameda": "Alameda", "beco": "Beco", "rua": "Rua", "travessa": "Travessa", "viela": "Viela" } }, { "name": "complemento", "type": "text" }, { "name": "cep", "type": "text" }, { "name": "tel1", "type": "text" }, { "name": "tel2", "type": "text" }, { "name": "email", "type": "text" }, { "name": "responsavel", "type": "text" }, { "name": "user_id", "type": "integer#unsigned" } ], "validations": [ { "field": "responsavel", "rules": "required|max:15" }, { "field": "razao_social", "rules": "required|max:15" },{ "field": "email", "rules": "required|max:30" },{ "field": "complemento", "rules": "required|max:30" } ] }

What the problem? Thankyou.

marcosrocha85 commented 5 years ago

Message: Too many arguments, expected arguments "command" "name".

Command: php artisan crud:generate Fornecedores --fields_from_file="/resources/crudGenerator/fornecedorFields" --view-path=admin --controller-namespace=Admin --route-group=admin form-helper=html ....... What the problem? Thankyou.

I see three problems with you command. 1st. form-helper should have double dashes --form-helper 2nd. Is fornecedorFields a json? If so, you have to type fornecedorFields.json 3rd. If you type /resources php will try search from your system root directory, not from project folder. So your full correct command would be:

php artisan crud:generate Fornecedores --fields_from_file="resources/crudGenerator/fornecedorFields.json" --view-path=admin --controller-namespace=Admin --route-group=admin --form-helper=html

image

fredsvanelli commented 5 years ago

I've just performed a clean install of Laravel 5.8.10 (PHP 7.3.3)

I ran the following commands:

1) composer require appzcoder/crud-generator --dev

Using version ^3.0 for appzcoder/crud-generator
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 2 installs, 0 updates, 0 removals
  - Installing laravelcollective/html (v5.8.0): Downloading (100%)
  - Installing appzcoder/crud-generator (v3.0.8): Downloading (100%)
Writing lock file
Generating optimized autoload files
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover --ansi
Discovered Package: appzcoder/crud-generator
Discovered Package: beyondcode/laravel-dump-server
Discovered Package: fideloper/proxy
Discovered Package: laravel/tinker
Discovered Package: laravelcollective/html
Discovered Package: nesbot/carbon
Discovered Package: nunomaduro/collision
Package manifest generated successfully.

2) php artisan vendor:publish --provider="Appzcoder\CrudGenerator\CrudGeneratorServiceProvider".

Copied File [\vendor\appzcoder\crud-generator\config\crudgenerator.php] To [\config\crudgenerator.php]
Copied Directory [\vendor\appzcoder\crud-generator\publish\views] To [\resources\views]
Copied Directory [\vendor\appzcoder\crud-generator\src\stubs] To [\resources\crud-generator]
Publishing complete.

3) Created and connected the database on .env

4) Then I tryed to run the first example command without changing anything: php artisan crud:generate Posts --fields='title#string; content#text; category#select#options={"technology": "Technology", "tips": "Tips", "health": "Health"}' --view-path=admin --controller-namespace=Admin --route-group=admin --form-helper=html

Output:

Too many arguments, expected arguments "command" "name".

WhatsApp Image 2019-04-09 at 00 07 14

marcosrocha85 commented 5 years ago

The only thing I think could be is the type "select". I didn't used that type yet in my newest project.

nawt12 commented 5 years ago

replace ' 'to " " and than it will be work. for ex. php artisan crud:generate Students --fields="stdname#string; phone#string" --view-path=admin --controller-namespace=Admin --route-group=admin --form-helper=htm

marcosrocha85 commented 5 years ago

@nawt12 , did you tried to call that command with select#options in the parameters?

manuelvidales commented 5 years ago

is correct sometimes does not recognize ' ... '. will have to use " ... ".

marcosrocha85 commented 5 years ago

is correct sometimes does not recognize ' ... '. will have to use " ... ".

You're right. I've never used ' ... ' on my commands.

vince83110 commented 5 years ago

replace ' 'to " " and than it will be work. for ex. php artisan crud:generate Students --fields="stdname#string; phone#string" --view-path=admin --controller-namespace=Admin --route-group=admin --form-helper=htm

Replacing by double quotes worked for me on Laravel 5.8. Thanks.

BesmellahBassam commented 2 years ago

replace ' 'to " " and than it will be work. for ex. php artisan crud:generate Students --fields="stdname#string; phone#string" --view-path=admin --controller-namespace=Admin --route-group=admin --form-helper=htm

thanks,Your solution solved my problem