Skip to content

Commit 564c62f

Browse files
committed
Updates for Drupal 10.x and React 18.
1 parent da68d9e commit 564c62f

26 files changed

+67284
-55102
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
/drupal/web/sites/*/translations
2121
/drupal/web/sites/*/tmp
2222
/drupal/web/sites/*/cache
23+
/drupal/web/themes/react_example_theme/js/dist_dev
2324

2425
# Ignore testing related files
2526
/drupal/web/sites/simpletest

README.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
1-
# Drupalize.Me React & Drupal 8 Code Examples
1+
# Drupalize.Me React & Drupal Code Examples
22

33
This repo contains the example code used in the https://drupalize.me/series/drupal-8-and-reactjs series.
44

55
**Note:** The `hello-world` branch contains a trimmed down version of the code that reflects the application as it would be after completing this tutorial covering how to [Connect React to a Drupal Theme or Module](https://drupalize.me/tutorial/connect-react-drupal-theme-or-module?p=3253).
66

7-
## Drupal 8
7+
## Drupal
88

9-
The /drupal directory contains a Drupal 8 project with basic configuration for JSON:API, and to demonstrate embedding a React application inside a Drupal theme or module.
9+
The /drupal directory contains a Drupal 10 project with basic configuration for JSON:API, and to demonstrate embedding a React application inside a Drupal theme or module.
10+
11+
See the `drupal-9` branch for older examples including Drupal 8/9 and React 16.
1012

1113
Install all the Drupal dependencies:
1214

@@ -51,14 +53,14 @@ npm run start:hmr
5153

5254
## Decoupled React Application
5355

54-
The _/react-decoupled_ directory contains an example decoupled React application built with create-react-app. It is built to interact with the API provided by Drupal 8 installed in _/drupal_.
56+
The _/react-decoupled_ directory contains an example decoupled React application built with create-react-app. It is built to interact with the API provided by Drupal installed in _/drupal_.
5557

5658
To download dependencies and start the local development server run:
5759

5860
```bash
5961
cd react-decoupled
60-
yarn install
61-
yarn run start
62+
npm install
63+
npm run start
6264
```
6365

6466
You might need to update some configuration to make sure it points to your local Drupal installation.

drupal/.ddev/config.yaml

Lines changed: 172 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,21 @@
1-
APIVersion: v1.13.0
21
name: react-tutorials-2
3-
type: drupal8
2+
type: drupal10
43
docroot: web
5-
php_version: "7.3"
4+
php_version: "8.2"
65
webserver_type: nginx-fpm
76
router_http_port: "80"
87
router_https_port: "443"
98
xdebug_enabled: false
109
additional_hostnames: []
1110
additional_fqdns: []
12-
nfs_mount_enabled: false
13-
provider: default
11+
database:
12+
type: mariadb
13+
version: "10.4"
1414
use_dns_when_possible: true
15-
timezone: ""
15+
composer_version: "2"
16+
web_environment: []
1617

17-
18-
# This config.yaml was created with ddev version v1.13.0
19-
# webimage: drud/ddev-webserver:v1.13.0
20-
# dbimage: drud/ddev-dbserver-mariadb-10.2:v1.13.0
21-
# dbaimage: phpmyadmin/phpmyadmin:5
22-
# However we do not recommend explicitly wiring these images into the
23-
# config.yaml as they may break future versions of ddev.
24-
# You can update this config.yaml using 'ddev config'.
25-
26-
# Key features of ddev's config.yaml:
18+
# Key features of DDEV's config.yaml:
2719

2820
# name: <projectname> # Name of the project, automatically provides
2921
# http://projectname.ddev.site and https://projectname.ddev.site
@@ -32,38 +24,64 @@ timezone: ""
3224

3325
# docroot: <relative_path> # Relative path to the directory containing index.php.
3426

35-
# php_version: "7.3" # PHP version to use, "5.6", "7.0", "7.1", "7.2", "7.3", "7.4"
27+
# php_version: "8.1" # PHP version to use, "5.6", "7.0", "7.1", "7.2", "7.3", "7.4", "8.0", "8.1", "8.2", "8.3"
3628

37-
# You can explicitly specify the webimage, dbimage, dbaimage lines but this
38-
# is not recommended, as the images are often closely tied to ddev's' behavior,
29+
# You can explicitly specify the webimage but this
30+
# is not recommended, as the images are often closely tied to DDEV's' behavior,
3931
# so this can break upgrades.
4032

4133
# webimage: <docker_image> # nginx/php docker image.
42-
# dbimage: <docker_image> # mariadb docker image.
43-
# dbaimage: <docker_image>
4434

45-
# mariadb_version and mysql_version
46-
# ddev can use many versions of mariadb and mysql
47-
# However these directives are mutually exclusive
48-
# mariadb_version: 10.2
49-
# mysql_version: 8.0
35+
# database:
36+
# type: <dbtype> # mysql, mariadb, postgres
37+
# version: <version> # database version, like "10.4" or "8.0"
38+
# MariaDB versions can be 5.5-10.8 and 10.11, MySQL versions can be 5.5-8.0
39+
# PostgreSQL versions can be 9-16.
40+
41+
# router_http_port: <port> # Port to be used for http (defaults to global configuration, usually 80)
42+
# router_https_port: <port> # Port for https (defaults to global configuration, usually 443)
5043

51-
# router_http_port: <port> # Port to be used for http (defaults to port 80)
52-
# router_https_port: <port> # Port for https (defaults to 443)
44+
# xdebug_enabled: false # Set to true to enable Xdebug and "ddev start" or "ddev restart"
45+
# Note that for most people the commands
46+
# "ddev xdebug" to enable Xdebug and "ddev xdebug off" to disable it work better,
47+
# as leaving Xdebug enabled all the time is a big performance hit.
5348

54-
# xdebug_enabled: false # Set to true to enable xdebug and "ddev start" or "ddev restart"
49+
# xhprof_enabled: false # Set to true to enable Xhprof and "ddev start" or "ddev restart"
5550
# Note that for most people the commands
56-
# "ddev exec enable_xdebug" and "ddev exec disable_xdebug" work better,
57-
# as leaving xdebug enabled all the time is a big performance hit.
51+
# "ddev xhprof" to enable Xhprof and "ddev xhprof off" to disable it work better,
52+
# as leaving Xhprof enabled all the time is a big performance hit.
5853

59-
# webserver_type: nginx-fpm # Can be set to apache-fpm or apache-cgi as well
54+
# webserver_type: nginx-fpm, apache-fpm, or nginx-gunicorn
6055

6156
# timezone: Europe/Berlin
6257
# This is the timezone used in the containers and by PHP;
6358
# it can be set to any valid timezone,
6459
# see https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
6560
# For example Europe/Dublin or MST7MDT
6661

62+
# composer_root: <relative_path>
63+
# Relative path to the Composer root directory from the project root. This is
64+
# the directory which contains the composer.json and where all Composer related
65+
# commands are executed.
66+
67+
# composer_version: "2"
68+
# You can set it to "" or "2" (default) for Composer v2 or "1" for Composer v1
69+
# to use the latest major version available at the time your container is built.
70+
# It is also possible to use each other Composer version channel. This includes:
71+
# - 2.2 (latest Composer LTS version)
72+
# - stable
73+
# - preview
74+
# - snapshot
75+
# Alternatively, an explicit Composer version may be specified, for example "2.2.18".
76+
# To reinstall Composer after the image was built, run "ddev debug refresh".
77+
78+
# nodejs_version: "18"
79+
# change from the default system Node.js version to another supported version, like 16, 18, 20.
80+
# Note that you can use 'ddev nvm' or nvm inside the web container to provide nearly any
81+
# Node.js version, including v6, etc.
82+
# You only need to configure this if you are not using nvm and you want to use a major
83+
# version that is not the default.
84+
6785
# additional_hostnames:
6886
# - somename
6987
# - someothername
@@ -76,8 +94,26 @@ timezone: ""
7694
# would provide http and https URLs for "example.com" and "sub1.example.com"
7795
# Please take care with this because it can cause great confusion.
7896

79-
# upload_dir: custom/upload/dir
80-
# would set the destination path for ddev import-files to custom/upload/dir.
97+
# upload_dirs: "custom/upload/dir"
98+
#
99+
# upload_dirs:
100+
# - custom/upload/dir
101+
# - ../private
102+
#
103+
# would set the destination paths for ddev import-files to <docroot>/custom/upload/dir
104+
# When Mutagen is enabled this path is bind-mounted so that all the files
105+
# in the upload_dirs don't have to be synced into Mutagen.
106+
107+
# disable_upload_dirs_warning: false
108+
# If true, turns off the normal warning that says
109+
# "You have Mutagen enabled and your 'php' project type doesn't have upload_dirs set"
110+
111+
# ddev_version_constraint: ""
112+
# Example:
113+
# ddev_version_constraint: ">= 1.22.4"
114+
# This will enforce that the running ddev version is within this constraint.
115+
# See https://github.com/Masterminds/semver#checking-version-constraints for
116+
# supported constraint formats
81117

82118
# working_dir:
83119
# web: /var/www/html
@@ -86,15 +122,28 @@ timezone: ""
86122
# These values specify the destination directory for ddev ssh and the
87123
# directory in which commands passed into ddev exec are run.
88124

89-
# omit_containers: ["dba", "ddev-ssh-agent"]
90-
# would omit the dba (phpMyAdmin) and ddev-ssh-agent containers. Currently
91-
# only those two containers can be omitted here.
92-
# Note that these containers can also be omitted globally in the
93-
# ~/.ddev/global_config.yaml or with the "ddev config global" command.
125+
# omit_containers: [db, ddev-ssh-agent]
126+
# Currently only these containers are supported. Some containers can also be
127+
# omitted globally in the ~/.ddev/global_config.yaml. Note that if you omit
128+
# the "db" container, several standard features of DDEV that access the
129+
# database container will be unusable. In the global configuration it is also
130+
# possible to omit ddev-router, but not here.
131+
132+
# performance_mode: "global"
133+
# DDEV offers performance optimization strategies to improve the filesystem
134+
# performance depending on your host system. Should be configured globally.
135+
#
136+
# If set, will override the global config. Possible values are:
137+
# - "global": uses the value from the global config.
138+
# - "none": disables performance optimization for this project.
139+
# - "mutagen": enables Mutagen for this project.
140+
# - "nfs": enables NFS for this project.
141+
#
142+
# See https://ddev.readthedocs.io/en/latest/users/install/performance/#nfs
143+
# See https://ddev.readthedocs.io/en/latest/users/install/performance/#mutagen
94144

95-
# nfs_mount_enabled: false
96-
# Great performance improvement but requires host configuration first.
97-
# See https://ddev.readthedocs.io/en/stable/users/performance/#using-nfs-to-mount-the-project-into-the-container
145+
# fail_on_hook_fail: False
146+
# Decide whether 'ddev start' should be interrupted by a failing hook
98147

99148
# host_https_port: "59002"
100149
# The host port binding for https can be explicitly specified. It is
@@ -112,13 +161,15 @@ timezone: ""
112161
# The host port binding for the ddev-dbserver can be explicitly specified. It is dynamic
113162
# unless explicitly specified.
114163

115-
# phpmyadmin_port: "1000"
116-
# The PHPMyAdmin port can be changed from the default 8036
164+
# mailpit_http_port: "8025"
165+
# mailpit_https_port: "8026"
166+
# The Mailpit ports can be changed from the default 8025 and 8026
117167

118-
# mailhog_port: "1001"
119-
# The MailHog port can be changed from the default 8025
168+
# host_mailpit_port: "8025"
169+
# The mailpit port is not normally bound on the host at all, instead being routed
170+
# through ddev-router, but it can be bound directly to localhost if specified here.
120171

121-
# webimage_extra_packages: [php-yaml, php7.3-ldap]
172+
# webimage_extra_packages: [php7.4-tidy, php-bcmath]
122173
# Extra Debian packages that are needed in the webimage can be added here
123174

124175
# dbimage_extra_packages: [telnet,netcat]
@@ -136,21 +187,87 @@ timezone: ""
136187
# If you prefer you can change this to "ddev.local" to preserve
137188
# pre-v1.9 behavior.
138189

139-
# ngrok_args: --subdomain mysite --auth username:pass
190+
# ngrok_args: --basic-auth username:pass1234
140191
# Provide extra flags to the "ngrok http" command, see
141-
# https://ngrok.com/docs#http or run "ngrok http -h"
192+
# https://ngrok.com/docs/ngrok-agent/config or run "ngrok http -h"
142193

143194
# disable_settings_management: false
144-
# If true, ddev will not create CMS-specific settings files like
145-
# Drupal's settings.php/settings.ddev.php or TYPO3's AdditionalSettings.php
195+
# If true, DDEV will not create CMS-specific settings files like
196+
# Drupal's settings.php/settings.ddev.php or TYPO3's AdditionalConfiguration.php
146197
# In this case the user must provide all such settings.
147198

148-
# provider: default # Currently either "default" or "pantheon"
199+
# You can inject environment variables into the web container with:
200+
# web_environment:
201+
# - SOMEENV=somevalue
202+
# - SOMEOTHERENV=someothervalue
203+
204+
# no_project_mount: false
205+
# (Experimental) If true, DDEV will not mount the project into the web container;
206+
# the user is responsible for mounting it manually or via a script.
207+
# This is to enable experimentation with alternate file mounting strategies.
208+
# For advanced users only!
209+
210+
# bind_all_interfaces: false
211+
# If true, host ports will be bound on all network interfaces,
212+
# not the localhost interface only. This means that ports
213+
# will be available on the local network if the host firewall
214+
# allows it.
215+
216+
# default_container_timeout: 120
217+
# The default time that DDEV waits for all containers to become ready can be increased from
218+
# the default 120. This helps in importing huge databases, for example.
219+
220+
#web_extra_exposed_ports:
221+
#- name: nodejs
222+
# container_port: 3000
223+
# http_port: 2999
224+
# https_port: 3000
225+
#- name: something
226+
# container_port: 4000
227+
# https_port: 4000
228+
# http_port: 3999
229+
# Allows a set of extra ports to be exposed via ddev-router
230+
# Fill in all three fields even if you don’t intend to use the https_port!
231+
# If you don’t add https_port, then it defaults to 0 and ddev-router will fail to start.
149232
#
150-
# Many ddev commands can be extended to run tasks before or after the
151-
# ddev command is executed, for example "post-start", "post-import-db",
233+
# The port behavior on the ddev-webserver must be arranged separately, for example
234+
# using web_extra_daemons.
235+
# For example, with a web app on port 3000 inside the container, this config would
236+
# expose that web app on https://<project>.ddev.site:9999 and http://<project>.ddev.site:9998
237+
# web_extra_exposed_ports:
238+
# - name: myapp
239+
# container_port: 3000
240+
# http_port: 9998
241+
# https_port: 9999
242+
243+
#web_extra_daemons:
244+
#- name: "http-1"
245+
# command: "/var/www/html/node_modules/.bin/http-server -p 3000"
246+
# directory: /var/www/html
247+
#- name: "http-2"
248+
# command: "/var/www/html/node_modules/.bin/http-server /var/www/html/sub -p 3000"
249+
# directory: /var/www/html
250+
251+
# override_config: false
252+
# By default, config.*.yaml files are *merged* into the configuration
253+
# But this means that some things can't be overridden
254+
# For example, if you have 'use_dns_when_possible: true'' you can't override it with a merge
255+
# and you can't erase existing hooks or all environment variables.
256+
# However, with "override_config: true" in a particular config.*.yaml file,
257+
# 'use_dns_when_possible: false' can override the existing values, and
258+
# hooks:
259+
# post-start: []
260+
# or
261+
# web_environment: []
262+
# or
263+
# additional_hostnames: []
264+
# can have their intended affect. 'override_config' affects only behavior of the
265+
# config.*.yaml file it exists in.
266+
267+
# Many DDEV commands can be extended to run tasks before or after the
268+
# DDEV command is executed, for example "post-start", "post-import-db",
152269
# "pre-composer", "post-composer"
153-
# See https://ddev.readthedocs.io/en/stable/users/extending-commands/ for more
270+
# See https://ddev.readthedocs.io/en/stable/users/extend/custom-commands/ for more
154271
# information on the commands that can be extended and the tasks you can define
155272
# for them. Example:
156273
#hooks:

drupal/.gitattributes

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,24 +19,24 @@
1919
*.config text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2
2020
*.css text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2
2121
*.dist text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2
22-
*.engine text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2 diff=php
22+
*.engine text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2 diff=php linguist-language=php
2323
*.html text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2 diff=html
24-
*.inc text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2 diff=php
25-
*.install text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2 diff=php
24+
*.inc text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2 diff=php linguist-language=php
25+
*.install text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2 diff=php linguist-language=php
2626
*.js text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2
2727
*.json text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2
2828
*.lock text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2
2929
*.map text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2
3030
*.md text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2
31-
*.module text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2 diff=php
32-
*.php text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2 diff=php
31+
*.module text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2 diff=php linguist-language=php
32+
*.php text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2 diff=php linguist-language=php
3333
*.po text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2
34-
*.profile text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2 diff=php
34+
*.profile text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2 diff=php linguist-language=php
3535
*.script text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2
36-
*.sh text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2 diff=php
36+
*.sh text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2 diff=php linguist-language=php
3737
*.sql text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2
3838
*.svg text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2
39-
*.theme text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2 diff=php
39+
*.theme text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2 diff=php linguist-language=php
4040
*.twig text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2
4141
*.txt text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2
4242
*.xml text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2

drupal/backup-d9.sql.gz

1.16 MB
Binary file not shown.

drupal/backup.sql.gz

-411 KB
Binary file not shown.

0 commit comments

Comments
 (0)