Skip to content
Advertisement

InvalidArgumentException when creating model through artisan

I am new to Laravel and is encountering a problem when I start a new laravel project.
My current environment is: PHP 7.4.14 on Linux (Manjaro) & Composer 2.0.9.

I use the following command to initialize a laravel project:

composer create-project --prefer-dist laravel/laravel lara "5.x"

Then I switch to the directory of lara and type:

./artisan make:controller ArticleController --resource -model=Article

And then, I got an InvalidArgumentException: Model name contains invalid characters.

   InvalidArgumentException  : Model name contains invalid characters.

  at $HOME/WS/php/lara/vendor/laravel/framework/src/Illuminate/Routing/Console/ControllerMakeCommand.php:159
155|      */
156|     protected function parseModel($model)
157|     {
158|         if (preg_match('([^A-Za-z0-9_/\\])', $model)) {
159|             throw new InvalidArgumentException('Model name contains invalid characters.');
160|         }
161| 
162|         $model = trim(str_replace('/', '\', $model), '\');
163| 

I am confused and dunno what I have done wrong so I would like to seek your helps. Thank you very much in advance.

Advertisement

Answer

php artisan make:controller PhotoController --resource --model=Photo

it should be “–model”. The parameters are prefixed with double “-“!

More

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement