7.1 Local Development
Local development environments should balance consistency across team members with the practical needs of individual projects. Our approach prioritizes getting developers productive quickly while ensuring that the local environment adequately represents the project’s requirements rather than enforcing a one-size-fits-all solution.
The choice of local development environment depends on project complexity, team preferences, and specific technical requirements. Simple projects benefit from lightweight solutions that minimize setup time, while complex applications with multiple services may require more sophisticated containerized environments.
7.1.1 WordPress Development Environments
WordPress projects work well with various local development solutions, each offering different advantages depending on project needs. Local by Flywheel provides an excellent user-friendly interface and handles many WordPress-specific configurations automatically, making it ideal for content-focused sites and rapid prototyping.
Laravel Valet offers a minimalist approach that works particularly well for developers working across multiple WordPress and Laravel projects simultaneously. Its lightweight nature and automatic domain resolution make it efficient for agencies managing numerous client sites.
Docker-based solutions provide consistency and isolation, particularly valuable for projects with specific PHP versions, database requirements, or complex hosting environment replication needs. Custom Docker configurations allow precise control over the development environment when projects require specific server configurations.
The key consideration is ensuring that all team members can run the project locally with minimal friction while maintaining enough environment consistency to prevent “works on my machine” issues during development and deployment.
7.1.2 Laravel Development Environments
Laravel projects span a wide range of complexity, from simple marketing sites to complex multi-service applications, and our development environment choices reflect this diversity. Laravel Valet excels for straightforward Laravel applications, providing fast site switching and minimal resource usage that benefits day-to-day development productivity.
More complex Laravel applications, particularly those requiring multiple databases, queue systems, Redis, or microservice architectures, benefit from containerized development environments. Docker Compose configurations provide reproducible environments that closely mirror production infrastructure while isolating project dependencies.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# Docker Compose example for complex Laravel project
version: '3.8'
services:
app:
build:
context: .
dockerfile: Dockerfile.dev
ports:
- "8000:80"
volumes:
- .:/var/www/html
- vendor_cache:/var/www/html/vendor
environment:
- APP_ENV=local
- DB_HOST=database
- REDIS_HOST=redis
depends_on:
- database
- redis
database:
image: mysql:8.0
environment:
MYSQL_DATABASE: ${DB_DATABASE}
MYSQL_ROOT_PASSWORD: ${DB_PASSWORD}
volumes:
- mysql_data:/var/lib/mysql
ports:
- "3306:3306"
redis:
image: redis:alpine
ports:
- "6379:6379"
queue:
build:
context: .
dockerfile: Dockerfile.dev
command: php artisan queue:work
volumes:
- .:/var/www/html
depends_on:
- database
- redis
environment:
- APP_ENV=local
- DB_HOST=database
- REDIS_HOST=redis
volumes:
mysql_data:
vendor_cache:
Laravel Homestead provides a middle ground, offering a pre-configured Vagrant box with common development tools while maintaining consistency across different operating systems. This approach works well for teams that need more than Valet provides but don’t require the full customization that Docker offers.
7.1.3 Environment Consistency Principles
Regardless of the specific development environment chosen, each project should document its setup requirements clearly and ensure that all team members can achieve a consistent baseline experience. This documentation should include any required software versions, environment variables, database setup procedures, and steps for running tests locally.
The .env.example file serves as the foundation for environment consistency, providing clear documentation of all required configuration variables while keeping sensitive information out of version control. Team members should be able to copy this file to .env and modify only the values specific to their local environment.
7.1.4 Switching Between Projects
Since our agency works on multiple projects simultaneously, our development environment choices consider the efficiency of switching between different client sites and applications. Tools that support easy project switching, like Valet’s automatic domain resolution or Docker Compose’s project isolation, improve daily productivity and reduce context switching overhead.
Development environment documentation should include instructions for starting, stopping, and resetting the local environment, ensuring that developers can quickly move between projects without interference or complicated cleanup procedures.