CakePHP 3 / Phinx исключение при запуске из CLI - PullRequest
0 голосов
/ 27 апреля 2018

У меня запущенный проект 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 / install даже dump-autoload, но ничего не изменилось.

Я не знаю, с чего начать отладку.

Стоит отметить, что я использую пользовательский обработчик ошибок как для интерфейса командной строки, так и для веб-интерфейса. Соответственно оба моих пользовательских обработчика ошибок расширяют свои соответствующие классы: \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
    }
}

1 Ответ

0 голосов
/ 27 апреля 2018

Похоже, ваши пакеты композитора вышли из синхронизации.

Для принудительного обновления удалите папку vendor, также удалите composer.lock и затем запустите

composer install

Он снова загрузит все, восстановит ваш поставщик и убедится, что Phinx и Symphony снова синхронизированы.

После того, как вы это сделаете, вы снова запустите миграцию и посмотрите, что произойдет.

Это ваше утверждение

«Я удалил все таблицы и надеялся, что он просто повторно запустит миграцию, как и раньше».

меня немного беспокоит, потому что менеджер миграции Phinx хранит свой журнал в базе данных в таблице с именем phinxlog (иногда с префиксом имени плагина, если вы говорите о плагине). Если вы удалили это, то phix не знает, какие миграции вы уже выполняли, а какие новые. Чтобы это исправить, вам может понадобиться отметить, что некоторые из предыдущих миграций были перенесены , поэтому phinx не пытается делать то, что уже было сделано.

...