1

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

  [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\ComposerIlluminate\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);
    }
}
4

0 回答 0