Laravel 5.2 RethinkDB服务提供程序阻止创建迁移文件

时间:2016-01-08 19:33:05

标签: laravel-5 laravel-5.2 laravel-migrations

我按照安装来安装此服务提供程序,但每次尝试创建迁移文件时都会出现此错误:

  [ErrorException]
  Argument 2 passed to duxet\Rethinkdb\Console\Migrations\MigrateMakeCommand::__construct() must be an instance
   of Illuminate\Foundation\Composer, instance of Illuminate\Support\Composer given, called in D:\projects\app\vendor\duxet\laravel-rethinkdb\src\RethinkdbServiceProvider.php on line 41 and defined

我在第41行,可以看到第二个参数是$composer,等于$composer = $app['composer'];。我想也许将Illuminate\Support\Composer更改为Illuminate\Foundation\ServiceProvider可能只是解决问题,但这样做会引发另一个错误:

[Symfony\Component\Debug\Exception\FatalErrorException]
Class 'Illuminate\Foundation\ServiceProvider' not found

遇到此问题的任何人?

更新

原始错误发生的地方(我标记为第41行):

<?php

namespace duxet\Rethinkdb;

use duxet\Rethinkdb\Console\Migrations\MigrateMakeCommand;
use duxet\Rethinkdb\Eloquent\Model;
use duxet\Rethinkdb\Migrations\MigrationCreator;
use Illuminate\Support\ServiceProvider;

class RethinkdbServiceProvider extends ServiceProvider
{
    /**
     * Bootstrap the application events.
     *
     * @return void
     */
    public function boot()
    {
        Model::setConnectionResolver($this->app['db']);
        Model::setEventDispatcher($this->app['events']);
    }

    /**
     * Register the service provider.
     *
     * @return void
     */
    public function register()
    {
        $this->app->resolving('db', function ($db) {
            $db->extend('rethinkdb', function ($config) {
                return new Connection($config);
            });
        });

        $this->app->singleton('command.rethink-migrate.make', function ($app) {

            $creator = new MigrationCreator($app['files']);
            $composer = $app['composer'];

            return new MigrateMakeCommand($creator, $composer); <= line 41
        });

        $this->commands('command.rethink-migrate.make');
    }

    public function provides()
    {
        return ['command.rethink-migrate.make'];
    }
}

MigrateMakeCommand类:

<?php

namespace duxet\Rethinkdb\Console\Migrations;

use duxet\Rethinkdb\Migrations\MigrationCreator;
use Illuminate\Database\Console\Migrations\MigrateMakeCommand as LaravelMigration;
use Illuminate\Foundation\Composer;

class MigrateMakeCommand extends LaravelMigration
{
    /**
     * The console command signature.
     *
     * @var string
     */
    protected $signature = 'make:rethink-migration {name : The name of the migration.}
        {--create= : The table to be created.}
        {--table= : The table to migrate.}
        {--path= : The location where the migration file should be created.}';

    /**
     * Create a new migration install command instance.
     *
     * @param duxet\Rethinkdb\Migrations\MigrationCreator $creator
     * @param \Illuminate\Foundation\Composer             $composer
     *
     * @return void
     */
    public function __construct(MigrationCreator $creator, Composer $composer)
    {
        parent::__construct($creator, $composer);
    }
}

0 个答案:

没有答案