0. はじめに
『Drupal 9 Web開発ことはじめ』記載の環境構築がうまくいかなかったのでメモ。
0-1. 全体の流れ
0-2. 前提条件
-
Docker
インストール済み -
Homebrew
インストール済み
0-3.開発環境
key | value |
---|---|
Drupal | 9 |
PHP | 8.1 |
Docker | 20.10.21 |
Homebrew | 3.4.10 |
OS | macOS Ventura 13.1 |
1. DDEV
1-1. installation
local
$ brew install drud/ddev/ddev
$ brew upgrade ddev
1-2. error
local
$ brew install drug/ddev/ddev
Error: An exception occurred within a child process:
CompilerSelectionError: drud/ddev/ddev cannot be built with any available compilers.
Install GNU's GCC:
brew install gcc
-
gcc
をインストールしろと言われる。
local
$ brew install gcc
Error: gcc: the bottle needs the Apple Command Line Tools to be installed.
You can install them, if desired, with:
xcode-select --install
If you're feeling brave, you can try to install from source with:
brew install --build-from-source gcc
-
xcode-select
が必要らしい。
local
$ xcode-select --install
xcode-select: note: install requested for command line developer tools
$ brew install drud/ddev/ddev
$ ddev
Create and maintain a local web development environment.
Docs: https://ddev.readthedocs.io
Support: https://ddev.readthedocs.io/en/stable/users/support
Usage:
ddev [command]
Available Commands:
=== 略 ===
2. Drupal
2-1. installation
local
$ mkdir my-drupal9-site
$ cd my-drupal9-site
$ ddev config --project-type=drupal10 --docroot=web --create-docroot
$ ddev start
$ ddev composer create drupal/recommended-project
$ ddev composer require drush/drush
$ ddev drush site:install --account-name=admin --account-pass=admin -y
$ ddev drush uli
$ ddev launch
2-2. lang
2-3. locale
3. git
3-1. .gitignore
- サンプルは
drupal8
ですが、9系のサンプルを見つけたら更新します。
local
$ cd my-drupal9-site
$ touch .gitignore
.gitignore
# Ignore directories generated by Composer
/drush/contrib/
/vendor/
/web/core/
/web/modules/contrib/
/web/themes/contrib/
/web/profiles/contrib/
/web/libraries/
# Ignore all site specific data
/web/sites/*
!/web/sites/default/
!/web/sites/example.sites.php
# Ignore IDE files
/.idea/
/.vscode/
*.iml
*.code-workspace
# Ignore all log files
*.log
# Ignore node modules
node_modules
# Ignore some css related stuff
*.css.map
*.css.map.map
# Ignore default text files
/CHANGELOG.txt
/COPYRIGHT.txt
/INSTALL*.txt
/LICENSE.txt
/MAINTAINERS.txt
/UPGRADE.txt
/README.txt
sites/README.txt
sites/all/modules/README.txt
sites/all/themes/README.txt
4. appendix
- Drupal9は、PHP8.1以上がインストールされていないとエラーが出る。
local
$ ddev composer require drush/drush
Your requirements could not be resolved to an installable set of packages.
Problem 1
- drupal/core 10.0.0 requires php >=8.1.0 -> your php version (8.0.26) does not satisfy that requirement.
- drupal/core-recommended 10.0.0 requires drupal/core 10.0.0 -> satisfiable by drupal/core[10.0.0].
- drupal/core-recommended is locked to version 10.0.0 and an update of this package was not requested.
You can also try re-running composer require with an explicit version constraint, e.g. "composer require drush/drush:*" to figure out if any version is installable, or "composer require drush/drush:^2.1" if you know which you need.
Installation failed, reverting ./composer.json and ./composer.lock to their original content.
composer [require drush/drush] failed, composer command failed: exit status 2. stderr=
.ddev/config.yml
- php_version: "8.0"
+ php_version: "8.1"
Reference