-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.envrc.example
More file actions
176 lines (160 loc) · 5.83 KB
/
Copy path.envrc.example
File metadata and controls
176 lines (160 loc) · 5.83 KB
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
# =============================================================
# WordPress Plugin Development Environment Template
# =============================================================
#
# This is a template file for direnv configuration optimized for
# WordPress plugin development with Local by Flywheel.
#
# Usage:
# cp .envrc.example .envrc
# direnv allow
#
# Requirements:
# - direnv: https://direnv.net/
# - mysql-client: brew install mysql-client
# - WP-CLI: brew install wp-cli
# - Composer: https://getcomposer.org/
# =============================================================
# =============================================================
# Project Configuration
# =============================================================
export PROJECT_ROOT="$PWD"
export PROJECT_NAME="$(basename "$PWD")"
# =============================================================
# Development Tools PATH
# =============================================================
# Add mysql-client to PATH (required for Local by Flywheel)
export PATH="/opt/homebrew/opt/mysql-client/bin:$PATH"
# Add project vendor binaries to PATH
export PATH="$PROJECT_ROOT/vendor/bin:$PATH"
# =============================================================
# WordPress Configuration
# =============================================================
# Enable WordPress debug mode
export WP_DEBUG=true
# =============================================================
# Database Configuration (Local by Flywheel)
# =============================================================
# Get these values from Local by Flywheel > Site > Database
#
# To find MySQL socket path:
# 1. Open Local by Flywheel
# 2. Go to your site
# 3. Click "Database" tab
# 4. Look for "Socket" value
#
# Example values:
# export DB_HOST="localhost"
# export DB_NAME="local"
# export DB_USER="root"
# export DB_PASSWORD="root"
# export MYSQL_UNIX_PORT="/Users/username/Library/Application Support/Local/run/xxxxxxxx/mysql/mysqld.sock"
# Database settings (customize for your environment)
export DB_HOST=localhost
export DB_NAME=local
export DB_USER=root
export DB_PASSWORD=root
# WordPress path for WP-CLI (avoid spaces in path)
export WP_PATH="/path/to/your/wordpress/public"
# IMPORTANT NOTES:
# 1. Use unquoted values for database variables: export DB_HOST=localhost (not "localhost")
# 2. Use quoted values for paths with spaces: export WP_PATH="/path with spaces/wordpress"
# 3. Test WP-CLI connection: wp db query "SELECT 1;" --path="$WP_PATH"
# MySQL socket path for Local by Flywheel
# IMPORTANT: Update this path for your Local installation
export MYSQL_UNIX_PORT="/Users/YOUR_USERNAME/Library/Application Support/Local/run/SITE_ID/mysql/mysqld.sock"
# =============================================================
# Development Tools Configuration
# =============================================================
# Composer scripts are used instead of direnv functions
# See composer.json > scripts section
#
# Usage:
# composer phpcs -- file.php
# composer phpcbf -- file.php
# composer install
# composer update
# =============================================================
# Optional: Custom Aliases (uncomment if needed)
# =============================================================
# These may not work reliably with direnv, but you can try:
#
# Directory navigation aliases
# cdadmin() { cd "$PROJECT_ROOT/includes/admin"; }
# cdassets() { cd "$PROJECT_ROOT/assets"; }
# cdinc() { cd "$PROJECT_ROOT/includes"; }
#
# Development aliases
# test() { echo "Testing $PROJECT_NAME..."; }
#
# For reliable aliases, add them to ~/.zshrc instead:
# alias cdadmin='cd ./includes/admin'
# alias cdassets='cd ./assets'
# =============================================================
# Shell Configuration
# =============================================================
# Custom prompt to show current project
export PS1="($PROJECT_NAME) $PS1"
# =============================================================
# Additional Environment Variables (Optional)
# =============================================================
# Add any project-specific environment variables here
#
# Examples:
# export API_KEY="your-api-key-here"
# export NODE_ENV="development"
# export LOG_LEVEL="debug"
# =============================================================
# Verification Commands
# =============================================================
# After setting up .envrc, verify your environment:
#
# # Check if direnv is working
# echo $PROJECT_ROOT
#
# # Check if mysql-client is available
# which mysql
# mysql --version
#
# # Check if WP-CLI can connect to database
# wp db query "SELECT 1;" --path=/path/to/wordpress
#
# # Check if Composer scripts work
# composer phpcs -- --version
#
# # Check if vendor binaries are in PATH
# which phpcs
# which phpcbf
# =============================================================
# Troubleshooting
# =============================================================
#
# If commands are not found:
# 1. Run: direnv allow
# 2. Run: direnv reload
# 3. Check: which mysql
# 4. Install: brew install mysql-client
#
# If WP-CLI cannot connect to database:
# 1. Verify DB_HOST, DB_NAME, DB_USER, DB_PASSWORD
# 2. Verify MYSQL_UNIX_PORT path exists
# 3. Run: wp cli cache clear
#
# If Composer scripts don't work:
# 1. Run: composer install
# 2. Check: composer.json scripts section
# 3. Run: composer install --no-dev
# =============================================================
# Team Collaboration
# =============================================================
#
# 1. Add .envrc.example to git repository
# 2. Add .envrc to .gitignore
# 3. Team members copy .envrc.example to .envrc
# 4. Each team member customizes their .envrc
# 5. Never commit .envrc to version control
#
# This ensures:
# - Consistent development environment
# - No sensitive data in repository
# - Easy onboarding for new team members