0

我有一个正在运行的 CakePHP 3 项目,我在该项目上使用 Phinx 迁移。今天早上我只是更改了一个迁移文件,没有进行回滚,而是删除了所有表,并希望它会像以前一样重新运行迁移。所以当我发出这些命令时:

bin/cake migrations migrate
bin/cake migrations rollback
bin/cake migrations status

或与迁移相关的任何内容,我在 CLI 中抛出以下异常:

Exception: Argument 2 passed to Phinx\Migration\Manager::__construct() must
implement interface Symfony\Component\Console\Input\InputInterface, instance of
Symfony\Component\Console\Output\ConsoleOutput given, called in
/var/www/html/vendor/cakephp/migrations/src/ConfigurationTrait.php on line 191
in [/var/www/html/vendor/robmorgan/phinx/src/Phinx/Migration/Manager.php, line 89]

我试过重新运行composer update/ installeven dump-autoload,但没有任何改变。

我不知道从哪里开始调试这个。

值得一提的是,我对 CLI 和 Web 界面都使用了自定义错误处理程序。我的两个自定义错误处理程序分别扩展了它们的适当类:\Cake\Console\ConsoleErrorHandler\Cake\Error\ErrorHandler.

当我运行时,composer info我得到这个输出:

ajgl/breakpoint-twig-extension             0.3.1                     Twig extension to set breakpoints
aptoma/twig-markdown                       2.0.0                     Twig extension to work with Markdown content
asm89/twig-cache-extension                 1.3.2                     Cache fragments of templates directly within Twig.
aura/intl                                  3.0.0                     The Aura Intl package provides internationalization tools, specifically message trans...
cakephp/bake                               1.7.2                     Bake plugin for CakePHP 3
cakephp/cakephp                            3.6.1                     The CakePHP framework
cakephp/cakephp-codesniffer                3.0.3                     CakePHP CodeSniffer Standards
cakephp/chronos                            1.1.4                     A simple API extension for DateTime.
cakephp/debug_kit                          3.15.2                    CakePHP Debug Kit
cakephp/migrations                         1.3                       Database Migration plugin for CakePHP 3.0 based on Phinx
cakephp/plugin-installer                   1.1.0                     A composer installer for CakePHP 3.0+ plugins.
composer/ca-bundle                         1.1.1                     Lets you find a path to the system CA bundle, and includes a fallback to the Mozilla ...
composer/composer                          1.6.4                     Composer helps you declare, manage and install dependencies of PHP projects, ensuring...
composer/semver                            1.4.2                     Semver library that offers utilities, version constraint parsing and validation.
composer/spdx-licenses                     1.3.0                     SPDX licenses list and validation library.
crabstudio/recaptcha                       2.1.0                     Easily use Google Recaptcha in CakePHP 3.2+ projects
dnoegel/php-xdg-base-dir                   0.1                       implementation of xdg base directory specification for php
florianwolters/component-core-stringutils  v0.3.1                    Offers operations on the data type string as a PHP component.
florianwolters/component-util-reflection   v0.2.0                    Provides operations for the PHP Reflection API as a PHP component.
florianwolters/component-util-singleton    v0.3.2                    The Singleton (and Registry of Singletons a.k.a. Multiton) design pattern as a PHP co...
guzzlehttp/guzzle                          6.3.3                     Guzzle is a PHP HTTP client library
guzzlehttp/promises                        v1.3.1                    Guzzle promises library
guzzlehttp/psr7                            1.4.2                     PSR-7 message implementation that also provides common utility methods
jakub-onderka/php-console-color            0.1                      
jakub-onderka/php-console-highlighter      v0.3.2                   
jasny/twig-extensions                      v1.2.0                    A set of useful Twig filters
jdorn/sql-formatter                        v1.2.17                   a PHP SQL highlighting library
josegonzalez/dotenv                        2.1.0                     dotenv file parsing for PHP
justinrainbow/json-schema                  5.2.7                     A library to validate a json schema.
m1/env                                     2.1.0                     Env is a lightweight library bringing .env file parser compatibility to PHP. In short...
mnsami/composer-custom-directory-installer 1.1.1                     A composer plugin, to help install packages of different types in custom paths.
mobiledetect/mobiledetectlib               2.8.31                    Mobile_Detect is a lightweight PHP class for detecting mobile devices. It uses the Us...
nikic/php-parser                           v4.0.1                    A PHP parser written in PHP
predis/predis                              v1.1.1                    Flexible and feature-complete Redis client for PHP and HHVM
psr/http-message                           1.0.1                     Common interface for HTTP messages
psr/log                                    1.0.2                     Common interface for logging libraries
psy/psysh                                  v0.9.3                    An interactive shell for modern PHP.
robmorgan/phinx                            0.9.2                     Phinx makes it ridiculously easy to manage the database migrations for your PHP app.
seld/cli-prompt                            1.0.3                     Allows you to prompt for user input on the command line, and optionally hide the char...
seld/jsonlint                              1.7.1                     JSON Linter
seld/phar-utils                            1.0.1                     PHAR file format utilities, for when PHP phars you up
squizlabs/php_codesniffer                  3.2.3                     PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations of a d...
symfony/config                             v4.0.8                    Symfony Config Component
symfony/console                            v4.0.8                    Symfony Console Component
symfony/filesystem                         v4.0.8                    Symfony Filesystem Component
symfony/finder                             v4.0.8                    Symfony Finder Component
symfony/polyfill-mbstring                  v1.7.0                    Symfony polyfill for the Mbstring extension
symfony/polyfill-php72                     v1.7.0                    Symfony polyfill backporting some PHP 7.2+ features to lower PHP versions
symfony/process                            v4.0.8                    Symfony Process Component
symfony/var-dumper                         v4.0.8                    Symfony mechanism for exploring and dumping PHP variables
symfony/yaml                               v4.0.8                    Symfony Yaml Component
twig/twig                                  v1.35.3                   Twig, the flexible, fast, and secure template language for PHP
umpirsky/twig-php-function                 v0.1                      Call (almost) any PHP function from your Twig templates.
wyrihaximus/twig-view                      4.3.4                     Twig powered View for CakePHP3
zendframework/zend-diactoros               1.7.1                     PSR HTTP Message implementations

