composer 自动更新_快速提示:使Composer自行自动更新

composer 自动更新

Composer is a great package manager for PHP. It allows us to install, update and upgrade third-party libraries. For those who don't know about composer, here is a good beginners guide on the topic.

Composer是PHP的出色软件包管理器。 它允许我们安装,更新和升级第三方库。 对于那些对作曲家一无所知的人, 这里有个不错的初学者指南

Now we know once in a while, composer needs to update its build so it can have the latest security fixes and patches. This can sometimes get annoying as most people (points to self) forget to update their build. If you have used composer for a period longer than 60days, you might have seen this message.

现在我们不时知道,作曲家需要更新其构建,以便它可以具有最新的安全修复程序和修补程序。 由于大多数人(指向自我)都忘记更新其构建,因此有时可能会令人烦恼。 如果您使用作曲家的时间超过60天,则可能已经看到此消息。

Warning: This development build of composer is over 60 days old. It is recommended to update it by running"C:\ProgramData\ComposerSetup\bin\composer.phar self-
update" to get the latest version.

This quick tip article aims to tackle that problem by letting composer auto-update itself. For composer to auto-update itself, all we have to is set up a command that runs on a certain interval. I set mine to every Saturday. I assume you know composer and have it installed. For more info, check out this article.

这篇快速提示文章旨在通过让作曲家自动更新自身来解决该问题。 为了使作曲家能够自动更新,我们所要做的就是设置一个以一定间隔运行的命令。 我把我的时间定在每个星期六。 我假设您知道作曲家并已安装它。 有关更多信息,请查看本文

Linux上的Setup Composer自动更新 ( Setup Composer auto-update on Linux )

To make composer auto-update on any Linux-based computer, all we need to do is setup a cron task. Don't know about cron, check out this DigitalOcean article. Open your cronfile and add the command.

为了使作曲家能够在任何基于Linux的计算机上自动更新,我们所需要做的就是设置cron任务。 不了解cron,请查阅此DigitalOcean文章 。 打开您的cronfile并添加命令。

5 8 * * Sat /path/to/composer/executable self-update

For example, since my composer executable is in usr/bin, mine cron task will look like this.

例如,由于我的作曲家可执行文件位于usr/bin ,因此我的cron任务将如下所示。

5 8 * * Sat /usr/bin/composer self-update

This lets composer update itself every Saturday morning at five minutes past eight.

这样,作曲家就可以在每个星期六早上八点五分更新自己。

Note: If you don't know where composer installed on your computer, you can open a terminal and run the following command to get composer's install path.

注意:如果您不知道composer在计算机上的安装位置,则可以打开终端并运行以下命令来获取composer的安装路径。

which composer

Since I use MinGW on windows to make Linux commands available for me, the result of running the above command looks like this.

由于我在Windows上使用MinGW使Linux命令对我可用,因此运行上述命令的结果如下所示。

Windows上的Setup Composer自动更新 ( Setup Composer auto-update on Windows )

As usual, setting up a task like this on windows takes a more graphical approach. On your windows machine, search for task scheduler.

像往常一样,在Windows上设置这样的任务需要采用更多的图形方法。 在Windows计算机上,搜索任务计划程序。

In the right-hand panel on the screen, you should see a list of actions, click on create basic task. In the dialog that pops up, fill in the name and description of the task, click next.

在屏幕的右侧面板中,您应该看到一个动作列表,然后单击create basic task 。 在弹出的对话框中,填写任务的名称和描述,然后单击下一步。

The next section asks you to pick a trigger. Trigger is the event which fires an action. It could be when the computer starts, daily, weekly, monthly etc. Pick weekly and click next.

下一节要求您选择一个触发器。 触发器是触发动作的事件。 可能是计算机启动的时间,每天,每周,每月等。每周选择一次,然后单击下一步。

The next page asks you when to start the task, and the day of the week to trigger the task. For ours, we choose the default start time, input 1 in the "recur every" weeks field, check Saturday as the day of the week and click next.

下一页询问您何时开始任务,以及星期几触发任务。 对于我们来说,我们选择默认的开始时间,在“每隔一周重复一次”字段中输入1,选中“星期六”作为一周中的某天,然后单击“下一步”。

A list of actions show up, now we can choose to start a program as the action to perform and click next.

将显示一个动作列表,现在我们可以选择启动程序作为要执行的动作,然后单击“下一步”。

On the screen that follows, there is a field for the path to composer.bat and another where we can add arguments. To get the path to composer.bat, in the command prompt type

在随后的屏幕上,有一个到composer.bat的路径字段,另一个是我们可以添加参数的字段。 要获取composer.bat的路径,请在命令提示符下键入

where composer

and copy and paste the path to composer.bat in the Program/script field. In the Add arguments field, type in self-update or selfupdate either is fine and hit next.

并将路径复制并粘贴到Program/script字段中的composer.bat 。 在“ Add arguments字段中,键入self-updateselfupdate都可以,然后单击下一步。

The window that shows up next is the last and final screen, it shows an overview of the task you are creating.

接下来显示的窗口是最后一个屏幕,也是最后一个屏幕,它概述了您正在创建的任务。

结论 ( Conclusion )

If you follow the steps mentioned above, composer should auto-update from now on.

如果您按照上述步骤操作,则作曲家应该从现在开始自动更新。

翻译自: https://scotch.io/tutorials/quick-tip-make-composer-auto-update-itself

composer 自动更新

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值