简体   繁体   English

Yii2 基本应用程序错误:要发布的文件或目录不存在

[英]Yii2 Basic Application Error: The file or directory to be published does not exist

I am currently trying to work on a Yii2 Basic application.我目前正在尝试开发 Yii2 基本应用程序。 It is kind of an experiment that I am conducting.这是我正在进行的一项实验。 I have an application and up and running on a Docker container.我有一个应用程序并在 Docker 容器上运行。 The demo website itself works great so far.到目前为止,演示网站本身运行良好。

However, when I try to use the gii I get the following Error: "The file or directory to be published does not exist: /usr/local/bereitschaftsdienst/php/webapp/vendor/yiisoft/yii2/gii/assets"但是,当我尝试使用 gii 时出现以下错误:“要发布的文件或目录不存在:/usr/local/bereitschaftsdienst/php/webapp/vendor/yiisoft/yii2/gii/assets”

I tried multiple things following these links:我在这些链接之后尝试了多种方法:

https://forum.yiiframework.com/t/invalid-parameter-error-for-gii-assets-folder/81899 https://forum.yiiframework.com/t/invalid-parameter-error-for-gii-assets-folder/81899

https://github.com/yiisoft/yii2-bootstrap4/issues/35 https://github.com/yiisoft/yii2-bootstrap4/issues/35

Yii2 - Gii extension assets folder alias referencing to a wrong path Yii2 - Gii 扩展资产文件夹别名引用了错误的路径

However, nothing worked.但是,没有任何效果。 At some point I deleted the vendor directory on my local machine and started the docker container again.在某个时候,我删除了本地计算机上的供应商目录,并再次启动了 docker 容器。 The directory on my local machine is still empty but the container contains a vendor folder with all the needed files.我本地机器上的目录仍然是空的,但容器包含一个供应商文件夹,其中包含所有需要的文件。

Whatever I do, I can't seem to find the solution for Gii to work.无论我做什么,我似乎都找不到让 Gii 工作的解决方案。 I have changed many configurations.我改变了很多配置。 At the moment I have the following thing set:目前,我设置了以下内容:

composer.json作曲家.json

{
    "name": "yiisoft/yii2-app-basic",
    "description": "Yii 2 Basic Project Template",
    "keywords": ["yii2", "framework", "basic", "project template"],
    "homepage": "http://www.yiiframework.com/",
    "type": "project",
    "license": "BSD-3-Clause",
    "support": {
        "issues": "https://github.com/yiisoft/yii2/issues?state=open",
        "forum": "http://www.yiiframework.com/forum/",
        "wiki": "http://www.yiiframework.com/wiki/",
        "irc": "irc://irc.freenode.net/yii",
        "source": "https://github.com/yiisoft/yii2"
    },
    "minimum-stability": "stable",
    "require": {
        "php": ">=5.6.0",
        "fzaninotto/faker": "*",
        "codeception/codeception": "*",
        "yiisoft/yii2": "~2.0.14",
        "yiisoft/yii2-bootstrap4": "~2.0.0",
        "yiisoft/yii2-swiftmailer": "~2.0.0 || ~2.1.0",
        "yiisoft/yii2-gii": "~2.2.0"
    },
    "require-dev": {
        "yiisoft/yii2-debug": "~2.1.0",
        "yiisoft/yii2-gii": "~2.2.0",
        "yiisoft/yii2-faker": "~2.0.0",
        "codeception/codeception": "^4.0",
        "codeception/verify": "~0.5.0 || ~1.1.0",
        "codeception/specify": "~0.4.6",
        "symfony/browser-kit": ">=2.7 <=4.2.4",
        "codeception/module-filesystem": "^1.0.0",
        "codeception/module-yii2": "^1.0.0",
        "codeception/module-asserts": "^1.0.0"
    },
    "config": {
        "process-timeout": 1800,
        "fxp-asset": {
            "enabled": false
        }
    },
    "scripts": {
        "post-install-cmd": [
            "yii\\composer\\Installer::postInstall"
        ],
        "post-create-project-cmd": [
            "yii\\composer\\Installer::postCreateProject",
            "yii\\composer\\Installer::postInstall"
        ]
    },
    "extra": {
        "asset-installer-paths": {
            "npm-asset-library": "vendor/npm",
            "bower-asset-library": "vendor/bower"
        },
        "yii\\composer\\Installer::postCreateProject": {
            "setPermission": [
                {
                    "runtime": "0777",
                    "web/assets": "0777",
                    "yii": "0777"
                }
            ]
        },
        "yii\\composer\\Installer::postInstall": {
            "generateCookieValidationKey": [
                "config/web.php"
            ]
        }
    },
    "repositories": [
        {
            "type": "composer",
            "url": "https://asset-packagist.org"
        }
    ]
}

web.php web.php

$ipAdress = $_SERVER['REMOTE_ADDR'];
if (YII_ENV_DEV) {
    // configuration adjustments for 'dev' environment
    $config['bootstrap'][] = 'debug';
    $config['modules']['debug'] = [
        'class' => 'yii\debug\Module',
        // uncomment the following to add your IP if you are not connecting from localhost.
        // 'allowedIPs' => ['127.0.0.1', '::1'],
    ];

    $config['bootstrap'][] = 'gii';
    $config['modules']['gii'] = [
        'class' => 'yii\gii\Module',
        // uncomment the following to add your IP if you are not connecting from localhost.
        'allowedIPs' => ['127.0.0.1', '::1', $ipAdress],
    ];
}

You guys know where I am doing things wrong?你们知道我哪里做错了吗?

After a lot of searching, I was able to find the solution.经过大量搜索,我能够找到解决方案。 I don't know why exactly, however, it seems that the composer has not installed all packages properly.我不知道为什么,但是,作曲家似乎没有正确安装所有软件包。

After running composer update the dependencies in the require-dev where also installed and I was able to run Gii without any further issues.在运行composer update后,还安装了require-dev中的依赖项,我能够运行 Gii 而没有任何进一步的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM