没有不值得去解决的问题,也没有不值得去学习的技术!

Troubleshooting ./yii When It Produces No Output

Reference URL: https://www.shuijingwanwq.com/2021/04/15/4859/ . Updating Yii 2 to the latest version via Composer, upgrading Yii Framework from version 2.0.35 to 2.0.41.1. ./yii produces no output.

1. Reference URL: Updating Yii 2 to the latest version via Composer, upgrading Yii Framework from version 2.0.35 to 2.0.41.1. ./yii produces no output. See Figure 1.

Reference URL: https://www.shuijingwanwq.com/2021/04/15/4859/ . Updating Yii 2 to the latest version via Composer, upgrading Yii Framework from version 2.0.35 to 2.0.41.1. ./yii produces no output.
Figure 1
Plaintext
[root@api-78b4b688b4-l26vd ccp_api]# ./yii
[root@api-78b4b688b4-l26vd ccp_api]# 

2. The normal situation where ./yii produces output. See Figure 2.

The normal situation where ./yii produces output.
Figure 2

3. Editing the ./yii file produces the output: 0. See Figure 3.

Editing the ./yii file produces the output: 0.
Figure 3
PHP
#!/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. Editing the ./yii file results in no output. I can confirm that the issue is related to /vendor.

PHP
<?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. It works normally in the local environment. See Figure 4.

It works normally in the local environment.
Figure 4

6. Comparing the /vendor directory between the development environment and the local environment. Because /vendor is tracked in Git. chore: add /vendor again. ./yii produces output. See Figure 5.

Comparing the /vendor directory between the development environment and the local environment. Because /vendor is tracked in Git. chore: add /vendor again. ./yii produces output.
Figure 5

7. In another project, even after applying the above steps, there is still no output. See Figure 6.

In another project, even after applying the above steps, there is still no output.
Figure 6
Plaintext
[root@api-6b9cd4ddb5-hcrks pcs_api]# ./yii
[root@api-6b9cd4ddb5-hcrks pcs_api]# 

8. Delete /vendor, delete composer.lock, and commit. Add /vendor, add composer.lock, and commit. ./yii produces output. See Figure 7.

Delete /vendor, delete composer.lock, and commit. Add /vendor, add composer.lock, and commit. ./yii produces output.
Figure 7
Plaintext
[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.

关于作者 · 持续学习与技术实践

我是一名拥有 15 年以上开发经验的技术从业者,自 2013 年起持续运营个人技术博客,记录工作与个人项目中遇到的真实问题,以及解决问题过程中的探索、实践和思考。

除了技术写作,我也在持续开发和维护自己的独立项目,探索新技术和新工具在实际场景中的应用。我始终相信,没有不值得去解决的问题,也没有不值得去学习的技术。

如果这篇文章对你有所帮助,欢迎浏览博客中的其他文章,也欢迎交流技术经验与想法。

关于我  ·  GitHub  ·  邮件联系