php 在 yii2.0 中使用 composer 安装扩展

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/27781793/
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 23:31:48  来源:igfitidea点击:

Install extension using composer in yii2.0

phpyii2yii-extensions

提问by Sunny Bhakta

How can i install yii/jui in yii2.0 using composer. I have tried

如何使用 composer 在 yii2.0 中安装 yii/jui。我试过了

php composer.phar require --prefer-dist yiisoft/yii2-jui "*"

and added to composer.json

并添加到composer.json

"yiisoft/yii2-jui": "*"

but it did not succeed. Can anyone help me how to use composer to install extension in yii 2.0 .

但它没有成功。任何人都可以帮助我如何使用 composer 在 yii 2.0 中安装扩展。

When i am running $ php composer.phar require yiisoft/yii2-jui "*"in cmd it is just opening the composer.phar file, nothing else happening.

当我$ php composer.phar require yiisoft/yii2-jui "*"在 cmd 中运行时,它只是打开 composer.phar 文件,没有其他任何事情发生。

Thank you in advance.

先感谢您。

回答by 502_Geek

Please check in composer.json file for yiisoft/yii2-jui under "require". You might be see like that

请在“require”下检查 yiisoft/yii2-jui 的 composer.json 文件。你可能会这样看

"require": {
        "yiisoft/yii2-jui": "2.0.*@dev"
},

If you didn't see, please add this and run composer.phar installor composer install. If already install, use composer.phar updateor composer update

如果你没有看到,请添加这个并运行composer.phar installcomposer install。如果已经安装,请使用composer.phar updatecomposer update

I have been updated my answer. Please take a look. The packagist is Here.

我已经更新了我的答案。请看一下。包装师在这里

回答by 502_Geek

Hopefully, you already installed Yii-2 with composer. I have been installed (basic application template) step by step.

希望你已经用 composer 安装了 Yii-2。我已经一步一步安装(基本应用模板)。

Step 1. Before installation, Yii official website said that, we require to install this package before installation Yii 2. This step will follow after composer installation.

Step 1. 在安装之前,Yii官网说,我们需要在安装Yii 2之前安装这个包。这一步会在composer安装后进行。

sudo composer global require "fxp/composer-asset-plugin:1.0.0-beta4"

Please take a look attach file.

请看附件文件。

enter image description here

在此处输入图片说明

This time is yii-2 installation with composer.

这次是用composer安装yii-2。

sudo composer create-project yiisoft/yii2-app-basic basic 2.0.1 

Please take a second and third attach image.

请拍摄第二张和第三张附加图片。

enter image description here

在此处输入图片说明

enter image description here

在此处输入图片说明

After that, please go to your project folder. Then, open your_project_folder/composer.json. I have been used vito open compser.json. You can use whatever your prefer. Please take a look again for attach image.

之后,请转到您的项目文件夹。然后,打开your_project_folder/composer.json。我一直用vi打开compser.json。你可以使用任何你喜欢的。请再看看附件图片。

enter image description here

在此处输入图片说明

The next step is final step for complete install for your package. After adding this

下一步是完整安装包的最后一步。添加这个之后

"yiisoft/yii2-jui": "*" 

under requirekeyword, please save your composer.jsonfile. Then run this command.

require关键字下,请保存您的composer.json文件。然后运行这个命令。

 sudo composer update

Please take a look attach image again.

请再看看附上图片。

enter image description here

在此处输入图片说明

Please check your folder on your_project_folder/vender/yiisoft/yii2-jui

请检查您的文件夹your_project_folder/vender/yiisoft/yii2-jui

enter image description here

在此处输入图片说明

That's all. Hope this help for your stack. Btw, if you want to use composercommand, please used the following command. This will help to call composerfrom everywhere.

就这样。希望这对您的堆栈有所帮助。顺便说一句,如果您想使用composer命令,请使用以下命令。这将有助于从任何地方调用作曲家

sudo mv composer.phar /usr/local/bin/composer

回答by Aristo Bharata

I use Windows 10, To install php composer.pharrequires --prefer-dist yiisoft/yii2-jui.

我使用 Windows 10,安装 phpcomposer.phar需要--prefer-dist yiisoft/yii2-jui.