Skip to content

Latest commit

 

History

History
177 lines (117 loc) · 3.93 KB

local-development.md

File metadata and controls

177 lines (117 loc) · 3.93 KB

Local development environment setup

Note

Please note we no longer use MAMP for local development and have moved to DDEV.

Terminal

Create Sites folder:

mkdir ~/Sites

You should clone all projects into this folder, using SSH to clone from GitHub since this uses SSH keys to authenticate with GitHub. As an example, to clone this repo you'd use:

git clone git@github.com:studio24/mac-setup.git

DEV

DDEV is a simple development environment which uses Docker to manage local development environments. It's mostly fully automated and allows us to configure software versions (e.g. PHP, MySQL) and store these in version control, so everyone uses the same version.

Installing OrbStack

OrbStack is a fast and simple alternative to Docker Desktop. We have team licenses.

Please note if you have Docker Desktop already installed we recommend uninstalling this first.

Installation instructions:

  • Login to the OrbStack website using your GitHub account
  • Install the app via brew install orbstack
  • Open OrbStack to configure it
    • Select Docker to use Docker containers
  • Sign in to OrbStack to use the professional license (sign in button bottom-left or Account > Sign in)
  • Open OrbStack Settings
    • In General tick Automatically download updates
    • If you want OrbStack to automatically start on login, tick Start at login

OrbStack should prompt when it needs updating (you'll need your Mac admin password to update software).

Note: to add a member to the Studio 24 Orbstack account admin users can go to the dashboard, select Studio 24 organisation > Settings > Members > Invite a member.

Installing DDEV

You must have Docker installed locally first (OrbStack).

To install DDEV, run:

brew install ddev/ddev/ddev

The first time you use DDEV it will ask:

May we send anonymous DDEV usage statistics and errors?

Answer no.

Upgrading DDEV

brew upgrade ddev/ddev/ddev

Using DDEV

To start DDEV run:

ddev start

To view the website in your default browser:

ddev launch

To list all current projects:

ddev list

To restart DDEV (for example if config has changed) run:

ddev restart

To stop DDEV run

ddev stop

You can also shut down all DDEV projects via:

ddev poweroff

Mailpit

By default all emails sent from your website are captured in a tool called Mailpit, which allows you to review emails sent by the website.

To open Mailpit run:

ddev mailpit

Using a database

To access the database via TablePlus:

ddev tableplus

Import a database via an SQL file:

ddev import-db < [filename]

Export SQL files for a database:

ddev export-db

Xdebug

Xdebug comes with it by default. To enable Xdebug run:

ddev xdebug on

To disable Xdebug:

ddev xdebug off

To toggle Xdebug on and off:

ddev xdebug toggle

Read instructions on how to setup Xdebug in PHPstorm and VSCode.

Running commands in DDEV

All commands must be run via ddev to ensure you are using the correct version of PHP. For example:

ddev composer install

Some useful commands from the DDEV docs:

  • ddev composer gives access to Composer
  • ddev artisan (Laravel only) gives direct access to the Laravel artisan CLI
  • ddev console (Symfony only) gives access to the Symfony console CLI
  • ddev craft (Craft CMS only) gives access to the Craft CLI
  • ddev npm gives direct access to the npm CLI
  • ddev wp (WordPress) give direct access to the WP CLI
  • ddev ssh takes you into the web container
  • ddev exec [command] executes a command inside the web container