Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error in make controller in laravel

Tags:

laravel

I want learn larvel please help.

Using laravel version 5.0.16.

php artisan make:controller Admin\Controller --resource

It shows this error:

[RuntimeException] The "--resource" option does not exist.

What is the problem?

What is different between?

php artisan make:controller Admin\Controller --resource

php artisan make:controller Admin\Controller --plain

php artisan make:controller Admin\Controller
like image 329
Mohammad Ibrahim hussaini Avatar asked Jun 07 '17 05:06

Mohammad Ibrahim hussaini


People also ask

What is error handling in Laravel?

Laravel makes it easy to display custom error pages for various HTTP status codes. For example, if you wish to customize the error page for 404 HTTP status codes, create a resources/views/errors/404.blade.php view template. This view will be rendered on all 404 errors generated by your application.

How to handle Exception in Laravel api?

Error Handler As you can see there, we add so many exceptions inside the handleException() function. By default, the handleException() function doesn't exist, so you must modify the render() function to use the handleException(). You can add as many exceptions as you want inside this function.

What does controller do in laravel?

A Controller is that which controls the behavior of a request. It handles the requests coming from the Routes. In Laravel, a controller is in the 'app/Http/Controllers' directory. All the controllers, that are to be created, should be in this directory.


1 Answers

1st of all --resource does not exist in 5.0 and don't use / in controller name as you write above Admin/Controller make it as AdminController

Short

Now in Laravel 5.2 make:controller command creates plain controller, if you want to make resource controller you need to add --resource

Resource Controller

Resource controller gives four built-in methods of CRUD with routes as well, for example you run:

php artisan make:controller AdminController --resource

Then the routes can be registered as:

Route::resource('admin', 'AdminController');

It will give you four methods.

Create Retrieve Update Delete

Laravel resource routing assigns the typical "CRUD" routes to a controller with a single line of code.

Plain Controller and without --plain.

Before, Laravel 5.2 --plain was used to make a simple controller without builtin routes and methods. Now:

php artisan make:controller AdminController

Works the same as --plain.

Reference: https://laravel.com/docs/5.4/controllers

like image 188
Ramzan Mahmood Avatar answered Sep 22 '22 13:09

Ramzan Mahmood