This is a fork of the official Trellis repo, configured for Codelight's use. It should be kept more or less up to date with the official repo. Note that this repository is public.
For anything not covered in the quick start guide below, see the official Trellis docs or the official repo.
Instructions below assume you're running a Windows machine.
dev/ # → Root folder for all projects
├── trellis/ # → Your clone of this repository
└── site1/ # → A Bedrock-based WordPress site
└── web/
├── app/ # → WordPress content directory (themes, plugins, etc.)
└── wp/ # → WordPress core (don't touch!)
└── site2/ # → A Bedrock-based WordPress site
└── web/
├── app/ # → WordPress content directory (themes, plugins, etc.)
└── wp/ # → WordPress core (don't touch!)
└── site3/ # → A Bedrock-based WordPress site
└── web/
├── app/ # → WordPress content directory (themes, plugins, etc.)
└── wp/ # → WordPress core (don't touch!)
Note: The instructions here prefix Trellis folder with an underscore. This differs from the official docs.
- Ensure you've installed all requirements listed here
- In Windows, open git bash & create a new root directory:
$ mkdir dev && cd dev
- Clone codelight/trellis:
$ git clone --depth=1 [email protected]:codelight-eu/trellis.git _trellis
- Clone codelight/bedrock:
$ git clone --depth=1 [email protected]:codelight-eu/bedrock.git [SITENAME] && rm -rf [SITENAME]/.git
Maybe use [SITENAME].local as the folder name. - Make a copy of the local environment config folder example (will not be stored in the repo):
$ cp -r _trellis/group_vars/development.example _trellis/group_vars/development
- Configure your WordPress site in
_trellis/group_vars/development/wordpress_sites.yml
and in_trellis/group_vars/development/vault.yml
(use .local instead of .dev) - Run
$ cd _trellis && vagrant up
- Run
$ vagrant ssh
to access your new shiny box via SSH
- In Windows, clone our composer repo into the auto-generated tools folder:
$ cd dev/_tools && git clone [email protected]:codelight-eu/composer-global.git composer
todo: add a script to make this happen automagically?
- In Windows, open git bash & go to your root directory:
$ cd dev
- Clone codelight/bedrock:
$ git clone --depth=1 [email protected]:codelight-eu/bedrock.git [NEW_SITENAME] && rm -rf [NEW_SITENAME]/.git
Maybe use [SITENAME].local as the folder name. - Configure your WordPress site in
_trellis/group_vars/development/wordpress_sites.yml
and in_trellis/group_vars/development/vault.yml
(use .local instead of .dev) - Run
$ cd _trellis && vagrant halt
then$ vagrant up
and then$ vagrant provision
While Composer works on both the host (Windows) machine and the guest (Vagrant) machine, you'll probably want to run composer install
from inside the Vagrant box. Many of the composer packages used have specific requirements for various PHP components, which might be missing from your Windows machine. Running composer install
from inside Vagrant bypasses that problem.
Building the theme should also be done on the host (Windows) machine. Go to the theme folder and run yarn run build:production
Codelight's private repositories are stored in our global composer.json file, which is merged to every site's own composer.json using Composer Merge Plugin. If you need to add a new private or github-based repository, please add it to composer.global.json located in dev/_tools/composer/composer.global.json
, commit and push.
When you install a plugin from github via composer, it comes with the git repo set up. In most cases, you should be able to use that same repository for development and push your changes back up to github.
In order to override the default config with local values, create a file called vagrant.local.yml in trellis/ directory. Values defined in this file will override the values defined in vagrant.default.yml. For example, to increase the RAM assigned to the virtual machine, add the following line to vagrant.local.yml
vagrant_memory: 2048
-
Make sure sitename.local is in hosts file without www at the beginning too. Local site opens from
http://sitename.local
-
If you change folder names you may need to do vagrant halt and up for it to register.
-
Vagrant currently doesn't work with VirtualBox 5.2. Use 5.1.3 instead
-
In case you are seeing the following error: "Vagrant was unable to mount VirtualBox shared folders. This is usually because the filesystem "vboxsf" is not available.", before running
vagrant up
run the following commands:
vagrant plugin install vagrant-vbguest
vagrant plugin install vagrant-winnfsd
vagrant plugin install vagrant-bindfs