php RuntimeException] 供应商不存在且无法创建

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/22390001/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 04:53:14  来源:igfitidea点击:

RuntimeException] vendor does not exist and could not be created

phpjsonvagrantcomposer-php

提问by user3413366

I've tried other posts I found online but none seemed to work correctly. I'm working with this. And I make my way to the root of it, which is /var/www/. So then I do composer installand I have a composer.jsonfile in there. I get

我试过在网上找到的其他帖子,但似乎没有一个能正常工作。我正在处理这个。我找到了它的根源,也就是/var/www/. 然后我做了composer install,我composer.json在那里有一个文件。我得到

[RuntimeException]                               
vendor does not exist and could not be created.

Here's the file

这是文件

{
    "name": "panique/php-login",
    "type": "project",
    "description": "A PHP login system embedded in a simple MVC framework",
    "keywords": ["login", "auth", "user", "authentification", "mvc"],
    "homepage": "https://github.com/panique/php-login",
    "license": "MIT",
    "authors": [
        {
            "name": "Panique",
            "homepage": "http://careers.stackoverflow.com/panique",
            "role": "Developer"
        }
    ],
    "support": {
        "issues": "https://github.com/panique/php-login/issues",
        "source": "https://github.com/panique/php-login"
    },
    "require":{
        "php": ">=5.3.7",
        "ircmaxell/password-compat": "1.0.*",
        "phpmailer/phpmailer": "5.2.*",
        "gregwar/captcha": "dev-master",
        "facebook/php-sdk": "@stable",
        "raveren/kint": "dev-1.0.0-wip"
    }
}

I'm not really sure where to go from here....

我真的不知道从这里去哪里......

回答by Etienne Gautier

Googlers, do not use composer with sudo:

Google 员工,请勿将 Composer 与 sudo 一起使用:

Add your user in the www-data group (this action require you to logout and login again)

在 www-data 组中添加您的用户(此操作需要您注销并重新登录)

sudo usermod -a -G www-data `whoami`

Give the right permissions to /var/www

授予对 /var/www 的正确权限

sudo chown root:root /var/www
sudo chmod 755 /var/www/

Give these permissions to your project

为您的项目授予这些权限

sudo chown -R www-data:www-data /var/www/<project>
sudo chmod -R 774 /var/www/<project>

回答by Hiroki

@Etienne Gautier 's approach is fine.

@Etienne Gautier 的方法很好。

Another solution is just to change the mode and owner/group of /vendor.

另一种解决方案是更改/vendor.

e.g.

例如

sudo chmod -R 775  /ROOT_OF_YOUR_APP/vendor/
sudo chown -R $USER:$USER /ROOT_OF_YOUR_APP/vendor/

回答by Clark Nelson

I was able to solve this type of issue by removing the vendor folder and then re-installing using composer update. Hope this helps someone like me.

我能够通过删除供应商文件夹然后使用composer update. 希望这可以帮助像我这样的人。

回答by Ziaur Rahman

Etienne Gautier's answer is alright. You can try it also.First update or install your composer composer updateor composer installand give the right permission to your project directory by using your terminal:

Etienne Gautier 的回答是好的。您也可以尝试一下。首先更新或安装您的作曲家,composer update或者composer install使用您的终端为您的项目目录授予正确的权限:

sudo chmod -R 755 /var/www/<your_project_name>/public 

and also give a permission to vendor dir. Use it while you don't want to give permission to your /var/wwwdirectory. Note that give right permission to your directory otherwise it will be accessible to all.

并授予供应商目录的权限。在您不想授予/var/www目录权限时使用它。请注意,为您的目录授予正确的权限,否则所有人都可以访问它。

回答by Kalai Selvan

Try this worked for me.

试试这对我有用。

sudo composer update

回答by Diego Santa Cruz Mendezú

This happens because we do not have administrator permissions, we just have to put the word sudo, it would look like this: sudo composer install

发生这种情况是因为我们没有管理员权限,我们只需要输入 sudo 这个词,它看起来像这样:sudo composer install