Laravel Artisan How To Make Controller

Mark Caggiano
2 min readFeb 21, 2022

Do you need to make a new controller in Laravel ? It is very simple, just run this command:

php artisan make:controller MyCustomController

And that’s it ! This will create an empty controller in directory app/Http/Controllers with no methods

But I need more methods

That is why you can make a resource controller, a controller who has all required methods to process your logic and your data, like: store, update, create, index, delete, ecc… Just run this command:

php artisan make:controller MyCustomController -r

This will make a controller in app/Http/Controllers with all required methods, like this:

<?phpnamespace App\Http\Controllers;use Illuminate\Http\Request;class MyCustomController extends Controller
{
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
//
}
/**
* Show the form for creating a new resource.
*
* @return \Illuminate\Http\Response
*/
public function create()
{
//
}
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{

}
/**
* Display the specified resource.
*
* @param int $id
* @return

--

--

Mark Caggiano
Mark Caggiano

Written by Mark Caggiano

Internet Marketer, Web Developer, Traveler

No responses yet