我正在尝试通过执行以下命令来创建资源控制器
php artisan controller:make ImageController
但我有这个错误
[Symfony\Component\Console\Exception\CommandNotFoundException]
There are no commands defined in the "controller" namespace.
有什么问题?
答案 0 :(得分:24)
这是一个小错误。
更改您的代码:
php artisan controller:make ImageController
到
php artisan make:controller ImageController
答案 1 :(得分:0)
只需输入以下命令
即可php artisan make:controller Admin/MaterialController --resource
此命令生成以下资源控制器
<?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)
{
//
}
}