文件内容composer.json如下:

{
    "name": "cakephp/app",
    "description": "CakePHP skeleton app",
    "homepage": "https://cakephp.org",
    "type": "project",
    "license": "MIT",
    "require": {
        "php": ">=5.6",
        "cakephp/cakephp": "^3.5",
        "cakephp/migrations": "^1.8",
        "cakephp/plugin-installer": "^1.0",
        "crabstudio/recaptcha": "^2.0",
        "guzzlehttp/guzzle": "^6.3",
        "josegonzalez/dotenv": "2.*",
        "mobiledetect/mobiledetectlib": "2.*"
    },
    "require-dev": {
        "cakephp/bake": "^1.1",
        "cakephp/cakephp-codesniffer": "^3.0",
        "cakephp/debug_kit": "^3.2",
        "psy/psysh": "@stable"
    },
    "suggest": {
        "markstory/asset_compress": "An asset compression plugin which provides file concatenation and a flexible filter system for preprocessing and minification.",
        "dereuromark/cakephp-ide-helper": "After baking your code, this keeps your annotations in sync with the code evolving from there on for maximum IDE and PHPStan compatibility.",
        "phpunit/phpunit": "Allows automated tests to be run without system-wide install.",
        "cakephp/cakephp-codesniffer": "Allows to check the code against the coding standards used in CakePHP."
    },
    "autoload": {
        "psr-4": {
            "App\\": "src/"
        }
    },
    "autoload-dev": {
        "psr-4": {
            "App\\Test\\": "tests/",
            "Cake\\Test\\": "vendor/cakephp/cakephp/tests/"
        }
    },
    "scripts": {
        "post-install-cmd": "App\\Console\\Installer::postInstall",
        "post-create-project-cmd": "App\\Console\\Installer::postInstall",
        "post-autoload-dump": "Cake\\Composer\\Installer\\PluginInstaller::postAutoloadDump",
        "check": [
            "@test",
            "@cs-check"
        ],
        "cs-check": "phpcs --colors -p --standard=vendor/cakephp/cakephp-codesniffer/CakePHP ./src ./tests",
        "cs-fix": "phpcbf --colors --standard=vendor/cakephp/cakephp-codesniffer/CakePHP ./src ./tests",
        "test": "phpunit --colors=always"
    },
    "prefer-stable": true,
    "config": {
        "sort-packages": true
    }
}
4

1 回答 1

2

看起来您的作曲家包不同步。

要强制刷新删除vendor文件夹也删除composer.lock然后运行

composer install

它将再次下载所有内容,重建您的供应商并确保 Phinx 和 Symphony 再次同步。

完成此操作后,再次运行迁移并查看会发生什么。

你的这份声明

“我删除了所有表,并希望它会像以前一样重新运行迁移。”

我有点担心,因为 Phinx 迁移管理器将其日志保存在数据库中的一个名为的表中phinxlog(如果您正在谈论插件,有时会以插件名称为前缀)。如果您删除了它,那么 phix 不知道您已经运行了哪些迁移以及哪些迁移是新的。要解决此问题,您可能需要标记一些较早的迁移已迁移,以便 phinx 不会尝试执行已完成的操作。

于 2018-04-27T11:36:38.753 回答