laravel 强制 Composer 更新包
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/35661609/
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
Force Composer to update a package
提问by ChrisNY
I've developed a custom laravel package and put it on GitHub. I put it in composer.json (code below) and it installs fine.
我开发了一个自定义的 laravel 包并将其放在 GitHub 上。我把它放在 composer.json (下面的代码)中,它安装得很好。
I have no version info on it yet, since it is still in development. When I make changes to my package (in a separate directory), I commit and push the changes up to the GitHub repo.
我还没有关于它的版本信息,因为它仍在开发中。当我对我的包进行更改(在单独的目录中)时,我提交并将更改推送到 GitHub 存储库。
When I run 'composer update', I get "nothing to install or update". If I delete the package from my vendors directory and update, then my package IS installed from the GitHub repo, with the latest changes.
当我运行“composer update”时,我得到“没有安装或更新”。如果我从我的供应商目录中删除包并更新,那么我的包是从 GitHub 存储库安装的,并带有最新的更改。
But I would like to be able to pull/force the latest changes from the repo without deleting it first from my vendors directory, since I have other dependencies on that package, and if I delete it, I get errors from artisan clear-compiled that classes are not defined (since they are defined in my deleted vendor package...)
但是我希望能够从 repo 中提取/强制执行最新更改,而无需先从我的供应商目录中删除它,因为我对该包有其他依赖项,如果我删除它,我会从 artisan clear-compiled 那里得到错误类未定义(因为它们是在我删除的供应商包中定义的...)
The relevant portion of my top-level composer.json is:
我的顶级 composer.json 的相关部分是:
"repositories": [{
"type": "package",
"package": {
"name": "myrepo/MyExtension",
"version": "dev-master",
"source": {
"url": "https://github.com/myrepo/MyExtension.git",
"type": "git",
"reference": "master"
},
"autoload": {
"psr-4": {
"MyExtension\": "src/Extensions/"
}
}
}
],
"require": {
"php": ">=5.5.9",
"laravel/framework": "5.2.*",
"myrepo/MyExtension": "dev-master"
},
采纳答案by Sven
You have created all meta data about your package yourself, likely making Composer think that the data didn't change.
您自己创建了关于您的包的所有元数据,这可能使 Composer 认为数据没有改变。
The easier, and probably working, way would be to simply point to the repository URL and let Composer query the meta data from the composer.json
file contained in the repository:
更简单且可能有效的方法是简单地指向存储库 URL 并让 Composer 从composer.json
存储库中包含的文件中查询元数据:
"repositories": [{
"type": "vcs",
"url": "https://github.com/myrepo/MyExtension.git"
}]
回答by oseintow
For it to update your changes you need to version your package but as you said earlier you are not versioning your packages so for it to update your changes you can go to composer.lock to remove your package entry or to use composer to remove the package and install it again. eg
为了更新您的更改,您需要对包进行版本控制,但正如您之前所说,您没有对包进行版本控制,因此为了更新您的更改,您可以转到 composer.lock 删除您的包条目或使用 composer 删除包并重新安装。例如
// composer remove vendor/package && composer require vendor/package
composer remove zizaco/entrust && composer require zizaco/entrust