Runbook for setting up a local dev environment for Frank's staging WordPress site using MAMP.
You need to have node, npm, and gulp installed globally before moving on.
- Install MAMP/MAMP PRO
- Create a directory where you'll store all of your projects. (ie.
localhost) - Inside of
localhost, create a new directory for your local instance of Frank's website (ie.frank-local)
cdinto your new directorycd ~/Desktop/localhost/frank-local- Clone the Github repo
- Now you should have the
frankproject directory with a path that looks likelocalhost/frank-local/frank cdintofrank/wp-content/themes/frank-collective- run
npm ci - run
gulp
- Download the latest version of WordPress
- Unzip it and move the folder into your
frankproject directory to replace the existing emptywordpressfolder
- Open MAMP and make sure the servers are on
- Create a new host by clicking the
+fromHostssettings - Enter the name of the directory where you created for Frank's local instance -
frank-local - Choose the document root (the Frank repo) by clicking the folder icon that is circled in red.
Desktop/localhost/frank-local/frank - Check the box to
Create a database - Enter the database name (if you want to clone staging then use
wp_fcollectivedev. If you want to clone production, then usewp_frankcollectiv) and hitCreate Host. - Navigate to the
Databasestab - You should see your newly created database checked
- Click the
phpMyAdminicon to open phpMyAdmin in your browser window - You'll see a list on the left of the page with your databases. You should see the database you just created. When you click the
+to expand, you'll notice a messageNo tables found in database.Don't worry, we'll add this next!
We first need to get the database from Frank's staging site in order to import it to our local database.
- Log in to WP Engine (get credentials from developer):
- Go to the
Stagingtab - Click the link to
phpMyAdmin - This should open phpMyAdmin in a new browser window
- Select the
wp_fcollectivedevdatabase from the left side - Click the
Exporttab - Use the
Quickexport method to download the sql file and hitGo
- Important: DO NOT TOUCH ANYTHING EXCEPT TO EXPORT THE DATABASE
- Close out of this window.
- Zip the file
- Go back to your local phpMyAdmin browser window
- If you closed out of it:
- Open MAMP application
- Select
frank-localhost - Click on
Databasestab - Make sure you see
wp_fcollectivedev(orwp_frankcollectiv) selected - Click the phpMyAdmin logo
- In phpMyAdmin, select your database from the left side
wp_fcollectivedev(orwp_frankcollectiv) - Click on the
Importtab.
- Make sure you are now in your local phpMyAdmin. Look in the URL to ensure you see
localhost/phpMyAdmin
Choose Fileto select the compressed sql file you just exported- Hit
Go - You should have a
successmessage!
- Open your wp-config.php file
- Make sure the database name matches your phpMyAdmin database
define( 'DB_NAME', 'wp_fcollectivedev' );
- Now go to the MAMP app
- In the
Generaltab, select your hostfrank-local - Hit
Saveto restart the servers - Click the arrow next to
Nameto open your site in a browser window. - You should now see your local instance of Frank's staging site in a browser window!
When you want to update your local database to match Frank's staging database, essentially you'll need to export the sql and import it locally. You should always make sure your local matches what is on the dev site. Keep in mind the database is just the content/data that is created in WordPress, this will not affect styles, layout, etc. Updating the database will just update the content.
Here are the steps:
- Go into Frank's staging site's phpMyAdmin (use credentials from above).
- Select the
wp_fcollectivedevdatabase from the left side - Click the
Exporttab - Select
Customexport method - Under
Tables, de-select allStructure. The reason for this is that you already have the database tables (structure) setup on your local and now you just want to replace the data itself. - Save & Close
- Go to
Data creation optionssection - Locate
Function to use when dumping data:and select from the drop-downREPLACE - Hit
Goto download the sql file
- Close Frank staging site's phpMyAdmin window to ensure you do not get it mixed up with your local!
- Zip the sql file
- In your local phpMyAdmin, select your database
frankdband go to theImporttab - Upload the zipped sql file that you just exported
- You should receive a
Successmessage - Go to your local browser and do a hard refresh to see the updated content
feature_feature-branch > develop > master
Always branch off of develop and never directly commit to master. After you are satisfied with your edits, create a pull request to have a peer review your code. Once it's accepted, merge your branch into develop. Next, you'll need to update the files via SFTP to be reflected on Frank's dev site. Afterwards, you can merge develop into master.
NOTE: Changes in the repo will not deploy the site. The site will get updated manually via SFTP.
- Develop has features approved to move to dev site but may have not yet been updated via SFTP
- Master should match the dev site
cdinto the directory where you have the Frank repocd ~/Desktop/localhost/frank-local/frankgit statusto make sure you are onmasterand the working tree is clean- Go to the develop branch
git checkout develop - Create a new branch
git checkout -b feature_your-feature - You'll edit CSS/JS from the
assets/sassorassets/jsdirectory - After you make any edits here, you'll need to compile these files:
cdinto the custom frank themecd ~/Desktop/localhost/frank-local/frank/wp-content/themes/frank-collective- run
gulp
- Do a hard refresh in your browser and confirm the changes are there
After everything looks good on your branch, it's been approved, and you've merged it into develop - now you need to update the staging site via SFTP
You only need to create your new user once. Afterwards, you can always use the same user to access the SFTP.
- Log in to WP Engine (get credentials from developer):
- Go to the
Stagingtab - Click
SFTP users - Create a new user
+ Add SFTP user - Username should use the convention
fcollectivedev-yourname - Create a password
Environmentshould beStaging
- Open the SFTP client of your choice (get credentials from developer):
- Navigate to the custom theme directory:
wp-content/themes/frank-collective. - Go to your finder window and drag the entire
assetsfolder into the custom theme so that it updates the existingassetsfolder with your edits.
- It's best to drag the entire
assetsfolder since it includes the compiled files. If you think it takes too long to update, feel free to navigate to the/assetsdirectory and manually drag both thecompiledandsass(orjs) folders instead of the entireassetsfolder.
- Now go to your browser, do a hard refresh and make sure the edits are now up on the dev site