作曲家| laravel 5 - 更新依赖项但更新框架本身

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

composer | laravel 5 - Updating dependencies but the framework itself

laravellaravel-4composer-phplaravel-5

提问by aBhijit

I am using pre-beta release of Laravel 5 for my project.

我正在为我的项目使用 Laravel 5 的 pre-beta 版本。

I found out that the app skeleton of Laravel 5 was changed in the github repo and since it is a development version, that is expected to change quite frequently.

我发现 Laravel 5 的应用程序框架在 github 存储库中发生了更改,并且由于它是一个开发版本,因此预计会经常更改。

My question is, can I update only the specific dependencies using composer and not the framework itself? So that I don't have to worry about the changing app structure until I am ready to make changes?

我的问题是,我可以使用 composer 而不是框架本身只更新特定的依赖项吗?这样我就不必担心不断变化的应用程序结构,直到我准备好进行更改?

Here is how the composer.json dependencies look:

这是 composer.json 依赖项的外观:

    "require": {
        "laravel/framework": "~5.0"
    },
    "require-dev": {
        "phpunit/phpunit": "~4.0",
        "way/generators": "~3.0",
        "fzaninotto/faker": "~1.5@dev"
    },

Thank you.

谢谢你。

采纳答案by alexrussell

While the composer update package package ...answer is a good one, another thing you might be able to do is change your Laravel require spec to a specific commit. The Composer documentationmentions how to do this, and I've done it myself on a project (though not with laravel, on my own packages which are also in a breaking/dev state).

虽然composer update package package ...答案很好,但您可能可以做的另一件事是将 Laravel 要求规范更改为特定提交。该作曲家文档提到如何做到这一点,我已经做到了我自己的一个项目(尽管不是laravel,在我自己的包也被加分断的/ dev状态)。

"require": {
    "laravel/framework": "dev-master#49e3c77b518547bb661b1de4fda64a3ae0c5c505",
    ...
}

I'd hope that, because laravel/framework'replaces' the various illuminate/*packages, that any reliance on these (as long as the spec is 5.0-esque) that this would work without downloading the illuminate packages twice.

我希望,因为laravel/framework“替换”了各种illuminate/*软件包,所以任何对这些软件包的依赖(只要规范是5.0-esque)都可以在不下载照明软件包两次的情况下工作。

Doing it this way you can lock your laravel/framework(or any package) at a given commit, but still allow the standard composer updateto work.

这样做你可以laravel/framework在给定的提交中锁定你的(或任何包),但仍然允许标准composer update工作。

To find out what commit you're already on, if your laravel/frameworkdependency spec is a dev one then the vendor/laravel/framework/directory itself should be a git repo, so just do git statusin there to get the HEAD ref. Alternatively, look in composer.lockfor the laravel/frameworkentry's source.referencevalue.

要找出您已经在进行的提交,如果您的laravel/framework依赖项规范是开发规范,那么vendor/laravel/framework/目录本身应该是一个 git 存储库,因此只需git status在那里获取 HEAD 引用即可。或者,查看composer.locklaravel/framework条目的source.reference值。

回答by Laurence

Composer allows you to do specific package upgrades. I used this literally the other night to upgrade a single package to fix a bug, but I didn't want to change anything else.

Composer 允许您进行特定的包升级。前几天晚上我用它来升级单个软件包以修复错误,但我不想更改任何其他内容。

composer update <package1> <package2> <...>

composer update <package1> <package2> <...>

So in your case

所以在你的情况下

composer update phpunit/phpunit way/generators fzaninotto/faker

composer update phpunit/phpunit way/generators fzaninotto/faker

It might be more complicated when you have lots of packages - but it is a solution that works.

当你有很多包时,它可能会更复杂 - 但它是一个有效的解决方案。

回答by Jarek Tkaczyk

Yes, you can simply call

是的,你可以简单地打电话

composer update vendor/package

without updating your whole project.

无需更新整个项目。

It will work for the packages pulled by yourself and for the dependencies

它将适用于您自己拉取的包和依赖项

回答by aFreshMelon

You can't really. If you use Laravel 5 this is a thing you need to deal with, development versions come with this backdraw.

你真的不能。如果您使用 Laravel 5,这是您需要处理的事情,开发版本带有此回撤。