Step 2 - Setting up Craft and Prototyping
MAMP Pro allows you to run a PHP/MySQL-based CMS from your local computer. Here’s how to set it up:
Install and Configure MAMP Pro the First Time
- Install MAMP Pro http://mamp.info
- Under ports - click the button to Set server ports to 80, 81, etc.
- Click the plus button underneath the box where “localhost” is listed
- Set up a new host directory (aka PROJECTNAME.web) and point to the “httpdocs” folder instead of the root
- Set up a local database as well using “PROJECTNAME_craft” as the database name.
- Set the default password for MySQL to “root”
- Start Servers by clicking the start button in the top Right of MAMP.
Note: MAMP Pro Must be running in order to access your site on your local computer.
Set up Craft CMS
- Duplicate the craft/config/db-default.php file and call it db.php. Edit it to include the LOCAL database name (assuming the password and user name are root).
- Important - change the public/htaccess file to be .htaccess.
- In craft/config/general.php - change the LOCAL url to your actual local URL. (in two places)
- Go to the local URL on your computer to install Craft (aka http://PROJECTNAME.web). Go through the installation process.
Editing Craft CMS Template Files
- Craft CMS template files are located in PROJECTNAME/craft/templates. You can organize these however you want, but the main template is layout.html.
- Pattern Lab and Craft CMS share the same assets, so they’ll automatically be in sync (yay).
For more information about how to build Craft templates and fields, see this article.
Adding Patterns for Prototyping
There is a subfolder in your httpdocs folder called “lab”. This is where you can place webpages and components before they’re ready for Craft CMS.
- Add a new pattern to the patterns folder by copying the “sample.php” file.
- Add the pattern to the collective pattern page by including the PHP file in lab/patterns/index.php.
- Add your patterns to the pages by copying the “copyme” folder. Include your patterns on “index.php” inside each of the folders.
- Finally, you can link to your pages in the lab/index.php file.