MAMP
MAMP is software that allows us to run a server on our own computer with minimal configuration. This works similar to VS Code's Live Server plugin, except it provides support for technologies:
- Apache server
- MySQL/Maria DB databsae
- PHP programming language
For this class, we will use MAMP to leverage PHP File Includes.
Setup
- Download MAMP (free version, not MAMP Pro).
- Click "Preferences". Under the "Server" tab, choose your Document root. This is the folder on your computer's hard drive that you want to behave like the server "root", or top-level folder. (NOTE: On Windows, folders synced with One Drive seem to have a conflict, so you may want to keep the default MAMP/htdocs folder).
- Hit "OK"
- Click the "Start" button in the top right corner
- You should now see the MAMP homepage when visiting http://localhost:8888/MAMP/?language=English. (or possibly just http://localhost/MAMP/?language=English. on Windows)
- If you change the URL to: http://localhost:8888/ you should see the contents of the document root you defined in step 2.
- Try testing PHP by creating the following file as page.php and then navigating to http://localhost:8888/page.php.
<?php
$title = 'Hello There.';
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<h1><?php echo $title; ?></h1>
</body>
</html>
To stop the server, click "Stop" in the MAMP window or quit MAMP.
From here, try incorporating PHP File Includes.