1、参考网址:https://www.shuijingwanwq.com/2021/04/15/4859/ 。基于 Composer 更新 Yii 2 至最新版本,将 Yii Framework 从 2.0.35 版本升级到 2.0.41.1。./yii 无输出。如图1

图1

[root@api-78b4b688b4-l26vd ccp_api]# ./yii
[root@api-78b4b688b4-l26vd ccp_api]# 

2、./yii 有输出的正常情况。如图2

图2

3、编辑 ./yii 文件,有输出:0。如图3

图3

#!/usr/bin/env php
<?php
/**
 * Yii console bootstrap file.
 */
defined('YII_DEBUG') or define('YII_DEBUG', true);
defined('YII_ENV') or define('YII_ENV', 'dev');
echo 0;
exit;
require __DIR__ . '/vendor/autoload.php';
require __DIR__ . '/vendor/yiisoft/yii2/Yii.php';
require __DIR__ . '/common/config/bootstrap.php';
require __DIR__ . '/console/config/bootstrap.php';
$config = yii\helpers\ArrayHelper::merge(
    require __DIR__ . '/common/config/main.php',
    require __DIR__ . '/common/config/main-local.php',
    require __DIR__ . '/console/config/main.php',
    require __DIR__ . '/console/config/main-local.php'
);

$application = new yii\console\Application($config);
$exitCode = $application->run();
exit($exitCode);

4、编辑 ./yii 文件,无输出。可以确定与 /vendor 存在关系了。

<?php
/**
 * Yii console bootstrap file.
 */
defined('YII_DEBUG') or define('YII_DEBUG', true);
defined('YII_ENV') or define('YII_ENV', 'dev');
require __DIR__ . '/vendor/autoload.php';
echo 1;
exit;
require __DIR__ . '/vendor/yiisoft/yii2/Yii.php';
require __DIR__ . '/common/config/bootstrap.php';
require __DIR__ . '/console/config/bootstrap.php';
$config = yii\helpers\ArrayHelper::merge(
    require __DIR__ . '/common/config/main.php',
    require __DIR__ . '/common/config/main-local.php',
    require __DIR__ . '/console/config/main.php',
    require __DIR__ . '/console/config/main-local.php'
);

$application = new yii\console\Application($config);
$exitCode = $application->run();
exit($exitCode);

5、在本地环境中是正常的。如图4

图4

6、对比开发环境与本地环境,/vendor 的差异。因为 /vendor 是放在 Git 中的。chore:再次添加 /vendor。./yii 有输出。如图5

图5

7、在另外一个工程中,即使按照如上的方式处理后,仍然无输出。如图6

图6

[root@api-6b9cd4ddb5-hcrks pcs_api]# ./yii
[root@api-6b9cd4ddb5-hcrks pcs_api]# 

8、删除 /vendor,删除 composer.lock,提交。添加 /vendor,添加 composer.lock,提交。./yii 有输出。如图7

图7

[root@api-747859c976-7zj7g pcs_api]# ./yii

This is Yii version 2.0.41.1.

The following commands are available:

- asset                        Allows you to combine and compress your JavaScript and CSS files.
    asset/compress (default)   Combines and compresses the asset files according to the given configuration.
    asset/template             Creates template of configuration file for [[actionCompress]].

- cache                        Allows you to flush cache.
    cache/flush                Flushes given cache components.
    cache/flush-all            Flushes all caches registered in the system.
    cache/flush-schema         Clears DB schema cache for a given connection component.
    cache/index (default)      Lists the caches that can be flushed.

 

永夜