Skip to content
This repository was archived by the owner on Feb 13, 2023. It is now read-only.

Commit f1c07ee

Browse files
authored
Merge pull request #1333 from oxyc/docs-other-apps
Add docs on using Drupal VM with other application eg Wordpress
2 parents b25caf7 + fe924a6 commit f1c07ee

File tree

2 files changed

+108
-0
lines changed

2 files changed

+108
-0
lines changed
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
While Drupal VM caters specifically to Drupal, and support for and compatibility with other PHP applications isn't guaranteed, Drupal VM is flexible enough to work with PHP applications besides Drupal.
2+
3+
## Wordpress
4+
5+
To integrate Drupal VM with an existing Wordpress project such as [bedrock](https://github.com/roots/bedrock), follow the documentation on using [Drupal VM as a Composer dependency](http://docs.drupalvm.com/en/latest/deployment/composer-dependency/).
6+
7+
Begin by forking/cloning `bedrock` as a boilerplate for your application, and require Drupal VM as a development dependency.
8+
9+
```yaml
10+
composer require --dev geerlingguy/drupal-vm
11+
```
12+
13+
Configure the VM by creating a `config/config.yml`:
14+
15+
```yaml
16+
vagrant_hostname: bedrock.dev
17+
vagrant_machine_name: bedrock
18+
19+
vagrant_synced_folders:
20+
- local_path: .
21+
destination: /var/www/wordpress
22+
type: nfs
23+
create: true
24+
25+
# Needs to match with what we have in .env and vagrant_synced_folders.
26+
drupal_core_path: "/var/www/wordpress/web"
27+
drupal_domain: "{{ vagrant_hostname }}"
28+
drupal_db_user: wordpress
29+
drupal_db_password: wordpress
30+
drupal_db_name: wordpress
31+
32+
# Disable Drupal specific features.
33+
drupal_build_composer_project: false
34+
drupal_install_site: false
35+
configure_drush_aliases: false
36+
37+
# Remove some Drupal extras such as `drupalconsole` and `drush`
38+
installed_extras:
39+
- adminer
40+
- mailhog
41+
- pimpmylog
42+
43+
# Add wp-cli
44+
composer_global_packages:
45+
- { name: hirak/prestissimo, release: '^0.3' }
46+
- { name: wp-cli/wp-cli, release: '^1.0.0' }
47+
```
48+
49+
Create the delegating `Vagrantfile` in the root of the project:
50+
51+
```rb
52+
# The absolute path to the root directory of the project. Both Drupal VM and
53+
# the config file need to be contained within this path.
54+
ENV['DRUPALVM_PROJECT_ROOT'] = "#{__dir__}"
55+
# The relative path from the project root to the config directory where you
56+
# placed your config.yml file.
57+
ENV['DRUPALVM_CONFIG_DIR'] = "config"
58+
# The relative path from the project root to the directory where Drupal VM is located.
59+
ENV['DRUPALVM_DIR'] = "vendor/geerlingguy/drupal-vm"
60+
61+
# Load the real Vagrantfile
62+
load "#{__dir__}/#{ENV['DRUPALVM_DIR']}/Vagrantfile"
63+
```
64+
65+
Edit your `.env` file to match the values you set in `config/config.yml`:
66+
67+
```
68+
DB_NAME=wordpress
69+
DB_USER=wordpress
70+
DB_PASSWORD=wordpress
71+
DB_HOST=localhost
72+
73+
WP_ENV=development
74+
WP_HOME=http://bedrock.dev
75+
WP_SITEURL=${WP_HOME}/wp
76+
```
77+
78+
Ignore local Drupal VM configuration files by adding the following to your `.gitignore`:
79+
80+
```
81+
Vagrantfile.local
82+
config/local.config.yml
83+
```
84+
85+
Add a wp-cli `@dev` alias that points to the VM by editing the `wp-cli.yml` file:
86+
87+
```yaml
88+
path: web/wp
89+
90+
@dev:
91+
ssh: [email protected]/var/www/wordpress/web/wp
92+
url: bedrock.dev
93+
```
94+
95+
For passwordless login with `wp-cli` add the following to your SSH config `~/.ssh/config`:
96+
97+
```
98+
Host bedrock.dev
99+
StrictHostKeyChecking no
100+
IdentityFile ~/.vagrant.d/insecure_private_key
101+
```
102+
103+
Provision the VM and import your database.
104+
105+
```sh
106+
vagrant up
107+
```

mkdocs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,3 +72,4 @@ pages:
7272
- 'Drupal 6 Notes': 'other/drupal-6.md'
7373
- 'Drupal VM Management Tools': 'other/management-tools.md'
7474
- 'Deploying to a production environment': 'other/production.md'
75+
- 'Wordpress or other applications': 'other/wordpress-other-applications.md'

0 commit comments

Comments
 (0)