Laravel 5 和方式/生成器

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/28501117/
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 10:55:43  来源:igfitidea点击:

Laravel 5 and way/generators

phplaravelway-generators

提问by Sr?an Markovi?

I try to include way/generatorsto laravel 5.0

我尝试包含way/generatorsLaravel 5.0

I follow these steps:

我按照以下步骤操作:

  1. I include it into require dev: require way/generators --dev
  1. 我把它包括在 require dev: require way/generators --dev
"require-dev": {
    "phpunit/phpunit": "~4.0",
    "phpspec/phpspec": "~2.1,
    "way/generators" : "~3.0"
},
  1. I do composer update, also I try with composer update --dev

  2. I add a new item to the providers array.

  1. 我愿意composer update,我也试试composer update --dev

  2. 我向 providers 数组添加了一个新项目。

'Way\Generators\GeneratorsServiceProvider'
  1. now when I type: php artisanin console I got error

    exception 'BadMethodCallException' with message 'Call to undefined method [package]' in C:\xampp\htdocs\testni\storage\framework\compiled.php:4351 Stack trace:

  1. 现在,当我输入:php artisan在控制台中时出现错误

    在 C:\xampp\htdocs\testni\storage\framework\compiled.php:4351 堆栈跟踪中带有消息“调用未定义的方法 [包]”的异常“BadMethodCallException”:

回答by odin88

For Laravel 5 Jeffrey Way already created Laravel 5 Extended Generators.

对于 Laravel 5,Jeffrey Way 已经创建了 Laravel 5 Extended Generators。

https://github.com/laracasts/Laravel-5-Generators-Extended

https://github.com/laracasts/Laravel-5-Generators-Extended

You can even see it in action in Laracasts website.

你甚至可以在 Laracasts 网站上看到它的运行情况。

https://laracasts.com/lessons/faster-workflow-with-generators

https://laracasts.com/lessons/faster-workflow-with-generators

It is still using php artisan command but so far there are 3 additional methods like

它仍在使用 php artisan 命令,但到目前为止还有 3 种其他方法,例如

  • mmake:migration:schema
  • make:migration:pivot
  • make:seed
  • 制作:迁移:架构
  • 制作:迁移:枢轴
  • 制作:种子

To install - composer require laracasts/generators --dev

安装 - composer 需要 laracasts/generators --dev

回答by tplaner

Directly from the GitHub readme.mdfor JeffreyWay/Laravel-4-Generators:

直接从 GitHubreadme.md获取JeffreyWay/Laravel-4-Generators

There is no support for Laravel 5, as the framework now includes a number of generators out of the box.

不支持 Laravel 5,因为该框架现在包含许多开箱即用的生成器。

回答by Dimitri Acosta

Generators included in laravel 5 are very useful now so maybe you shouldn't worry about that, just type in php artisanto see the full list of them, they are under the make section

laravel 5 中包含的生成器现在非常有用,所以也许你不应该担心,只需输入php artisan以查看它们的完整列表,它们在 make 部分下

回答by shervin

composer require laracasts/generators --dev

composer require laracasts/generators --dev



Add this to config/app.php

将此添加到 config/app.php



'Laracasts\Generators\GeneratorsServiceProvider',

'Laracasts\Generators\GeneratorsServiceProvider',