composer 源l:_快速提示:使用Composer设置Drupal 8!

composer 源l:

Drupal 8 logo

The recommended approach to getting started with Drupal 8 is now via Composer. An official project template has been created for this. We will create our project directly using the template, which is also available on Packagist.

现在推荐通过Composer开始使用Drupal 8。 为此已创建一个官方项目模板 。 我们将直接使用模板创建项目,该模板也可在Packagist获得

To create a new project based on this template we can run the following Composer command:

要基于此模板创建新项目,我们可以运行以下Composer命令:

composer create-project drupal-composer/drupal-project:8.x-dev my_project --stability dev --no-interaction

This Composer command will pull in the template from Packagist and run a few Drupal specific scripts to prepare our project for installation. The only thing left to do is point our browser to the web/ directory (since that is where the index.php file is) and run the installer as usual.

这个Composer命令将从Packagist中提取模板,并运行一些Drupal特定的脚本来准备要安装的项目。 剩下要做的唯一事情就是将浏览器指向web/目录(因为index.php文件所在的位置),然后照常运行安装程序。

This template comes with a /web folder that contains, among other things, the main folders of a Drupal installation that are no longer considered part of Drupal core (such as the index.php file or the modules and themes folders). Additionally, it comes with an autoload.php file used by Drupal that simply points to the Composer vendor/ directory, one folder up. So all PHP libraries are now handled from one single place.

该模板带有一个/web文件夹,其中除其他外,其中包含Drupal安装的主要文件夹,这些不再被视为Drupal核心的一部分(例如index.php文件或modules和themes文件夹)。 此外,它还附带了Drupal使用的autoload.php文件,该文件仅指向Composer vendor/目录(一个文件夹)。 因此,所有PHP库现在都可以从一个地方处理。

The template’s composer.json file requires the latest stable Drupal core + some additional helper tools such as Drush and the Drupal Console. Additionally, it adds the Drupal specific Packagist repository from where we can install Drupal contributed modules, themes and profiles (that get automatically installed in the right place).

模板的composer.json文件需要最新的稳定Drupal核心+一些其他辅助工具,例如Drush和Drupal Console 。 另外,它添加了Drupal特定的Packagist存储库,我们可以在其中安装Drupal贡献的模块,主题和配置文件(这些文件,主题和配置文件会自动安装在正确的位置)。

If we want to add a Drupal contributed module, we need to find it on the Drupal Packagist and require it in our project via Composer:

如果要添加Drupal贡献模块,则需要在Drupal Packagist上找到它,并通过Composer在我们的项目中需要它:

composer require drupal/ctools

This will add the Ctools module directly to our web/modules/ directory and update our composer.json file.

这会将Ctools模块直接添加到我们的web/modules/目录中,并更新我们的composer.json文件。

The project template also comes with a .gitignore file that keeps Drupal core and all the contributed packages outside of Git, similar to the regular vendor/ packages. So based on an updated composer.json file, we can maintain a smaller Git repository and recreate our project any time. A lot of the benefits of Drush Make have now been incorporated into a Composer flow.

该项目模板还带有一个.gitignore文件,该文件保留了Drupal核心以及Git之外的所有贡献软件包,类似于常规的vendor/软件包。 因此,基于更新的composer.json文件,我们可以维护一个较小的Git存储库并随时重新创建我们的项目。 现在, Drush Make的许多优点已被整合到Composer流程中。

结论 (Conclusion)

Drupal 8 has come a long way in catching up with other major PHP software. The possibility of fully managing it via Composer, either as a main project or even just as part of a bigger set of applications, is a testament to the community effort that went in.

Drupal 8在赶上其他主要PHP软件方面已经走了很长一段路。 通过Composer对其进行完全管理的可能性,可以作为主要项目,也可以作为更大的应用程序的一部分进行 ,这证明了社区付出的努力。

翻译自: https://www.sitepoint.com/quick-tip-set-up-drupal-8-with-composer/

composer 源l:

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值