wesolvit / drupal-init
使用Docker环境和Robo创建Drupal项目。
2.0.4
2020-12-15 20:27 UTC
Requires
- php: >=7.4
- composer-plugin-api: ^1.1|^2.0
- symfony/filesystem: ^4.0
- twig/twig: ^3.0
README

WeSolvIT Drupal init
Create a Drupal project using composer.
目录
关于本项目
许多人会说,“又是另一个创建Drupal项目的”,我会说是的。但这个项目提供了Docker支持。
它将创建你的Drupal(8|9)项目,并附带docker-compose.yml。
它可以交互式使用,也可以不使用(特别是对于CI)。
此插件会为你生成composer.json文件,如果你想要使用Docker和RoboFile.php,以及robo.yml用于自动化。
第一个版本依赖于hussainweb/drupal-composer-init,但现在不再依赖,因为它与composer 2不兼容。
我还取消了Drupal 7的支持以及低于7.4的PHP版本。
入门指南
composer global require wesolvit/drupal-init
mkdir my-new-project
cd my-new-project
composer wesolvit-init
使用方法
该工具会询问你关于项目的一些问题。你可以通过命令行提供一些默认值。以下是一些选项
Usage:
wesolvit-init [options]
Options:
--name=NAME Name of the package [default: "wesolvit/package"]
--description=DESCRIPTION Description of package
--author=AUTHOR Author name of package [default: "Rachid TARSIMI <rachid@wesolv.it>"]
--type[=TYPE] Type of package (e.g. library, project, metapackage, composer-plugin) [default: "project"]
--homepage=HOMEPAGE Homepage of package
--require=REQUIRE Package to require with a version constraint, e.g. foo/bar:1.0.0 or foo/bar=1.0.0 or "foo/bar 1.0.0" (multiple values allowed)
--require-dev=REQUIRE-DEV Package to require for development with a version constraint, e.g. foo/bar:1.0.0 or foo/bar=1.0.0 or "foo/bar 1.0.0" (multiple values allowed)
-c, --core=CORE Drupal Core or distribution, e.g. drupal/core or acquia/lightning [default: "drupal/core-recommended ^8.9"]
-s, --stability=STABILITY Minimum stability (empty or one of: stable, RC, beta, alpha, dev) [default: "dev"]
-l, --license=LICENSE License of package [default: "GPL-3.0-or-later"]
--repository=REPOSITORY Add custom repositories, either by URL or using JSON arrays (multiple values allowed)
-w, --web-dir=WEB-DIR Specify the docroot (defaults to web) [default: "./"]
--docker[=DOCKER] Use docker [default: true]
--docker-network[=DOCKER-NETWORK] Docker network [default: "default"]
--docker-image[=DOCKER-IMAGE] Docker image [default: true]
--docker-php-fpm[=DOCKER-PHP-FPM] Docker image with PHP-FPM [default: true]
--docker-image-php-name[=DOCKER-IMAGE-PHP-NAME] Docker image php name [default: "php:7.4-fpm-alpine"]
--docker-image-web-name[=DOCKER-IMAGE-WEB-NAME] Docker image web name [default: "nginx:alpine"]
--docker-image-db-name[=DOCKER-IMAGE-DB-NAME] Docker image database name [default: "yobasystems/alpine-mariadb"]
--app-dir[=APP-DIR] Application directory [default: "."]
--app-port[=APP-PORT] Application port [default: "80"]
--app-user-uid[=APP-USER-UID] Application user id [default: "1000"]
--app-user-gid[=APP-USER-GID] Application group id [default: "1000"]
--drupal-uri[=DRUPAL-URI] Drupal URI [default: "https://"]
--drupal-root[=DRUPAL-ROOT] Drupal root path [default: "/var/www/html"]
--drupal-admin-name[=DRUPAL-ADMIN-NAME] Drupal admin name [default: "admin"]
--drupal-admin-pass[=DRUPAL-ADMIN-PASS] Drupal admin password [default: "pass"]
--drupal-admin-mail[=DRUPAL-ADMIN-MAIL] Drupal admin mail [default: "mail@mail.com"]
--drupal-profile[=DRUPAL-PROFILE] Drupal profile [default: "standard"]
--drupal-language[=DRUPAL-LANGUAGE] Drupal language [default: "en"]
--drupal-db-name[=DRUPAL-DB-NAME] Drupal database name [default: "drupal"]
--drupal-db-host[=DRUPAL-DB-HOST] Drupal database host [default: "db"]
--drupal-db-port[=DRUPAL-DB-PORT] Drupal database port [default: "3306"]
--drupal-db-user[=DRUPAL-DB-USER] Drupal database user [default: "drupal"]
--drupal-db-pass[=DRUPAL-DB-PASS] Drupal database password [default: "drupal"]
--drupal-site-name[=DRUPAL-SITE-NAME] Drupal site name [default: "Drupal 8"]
--drupal-site-mail[=DRUPAL-SITE-MAIL] Drupal site mail [default: "site@mail.com"]
--drush-bin-path[=DRUSH-BIN-PATH] Drush path [default: "./bin/drush"]
--no-install-dependencies[=NO-INSTALL-DEPENDENCIES] Install dependencies [default: true]
-h, --help Display this help message
-q, --quiet Do not output any message
-V, --version Display this application version
--ansi Force ANSI output
--no-ansi Disable ANSI output
-n, --no-interaction Do not ask any interactive question
--profile Display timing and memory usage information
--no-plugins Whether to disable plugins.
-d, --working-dir=WORKING-DIR If specified, use the given directory as working directory.
--no-cache Prevent use of the cache
-v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
Help:
The wesolvit-init command creates a composer project
in the working directory.
It generates the composer.json, docker-compose.yml, docker files
for Apache-MariaDB-PHP stack, robo.yml, RoboFile.php and provides aliases
to execute drush, drupal console, composer and robo inside the docker container.
php composer.phar wesolvit-init
示例
# In each new terminal:
. .aliases
# Instead of
docker-compose exec -u www-data ./bin/robo install
# You can do
robo install
# Instead of
docker-compose exec -u www-data drupal ./bin/drush --root=/var/www/html -l https:// cr
# You can do
drush cr
使用composer wesolvit-init --no-interactive
生成的文件列表
├── .aliases
├── composer.json
├── docker
│ ├── nginx
│ │ └── site.conf
│ └── web
│ └── php-dev.ini
├── docker-compose.yml
├── drush
│ └── Commands
│ ├── custom
│ └── .gitignore
├── .env
├── .gitignore
├── modules
│ ├── custom
│ └── .gitignore
├── profiles
│ ├── custom
│ └── .gitignore
├── RoboFile.php
├── robo.yml
└── themes
├── custom
└── .gitignore
Docker支持
支持Docker有两种方式,一种是通过镜像,另一种是通过Dockerfile。
提供了两个Dockerfile,一个用于使用Apache的PHP,另一个用于使用mariadb的数据库。
当使用镜像时,你可以选择使用php-fpm,其中你需要一个PHP镜像和一个nginx镜像。
Docker示例
# No FPM
composer wesolvit-init --docker-php-fpm=no
# No image, but with the provided Dockerfiles
composer weesolvit-init --docker-image=no
# FPM with a different fpm image.
composer weesolvit-init --docker-image-php-name=my.private.registry/my-php-image:my-tag
# CI, generate files and install project
composer weesolvit-init --no-interaction --drupal-db-name=${JENKINS_DB_PWD} --no-install-dependencies=no
. .aliases
docker-compose up -d
robo install
#No docker
composer wesolvit-init --no-interaction --docker=no --no-install-dependencies=no
./bin/robo install
请随意调整docker-compose,Dockerfile和别名文件以适应你的使用。
未来计划
接下来将有什么
- 支持traefik
- 测试
- 自定义Dockerfile
- PHP-FPM负载均衡器的替代选择。(例如Apache)
许可协议
本软件基于GNU GENERAL PUBLIC LICENSE Version 3许可协议发布。请参阅LICENSE
文件以获取更多信息。