【问题标题】:Laravel 5.4 migrate:generate fails with Way\Generators\Filesystem\FileNotFound errorLaravel 5.4 迁移:生成失败并出现 Way\Generators\Filesystem\FileNotFound 错误
【发布时间】:2017-07-16 00:33:11
【问题描述】:

我正在尝试在 Laravel 5.4 项目中使用Xethron/migrations-generator,以便为我的数据库中的所有表生成迁移文件。我完全按照 Laravel 5 的 README 文件中的说明进行操作。解决一两个投诉后(必须安装 php7.0-xml 扩展),我尝试运行它,但它会吐出如下错误:

$ php artisan migrate:generate
Using connection: mysql

Generating migrations for: group_product_assoc, groups, product_hierarchy_assoc, product_product_assoc, products, replist, sessionsOLD, stores, tree, users, zipcode_coordinates

 Do you want to log these migrations in the migrations table? [Y/n] :
 > n

Setting up Tables and Index Migrations


  [Way\Generators\Filesystem\FileNotFound]                                               
  /var/www/my-project/vendor/way/generators/src/Way/Generators/templates/migration.txt  

我已在 github 上将此 issue 报告给 Xethron,显然我不是唯一遇到此问题的人。

谁能告诉我如何让它工作?我对 Laravel 或 Composer 不是特别流利,所以请不要吝啬基本的解释。我正在使用:

  • Ubuntu 16.04
  • PHP 7.0.15
  • Laravel 5.4

【问题讨论】:

    标签: php laravel laravel-5.4 laravel-migrations


    【解决方案1】:

    此问题已解决,只需运行composer update 即可获取最新版本。

    对给您带来的不便深表歉意。

    【讨论】:

      【解决方案2】:

      J。据我所知,Doe 的回答基本上是正确的。我在此处发布了一个更完整的解决方案,以描述我为解决该问题所采取的具体步骤。

      显然,Xethron 代码有问题,因为它试图引用一个 PHP 模板文件,而该文件在某种程度上没有被 Xethron 包正确包含/要求。我的短期解决方案似乎奏效了。该解决方案是首先 cd 进入工作目录:

      cd /var/www/my-project
      

      然后创建文件所在的目录:

      mkdir -p vendor/way/generators/src/Way/Generators/templates
      

      然后我们以两种方式之一将模板文件放入其中。正如 J. Doe 所建议的那样,一种方法是从 github (https://raw.githubusercontent.com/Xethron/Laravel-4-Generators/master/src/Way/Generators/templates/migration.txt) 下载文件并将其保存为 migration.txt 在我们刚刚在上面创建的目录中。或者您可以 cd 进入工作目录并执行以下命令:

      curl https://raw.githubusercontent.com/Xethron/Laravel-4-Generators/master/src/Way/Generators/templates/migration.txt > vendor/way/generators/src/Way/Generators/templates/migration.txt
      

      另一种方法是复制显然在 xethron 包的子目录中的模板文件:

      cp vendor/xethron/laravel-4-generators/src/Way/Generators/templates/migration.txt vendor/way/generators/src/Way/Generators/templates/migration.txt
      

      一旦文件存在于该位置,您应该能够顺利再次运行该命令:

      php artisan migrate:generate
      

      【讨论】:

        【解决方案3】:

        我遇到了同样的问题。您需要将以下文件复制到该位置:

        https://github.com/Xethron/Laravel-4-Generators/tree/master/src/Way/Generators/templates/migration.txt

        在这个文件夹中(有可能,它不存在 - 所以您可以创建文件夹或更改供应商 Xethron 中的配置文件(config.php)

        /var/www/my-project/vendor/way/generators/src/Way/Generators/templates/

        【讨论】:

        • @j-doe 供应商目录中不存在方式目录。好像缺少一个完整的包裹
        • 没错。它是为“laravel 4”创建的,因此不存在依赖项。因此,如果您想让它工作,请按照上面的说明进行操作。
        猜你喜欢
        • 2021-10-20
        • 2020-05-13
        • 2017-07-26
        • 2017-06-23
        • 1970-01-01
        • 2021-08-10
        • 1970-01-01
        • 2013-05-30
        • 2018-12-06
        相关资源
        最近更新 更多