作曲家是一个命令行工具,用于管理 PHP 项目中的依赖项。它允许您声明项目所依赖的库,并自动为您管理(安装/更新)它们。它充当某种项目经理,帮助程序员管理将在项目到项目的基础上使用的依赖项。
在 Rocky Linux 9 上安装 Composer
第 1 步。第一步是将系统更新到最新版本的软件包列表。为此,请运行以下命令:
<span class="pln">sudo dnf check</span><span class="pun">-</span><span class="pln">update sudo dnf install dnf</span><span class="pun">-</span><span class="pln">utils</span>
第 2 步。安装 PHP。
PHP Composer 至少需要 PHP 7,因此,我们将安装 PHP 8,因为满足了要求。现在使用包管理器安装 PHP,如下所示:dnf
<span class="pln">sudo dnf install php</span>
安装完成后,验证安装的 PHP 版本,如下所示:
<span class="pln">php </span><span class="pun">-</span><span class="pln">v</span>
有关安装 PHP 的其他资源,请阅读下面的帖子:
- 如何在 Rocky Linux √ 上安装 PHP
第 3 步。在 Rocky Linux 9 上安装 Composer。
默认情况下,Composer 在 Rocky Linux 9 基础存储库中不可用。现在运行以下命令,使用以下命令从其官方网站下载 Composer 安装程序文件:wget
<span class="pln">wget https</span><span class="pun">:</span><span class="com">//getcomposer.org/installer -O composer-installer.php</span>
接下来,使用以下命令运行下载的作曲家安装文件:
<span class="pln">php composer</span><span class="pun">-</span><span class="pln">installer</span><span class="pun">.</span><span class="pln">php </span><span class="pun">--</span><span class="pln">filename</span><span class="pun">=</span><span class="pln">composer </span><span class="pun">--</span><span class="pln">install</span><span class="pun">-</span><span class="pln">dir</span><span class="pun">=</span><span class="str">/usr/</span><span class="kwd">local</span><span class="pun">/</span><span class="pln">bin</span>
通过运行以下命令验证编辑器安装:
<span class="pln">composer </span><span class="pun">--</span><span class="pln">version</span>
输出:
<span class="pun">[</span><span class="pln">root@idroot</span><span class="pun">.</span><span class="pln">us </span><span class="pun">~]#</span><span class="pln"> composer </span><span class="typ">Do</span> <span class="kwd">not</span><span class="pln"> run </span><span class="typ">Composer</span> <span class="kwd">as</span><span class="pln"> root</span><span class="pun">/</span><span class="kwd">super</span><span class="pln"> user</span><span class="pun">!</span> <span class="typ">See</span><span class="pln"> https</span><span class="pun">:</span><span class="com">//getcomposer.org/root for details</span> <span class="typ">Continue</span> <span class="kwd">as</span><span class="pln"> root</span><span class="pun">/</span><span class="kwd">super</span><span class="pln"> user </span><span class="pun">[</span><span class="pln">yes</span><span class="pun">]?</span><span class="pln"> y ______ </span><span class="pun">/</span><span class="pln"> ____</span><span class="pun">/</span><span class="pln">___ ____ ___ ____ ____ ________ _____ </span><span class="str">/ /</span> <span class="pun">/</span><span class="pln"> __ \/ __ </span><span class="str">`__ \/ __ \/ __ \/ ___/ _ \/ ___/ / /___/ /_/ / / / / / / /_/ / /_/ (__ ) __/ / \____/\____/_/ /_/ /_/ .___/\____/____/\___/_/ /_/ Composer version 2.3.10 2022-10-12 16:36:11 Usage: command [options] [arguments]</span>
感谢您使用本教程在您的 Rocky Linux 9 系统上安装 Composer。有关其他帮助或有用信息,我们建议您查看作曲家官方网站。