Phinx 迁移错误,"Could not find class" 但正在查找正确的文件?

Phinx migration error, "Could not find class" but looking in the correct file?

我正在尝试使用名为 'Vokuro' 的 Phalcon 框架示例项目的 phinx 库来 运行 数据库迁移,但出现此错误。文件目录是正确的,所以我不知道为什么会这样。

命令:

C:\xampp\htdocs\vokuro\vendor\bin>phinx.bat status -e development
Phinx by CakePHP - https://phinx.org.

using config file .\phinx.json
using config parser json
using migration paths
 - C:\xampp\htdocs\vokuro\db\migrations
using seed paths
 - C:\xampp\htdocs\vokuro\db\seeds
using environment development
ordering by creation time

In Manager.php line 742:

  Could not find class "CreateEmailConfirmations" in file "C:\xampp\htdocs\vokuro\vendor\bin\..\..\db\migrations190825181051_create_email_confirmations.php"

C:\xampp\htdocs\vokuro\db\migrations190825181051_create_email_confirmations.php:

<?php
declare(strict_types=1);

namespace Vokuro\Migrations;

use Phinx\Migration\AbstractMigration;

final class CreateEmailConfirmations extends AbstractMigration
{
    public function change(): void
    {
        $table = $this->table('email_confirmations');
        if ($table->exists()) {
            return;
        }

        $table->addColumn('usersId', 'integer')
            ->addColumn('code', 'char', ['limit' => 32])
            ->addColumn('createdAt', 'integer')
            ->addColumn('modifiedAt', 'integer', ['null' => true])
            ->addColumn('confirmed', 'char', ['limit' => 1, 'default' => 'N'])
            ->create();
    }
}

C:\xampp\htdocs\vokuro\vendor\robmorgan\phinx\src\Phinx\Migration\Manager.php:

// convert the filename to a class name
$class = ($namespace === null ? '' : $namespace . '\') . Util::mapFileNameToClassName(basename($filePath));

if (isset($fileNames[$class])) {
    throw new InvalidArgumentException(sprintf(
        'Migration "%s" has the same name as "%s"',
        basename($filePath),
        $fileNames[$class]
    ));
}

$fileNames[$class] = basename($filePath);

if ($this->getOutput()->getVerbosity() >= OutputInterface::VERBOSITY_DEBUG) {
    $this->getOutput()->writeln("Loading class <info>$class</info> from <info>$filePath</info>.");
}

// load the migration file
$orig_display_errors_setting = ini_get('display_errors');
ini_set('display_errors', 'On');
/** @noinspection PhpIncludeInspection */
require_once $filePath;
ini_set('display_errors', $orig_display_errors_setting);
if (!class_exists($class)) {
    throw new InvalidArgumentException(sprintf(
        'Could not find class "%s" in file "%s"',
        $class,
        $filePath
    ));
}

因为您使用的是自己的配置文件:

using config file .\phinx.json

而不是 phinx.php。该文件位于项目的根目录中。 https://github.com/phalcon/vokuro/blob/master/phinx.php

此文件中有 paths 键,它指定迁移和种子的命名空间。