CrestApps / laravel-code-generator

An efficient Laravel code generator, saving time by automating the creation of resources such as views, controllers, routes, migrations, languages, and form-requests. Highly flexible and customizable, it includes a cross-browser compatible template and client-side validation for application modernization.
https://laravel-code-generator.crestapps.com
MIT License
738 stars 158 forks source link

Error on array_key_exists() expects parameter 2 to be array, null given #16

Closed larrydalaw closed 7 years ago

larrydalaw commented 7 years ago

When I Ran the php artisan create:fields-file [table name] at the first time it was perfectly good... php artisan create:fields-file ssDuty --translation-for=en,cn then php artisan create:resources SsService --fields-file=ssService.json --table-name=ssService --table-exists --translation-for=en,cn --primary-key=sid --with-soft-delete --without-migration --force So I wanted to re-do it again in a new environment using the same set of code and Table in a new laravel project and new mysql schema. However, I forgot to first require something like

bower install bootstrap#v4.0.0-alpha.6
bower install jquery
bower install jquery-validation
composer require "laravelcollective/html":"^5.4.0"

So it was not successful when i ran the same code above. So I installed them again and tried to run the same code but from this moment , the code returned the same error no matter what possibility i tried.

[ErrorException] array_key_exists() expects parameter 2 to be array, null given

please help

MikeAlhayek commented 7 years ago

I am not sure that I fully follow what your doing.

What version of Laravel are you using? What version of Laravel-code-generator are you using? Also, are you using the default template or the default-collective?

Additionally, can you please clean your Laravel log file, rerun your code? Then please paste the entire log so I can trace th problem.

It may also be helpful to post your SsServices structure to help reproducing the error

jesperhag commented 7 years ago

@larrydalaw I think that you might have forgotten to run php artisan vendor:publish --provider="CrestApps\CodeGenerator\CodeGeneratorServiceProvider" --tag=default before running the create:fields-file command. That would cause this error since the config file is not in place (more specifically the eloquent_type_to_method array is missing).

MikeAlhayek commented 7 years ago

@jesperhag thanks for your input. @larrydalaw did you fix your issue?

dogatonic commented 2 years ago

Check your package.json to see if it is valid JSON. For instance, if you have a dangling comma after the last item in a bracket set {}, like... "tailwindcss": "^3.0.18", } it can cause a problem when you run an artisan command. It can give you an error much like `ErrorException

array_key_exists() expects parameter 2 to be array, null given` A misplaced comma can confuse artisan into expecting one more thing.