Laravel 4 - 如何使用其方法生成控制器

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/18522918/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 08:21:08  来源:igfitidea点击:

Laravel 4 - How to generate a controller with its methods

phplaravelcode-generationlaravel-4

提问by Hakim

I'm using Jeffrey WayGeneratorto generate my controller, but in Laravel 4's version, I cant find a way to generate a controller with its list of methods.

我正在使用Jeffrey WayGenerator来生成我的控制器,但是在Laravel 4的版本中,我找不到一种方法来生成带有方法列表的控制器。

This command: php artisan generate:controller, gives me a controller with a predefined template, but I want to declare these methods on my own.

这个命令:php artisan generate:controller,给了我一个带有预定义模板的控制器,但我想自己声明这些方法。

回答by Lead Developer

Go to the project route directory in Command prompt

在命令提示符下转到项目路径目录

cd c:\xampp\htdocs\ProjectName

then run the command php artisan controller:make XYZController

然后运行命令 php artisan controller:make XYZController

like this

像这样

c:\xampp\htdocs\ProjectName>php artisan controller:make XYZController

now it will creates a controller with the name XYZController.php in your Controllers folder i.e

现在它将在您的 Controllers 文件夹中创建一个名为 XYZController.php 的控制器,即

c:\xampp\htdocs\ProjectName\app\controllers\XYZController.php

njoy!!.

开心!!

回答by J.T. Grimes

Looking at the source, it doesn't appear that the Generator package currently does this. You might send a feature request: https://github.com/JeffreyWay/Laravel-4-Generators/issues

查看源代码,Generator 包当前似乎没有执行此操作。您可以发送功能请求:https: //github.com/JeffreyWay/Laravel-4-Generators/issues