11

I'm trying to create a resource controller by executing the following command

php artisan controller:make ImageController

but I'm having this error

[Symfony\Component\Console\Exception\CommandNotFoundException]
  There are no commands defined in the "controller" namespace.

What is wrong?

1
  • It can be treated as a typo error . Commented Feb 11, 2016 at 3:39

2 Answers 2

26

Its a small mistake.

Change your code from:

php artisan controller:make ImageController

to

php artisan make:controller ImageController
Sign up to request clarification or add additional context in comments.

5 Comments

the code created empty resource controller, <?php namespace App\Http\Controllers; use Illuminate\Http\Request; use App\Http\Requests; use App\Http\Controllers\Controller; class ImageController extends Controller { // }
Do you want some boiler plate code also along with that?
I'm afraid that option is deprecated now. php artisan make:controller SampleController --plain is the one used to create blank controller, but now it seems its creating blank controllers by default. But you can always create your own functions like public function index() { }
This solution works but is this a change in documentation as there are posts which say "php artisan controller:make ImageController"
@isoCurator: Its a change from L5 and above.
0

Just type the following command

php artisan make:controller Admin/MaterialController --resource

This Command generates the following resource controller

<?php

namespace App\Http\Controllers\Admin;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;

class MaterialController 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 \Illuminate\Http\Response
 */
public function show($id)
{
    //
}

/**
 * Show the form for editing the specified resource.
 *
 * @param  int  $id
 * @return \Illuminate\Http\Response
 */
public function edit($id)
{
    //
}

/**
 * Update the specified resource in storage.
 *
 * @param  \Illuminate\Http\Request  $request
 * @param  int  $id
 * @return \Illuminate\Http\Response
 */
public function update(Request $request, $id)
{
    //
}

/**
 * Remove the specified resource from storage.
 *
 * @param  int  $id
 * @return \Illuminate\Http\Response
 */
public function destroy($id)
{
    //
}
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.