Create new controller laravel

To create a new controller in Laravel, you can use the following command:

php artisan make:controller ControllerName

Replace ControllerName with the name of the controller you want to create. For example, if you want to create a controller named UserController, you would run the following command:

php artisan make:controller UserController

This will create a new file in the app/Http/Controllers directory with the name UserController.php. The file will contain a basic controller class with a constructor and a __construct method.

You can also specify the namespace and the controller type (e.g., API controller) when creating a new controller:

php artisan make:controller --namespace=App\Http\Controllers\API UserController

This will create a new file in the app/Http/Controllers/API directory with the name UserController.php.

You can also use the make command with the --resource option to create a resource controller:

php artisan make:controller --resource UserController

This will create a new file in the app/Http/Controllers directory with the name UserController.php and will include the necessary methods for a resource controller (e.g., index, show, store, update, destroy).

Note: Make sure to update the routes.php file in the routes directory to include the new controller and its routes.