Memo

メモ > 技術 > CMS: ECCube > プラグインの導入: プラグインを追加削除したときの挙動を検証

■プラグインの導入: プラグインを追加削除したときの挙動を検証
■composerの実行 「composer install」の代わりに「php bin/console eccube:composer:install」を実行する (ただし初回はこのコマンドもエラーになる。詳細は「プラグインを導入済みのECCubeをセットアップする場合」を参照)
$ php bin/console eccube:composer:install <warning>Deprecation warning: require.ec-cube/VeriTrans4G is invalid, it should not contain uppercase characters. Please use ec-cube/veritrans4g instead. Make sure you fix this as Composer 2.0 will error.</warning> [28.5MiB/0.03s] Loading composer repositories with package information [28.9MiB/0.04s] Installing dependencies (including require-dev) from lock file [29.8MiB/0.12s] Nothing to install or update [29.0MiB/0.14s] <warning>Package easycorp/easy-log-handler is abandoned, you should avoid using it. No replacement was suggested.</warning> [29.0MiB/0.14s] <warning>Package facebook/webdriver is abandoned, you should avoid using it. Use php-webdriver/webdriver instead.</warning> [29.0MiB/0.14s] <warning>Package phpunit/phpunit-mock-objects is abandoned, you should avoid using it. No replacement was suggested.</warning> [29.0MiB/0.14s] <warning>Package sensio/generator-bundle is abandoned, you should avoid using it. Use symfony/maker-bundle instead.</warning> [29.0MiB/0.14s] <warning>Package setasign/fpdi-tcpdf is abandoned, you should avoid using it. No replacement was suggested.</warning> [29.0MiB/0.14s] <warning>Package zendframework/zend-code is abandoned, you should avoid using it. Use laminas/laminas-code instead.</warning> [29.0MiB/0.14s] <warning>Package zendframework/zend-eventmanager is abandoned, you should avoid using it. Use laminas/laminas-eventmanager instead.</warning> [29.0MiB/0.14s] Generating optimized autoload files [33.1MiB/14.84s] <warning>Warning: Ambiguous class resolution, "Eccube\Entity\Customer" was found in both "$baseDir . '/app/proxy/entity/src/Eccube/Entity/Customer.php" and "/var/www/main/html/src/Eccube/Entity/Customer.php", the first will be used.</warning> [32.4MiB/19.45s] Memory usage: 32.43MiB (peak: 40.82MiB), time: 19.45s
実行できたら、以下でオートローダーを生成する
$ composer install Deprecation warning: require.ec-cube/VeriTrans4G is invalid, it should not contain uppercase characters. Please use ec-cube/veritrans4g instead. Make sure you fix this as Composer 2.0 will error. Loading composer repositories with package information Installing dependencies (including require-dev) from lock file Nothing to install or update Package easycorp/easy-log-handler is abandoned, you should avoid using it. No replacement was suggested. Package facebook/webdriver is abandoned, you should avoid using it. Use php-webdriver/webdriver instead. Package phpunit/phpunit-mock-objects is abandoned, you should avoid using it. No replacement was suggested. Package sensio/generator-bundle is abandoned, you should avoid using it. Use symfony/maker-bundle instead. Package setasign/fpdi-tcpdf is abandoned, you should avoid using it. No replacement was suggested. Package zendframework/zend-code is abandoned, you should avoid using it. Use laminas/laminas-code instead. Package zendframework/zend-eventmanager is abandoned, you should avoid using it. Use laminas/laminas-eventmanager instead. Generating optimized autoload files Deprecation Notice: Class Eccube\Entity\Customer located in ./app/proxy/entity/src/Eccube/Entity/Customer.php does not comply with psr-4 autoloading standard. It will not autoload anymore in Composer v2.0. in phar:///usr/local/bin/composer/src/Composer/Autoload/ClassMapGenerator.php:201 Warning: Ambiguous class resolution, "Eccube\Entity\Customer" was found 2x: in "/var/www/main/html/app/proxy/entity/src/Eccube/Entity/Customer.php" and "/var/www/main/html/src/Eccube/Entity/Customer.php", the first will be used. Carbon 1 is deprecated, see how to migrate to Carbon 2. https://carbon.nesbot.com/docs/#api-carbon-2 You can run './vendor/bin/upgrade-carbon' to get help in updating carbon and other frameworks and libraries that depend on it. ocramius/package-versions: Generating version class... ocramius/package-versions: ...done generating version class Executing script cache:clear --no-warmup [OK] Executing script cache:warmup --no-optional-warmers [OK] Executing script assets:install --symlink --relative html [OK]
■composer install の警告 上記のとおり、composerを実行する際にwarningがいくつも表示される …が、これは気にしなくてもいいみたい プラグインインストール時にcomposerのwarningが出力される - Issue #4106 - EC-CUBE/ec-cube https://github.com/EC-CUBE/ec-cube/issues/4106 「composer 2.0 より、パッケージ名に大文字の記述が利用できなくなるため。 ec-cube 4では、composerは1.xを利用するため、動作に支障はありません。 また、プラグインのコードも変更する必要はありません。」 ■プラグインの追加 プラグイン一覧画面で「オーナーズストアから新規追加」ボタンを押してプラグインのインストール画面に進むことができる プラグインをインストールすると、その情報が composer.json と composer.lock にも書き込まれる この状態ならプラグインの情報が残っているので、次回は以下のコマンドでプラグインをインストールできる
$ php bin/console eccube:composer:install
■プラグインの削除 ※VeriTrans4G を削除したときの挙動 プラグイン一覧画面で「削除」ボタンを押すと app/Plugin/VeriTrans4G が削除され、 dtb_plugin テーブルからもデータが削除された 以下は削除されたときのログ
[32.1MiB/0.00s] <warning>ec-cube/veritrans4g is not required in your composer.json and has not been removed</warning> [33.7MiB/0.68s] Loading composer repositories with package information [35.0MiB/4.23s] Updating dependencies (including require-dev) [311.2MiB/13.72s] <warning>Writing /var/www/main/html/app/Plugin/.composer/cache/repo/https---repo.packagist.org/provider-symfony$polyfill-ctype.json into cache failed after 3842048 of 4103821 bytes written, only 291899080704 bytes of free space available</warning> [433.8MiB/27.69s] Package operations: 0 installs, 0 updates, 1 removal [454.4MiB/32.67s] - Removing ec-cube/veritrans4g (1.2.0) [451.3MiB/32.72s] <warning>Package easycorp/easy-log-handler is abandoned, you should avoid using it. No replacement was suggested.</warning> [451.3MiB/32.72s] <warning>Package facebook/webdriver is abandoned, you should avoid using it. Use php-webdriver/webdriver instead.</warning> [451.3MiB/32.72s] <warning>Package phpunit/php-token-stream is abandoned, you should avoid using it. No replacement was suggested.</warning> [451.3MiB/32.72s] <warning>Package phpunit/phpunit-mock-objects is abandoned, you should avoid using it. No replacement was suggested.</warning> [451.3MiB/32.72s] <warning>Package sensio/generator-bundle is abandoned, you should avoid using it. Use symfony/maker-bundle instead.</warning> [451.3MiB/32.72s] <warning>Package setasign/fpdi-tcpdf is abandoned, you should avoid using it. No replacement was suggested.</warning> [451.3MiB/32.72s] <warning>Package zendframework/zend-code is abandoned, you should avoid using it. Use laminas/laminas-code instead.</warning> [451.3MiB/32.72s] <warning>Package zendframework/zend-eventmanager is abandoned, you should avoid using it. Use laminas/laminas-eventmanager instead.</warning> [451.5MiB/32.75s] Writing lock file [451.5MiB/32.75s] Generating optimized autoload files [454.2MiB/48.16s] <warning>Warning: Ambiguous class resolution, "Eccube\Entity\Customer" was found in both "$baseDir . '/app/proxy/entity/src/Eccube/Entity/Customer.php" and "/var/www/main/html/src/Eccube/Entity/Customer.php", the first will be used.</warning> [456.0MiB/53.29s] Memory usage: 456.01MiB (peak: 497.08MiB), time: 53.29s
※app/Plugin/VeriTrans4G/Resource/tgMdkPHP/tgMdk/log4php.properties を作成して、 そのファイル内で「log4php.appender.R1.File」の設定も行った状態でないと削除できなかった 削除すると composer.json と composer.lock からも該当プラグインの情報が削除された よって次回は php bin/console eccube:composer:install でのインストールではなく、管理画面からのインストールが必要 ■プラグインを直接削除したときの挙動 VeriTrans4G フォルダを直接削除してから以下を実行すると、新たに VeriTrans4G が作られた
$ php bin/console eccube:composer:install <warning>Deprecation warning: require.ec-cube/VeriTrans4G is invalid, it should not contain uppercase characters. Please use ec-cube/veritrans4g instead. Make sure you fix this as Composer 2.0 will error.</warning> [28.4MiB/0.02s] Loading composer repositories with package information [28.8MiB/0.03s] Installing dependencies (including require-dev) from lock file [29.7MiB/0.10s] Package operations: 1 install, 0 updates, 0 removals [29.9MiB/0.12s] - Installing ec-cube/veritrans4g (1.2.0): [29.9MiB/0.14s] Loading from cache[29.9MiB/0.14s] [29.5MiB/5.64s] <warning>Package easycorp/easy-log-handler is abandoned, you should avoid using it. No replacement was suggested.</warning> [29.5MiB/5.64s] <warning>Package facebook/webdriver is abandoned, you should avoid using it. Use php-webdriver/webdriver instead.</warning> [29.5MiB/5.64s] <warning>Package phpunit/phpunit-mock-objects is abandoned, you should avoid using it. No replacement was suggested.</warning> [29.5MiB/5.64s] <warning>Package sensio/generator-bundle is abandoned, you should avoid using it. Use symfony/maker-bundle instead.</warning> [29.5MiB/5.64s] <warning>Package setasign/fpdi-tcpdf is abandoned, you should avoid using it. No replacement was suggested.</warning> [29.5MiB/5.64s] <warning>Package zendframework/zend-code is abandoned, you should avoid using it. Use laminas/laminas-code instead.</warning> [29.5MiB/5.64s] <warning>Package zendframework/zend-eventmanager is abandoned, you should avoid using it. Use laminas/laminas-eventmanager instead.</warning> [29.5MiB/5.64s] Generating optimized autoload files [33.6MiB/14.81s] <warning>Warning: Ambiguous class resolution, "Eccube\Entity\Customer" was found in both "$baseDir . '/app/proxy/entity/src/Eccube/Entity/Customer.php" and "/var/www/main/html/src/Eccube/Entity/Customer.php", the first will be used.</warning> [32.9MiB/19.15s] Memory usage: 32.89MiB (peak: 41.27MiB), time: 19.15s
すでにプラグインが存在する場合は何も行われなかった カラの VeriTrans4G がある場合も何も行われなかった
$ php bin/console eccube:composer:install <warning>Deprecation warning: require.ec-cube/VeriTrans4G is invalid, it should not contain uppercase characters. Please use ec-cube/veritrans4g instead. Make sure you fix this as Composer 2.0 will error.</warning> [28.4MiB/0.02s] Loading composer repositories with package information [28.8MiB/0.03s] Installing dependencies (including require-dev) from lock file [29.7MiB/0.10s] Nothing to install or update [28.9MiB/0.12s] <warning>Package easycorp/easy-log-handler is abandoned, you should avoid using it. No replacement was suggested.</warning> [28.9MiB/0.12s] <warning>Package facebook/webdriver is abandoned, you should avoid using it. Use php-webdriver/webdriver instead.</warning> [28.9MiB/0.12s] <warning>Package phpunit/phpunit-mock-objects is abandoned, you should avoid using it. No replacement was suggested.</warning> [28.9MiB/0.12s] <warning>Package sensio/generator-bundle is abandoned, you should avoid using it. Use symfony/maker-bundle instead.</warning> [28.9MiB/0.12s] <warning>Package setasign/fpdi-tcpdf is abandoned, you should avoid using it. No replacement was suggested.</warning> [28.9MiB/0.12s] <warning>Package zendframework/zend-code is abandoned, you should avoid using it. Use laminas/laminas-code instead.</warning> [28.9MiB/0.12s] <warning>Package zendframework/zend-eventmanager is abandoned, you should avoid using it. Use laminas/laminas-eventmanager instead.</warning> [28.9MiB/0.12s] Generating optimized autoload files [33.0MiB/13.62s] <warning>Warning: Ambiguous class resolution, "Eccube\Entity\Customer" was found in both "$baseDir . '/app/proxy/entity/src/Eccube/Entity/Customer.php" and "/var/www/main/html/src/Eccube/Entity/Customer.php", the first will be used.</warning> [32.3MiB/17.58s] Memory usage: 32.34MiB (peak: 40.73MiB), time: 17.58s
よってプラグインを改造して使用する場合、 ・通常の手順でプラグインをインストールする(app/Plugin/VeriTrans4G にインストールされるとする) ・app/Plugin/VeriTrans4G をGit管理対象にし、ファイルをリポジトリに含める とすれば、あとは通常の手順でプラグインの改造も新規環境構築もできる はず ■プラグインを無効化したときの挙動 プラグイン一覧画面で「無効化」ボタンを押すと dtb_plugin テーブルで該当データの enabled が 1 から 0 になる 以下は参考までにデータの変化とテーブル定義
INSERT INTO `dtb_plugin` VALUES (1,'ベリトランス4G','VeriTrans4G',1,'1.2.0','1835',1,'2020-08-31 09:35:35','2020-08-31 09:51:07','plugin'); ↓ INSERT INTO `dtb_plugin` VALUES (1,'ベリトランス4G','VeriTrans4G',0,'1.2.0','1835',1,'2020-08-31 09:35:35','2020-09-24 05:53:57','plugin'); MariaDB [main]> select * from dtb_plugin; +----+----------------------+-------------+---------+---------+--------+-------------+---------------------+---------------------+--------------------+ | id | name | code | enabled | version | source | initialized | create_date | update_date | discriminator_type | +----+----------------------+-------------+---------+---------+--------+-------------+---------------------+---------------------+--------------------+ | 1 | ベリトランス4G | VeriTrans4G | 0 | 1.2.0 | 1835 | 1 | 2020-08-31 09:35:35 | 2020-09-24 05:53:57 | plugin | +----+----------------------+-------------+---------+---------+--------+-------------+---------------------+---------------------+--------------------+ 1 row in set (0.00 sec) MariaDB [main]> show columns from dtb_plugin; +--------------------+------------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +--------------------+------------------+------+-----+---------+----------------+ | id | int(10) unsigned | NO | PRI | NULL | auto_increment | | name | varchar(255) | NO | | NULL | | | code | varchar(255) | NO | | NULL | | | enabled | tinyint(1) | NO | | 0 | | | version | varchar(255) | NO | | NULL | | | source | varchar(255) | NO | | NULL | | | initialized | tinyint(1) | NO | | 0 | | | create_date | datetime | NO | | NULL | | | update_date | datetime | NO | | NULL | | | discriminator_type | varchar(255) | NO | | NULL | | +--------------------+------------------+------+-----+---------+----------------+ 10 rows in set (0.00 sec)

Advertisement