[英]How can I install only one directory by Composer from the vendor/package? Or delete directories after installation?
Sorry my english isn't too good. 对不起,我的英语不太好。 So I have a problem with the composer.
所以我对作曲家有疑问。 It is that I can select which directory I would like to install from a package, or after installation delete them.
我可以从软件包中选择要安装的目录,也可以在安装后删除它们。 For example: "yiisoft/yii" this is the vendor/package.
例如:“ yiisoft / yii”这是供应商/软件包。 But I would like to install only the "yiisoft/yii/framework" directory.
但是我只想安装“ yiisoft / yii / framework”目录。 I don't like to keep the other directories.
我不喜欢保留其他目录。 I still find what will be the best solution for my problem.
我仍然找到解决我的问题的最佳解决方案。
You shouldn't mess with the vendor directory. 您不应该混淆供应商目录。 There are good reason to keep it all together in
vendors
. 有充分的理由将所有这些东西放在
vendors
。 If you really need to have certain files available from another path, use symlinks. 如果确实需要从其他路径获得某些文件,请使用符号链接。
For more information about this topic read this authoritative blog post about the Composer Vendor Directory by Igor Wiedler. 有关此主题的更多信息,请阅读Igor Wiedler撰写的有关Composer供应商目录的权威博客文章。
Alternatively you could copy the content somewhere else (and/or delete) with phing. 或者,您可以通过phing将内容复制到其他位置(和/或删除)。
When you install a software with composer, you install all the repository. 使用composer安装软件时,将安装所有存储库。 If you want to delete unused folder, you can use a particular feature of composer.
如果要删除未使用的文件夹,则可以使用composer的特定功能。 You can catch some events like post-install-cmd or post-update-cmd in this way:
您可以通过以下方式捕获一些事件,例如post-install-cmd或post-update-cmd:
{
"scripts": {
"post-install-cmd": "Sensorario\\Communityii\\ComposerCommands::postInstall",
"post-update-cmd": "Sensorario\\Communityii\\ComposerCommands::postUpdate"
}
}
In the root folder of your project you have composer.json, you will also need to add a file in PSR-0 standard: - composer.json - src/Sensorario/Communityii/ComposerCommands.php 在项目的根文件夹中,您有composer.json,还需要添加PSR-0标准的文件:-composer.json-src / Sensorario / Communityii / ComposerCommands.php
And this file can be like this: 这个文件可以像这样:
namespace Sensorario\\Communityii; 命名空间Sensorario \\ Communityii;
class ComposerCommands
{
public static function postUpdate()
{
// remove unused folders
shell_exec('rm vendor/yiisoft/yii/demos/ ... ');
}
}
This code will run after 此代码将在之后运行
$ composer update
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.