Sajid Bashir
Sajid Bashir

Reputation: 36

Unable to create Controller and model in php laravel framework

I am new at php laravel framework.

how model and controller are created through composer? phr write the commands to create model and controller.

Upvotes: 2

Views: 644

Answers (3)

Kevin Pimentel
Kevin Pimentel

Reputation: 1916

You would use artisan not composer. To view all the commands you can run:

php artisan list

To make a controller and model you can run:

php artisan make:model -c Awesome

This will generate a Controller named AwesomeController.php file in your Http\Controllers\ directory. It will also generate a Model named Awesome.php in the App directory by default.

Upvotes: 3

Zia Ur Rehman
Zia Ur Rehman

Reputation: 116

Try:

php artisan make:model Test -mcr

This command will create Model User, migration User, Controller User with resources.

Upvotes: 0

user6478676
user6478676

Reputation:

To create a model just run in console
php artisan make:model <model name> (e. g. `php artisan make:model Test)

To create a controller
php artisan make:controller <controller name> (e. g. php artisan make:controller TestController)
You can also change a path where to create a new class:
php artisan make:controller NewFolder/Test

Upvotes: 2

Related Questions