---
# System prepended metadata

title: wp-sweetgreen

---

# wp-sweetgreen
Welcome to the sweetgreen Wordpress hosted site, home of sweetgreen.com.

## Getting Started

### Prerequisites
- [MAMP](https://www.mamp.info/en/): download latest version
- [Wordpress](https://wordpress.org/download/): fresh copy of Wordpress
- [SG Database](https://sweetgreen.atlassian.net/wiki/spaces/TEC/pages/381681665/SG.com+Setup+process): copy of Wordpress database (first link)
- [Sequel Pro](https://www.sequelpro.com/): optional, helpful for making DB changes


### Setup
1. Install MAMP and set up Wordpress locally. Follow [this guide](https://skillcrush.com/2015/04/14/install-wordpress-mac/) (suggestion: use ports 8888 for Apache, 8889 for MySQL).
2. After following the above guide, you should have a clean copy of Wordpress and MAMP running. Open up Sequel Pro to import the DB.  
    - To connect: host (localhost or 127.0.0.1), username / password (root), port (8889)
    - Select your newly created database as mentioned in above guide (should be empty). Go to `File > Import` and import the SG database (under "Prerequisites"). 
    - **Note**: If you don't use Sequel Pro you can upload and do all necessary actions via PHPMyAdmin (localhost:8888/phpMyAdmin).
4. In Sequel Pro, update the DB to point to your local development. In `wp_options` table, change `siteurl` and `home` to `http://localhost:8888/sweetgreen`. In `wb_users`, change `admin` password to an [MD5] hash.
5. Log in by navigating to `localhost:8888/wp-login.php`.  Username is`admin` and password is the string that was just hashed.
6.  After cloning this repo, copy the `sweetgreen-wp-theme` directory of this repo to `wp-content > themes` in your instance of Wordpress.
7. Change your version of PHP in MAMP to 7.1.30 by opening up `Preferences > PHP`.
8. Install various dependencies by navigating to the `sweetgreen-wp-theme` directory of your Wordpress instance and run the following in your terminal:
```
// Install Composer, a dependency manager for PHP
curl -sS https://getcomposer.org/installer | php (edited) 

// Install LaunchDarkly SDK
php composer.phar require launchdarkly/server-sdk:3.5.5

// Install Guzzle, a PHP HTTP client library
php composer.phar require guzzlehttp/guzzle
```
9. Navigate to `http://localhost:8888/sweetgreen` in your browser.

## Troubleshooting

### Debugging/Gotchasa
- Make sure you have an empty database, before setting up and installing Wordpress. Import the Sweetgreen DB after.
- Follow [this](https://stackoverflow.com/questions/16783558/how-can-i-add-additional-php-versions-to-mamp) to downgrade your PHP version.
- Download plugins [here](https://sweetgreen.atlassian.net/wiki/spaces/TEC/pages/381681665/SG.com+Setup+process) (second link).

### Feature Flagging with LaunchDarkly 
1. For local testing, create a local file called `local_flags.php` in `wp-content/themes/sweetgreen-wp-theme/inc`:

   ```php
 	<?php
      $localFeatureFlags = [
        "test-flag-name" => false,
  		"second-flag-name" => true
      ];
	?>
   ```
 2. If the local feature flag is not present, the default value will be returned (defined in `wp-content/themes/sweetgreen-wp-theme/inc/deafult_feature_flags.php`). 