Before diving into the practical exercises ahead, you'll need to complete this essential setup process to ensure your development environment runs smoothly.
Topics Covered in This PHP & MySQL Tutorial:
Setting up Your Class Files, Configuring MAMP PRO to Display Errors for Effective Debugging
Setup Components
Class Files Organization
Learn how to properly structure and place your PHP files in the web server directory for optimal development workflow.
Error Display Configuration
Configure MAMP PRO to show PHP errors during development, making debugging and troubleshooting much easier.
Development Server Options
| Feature | MAMP PRO (Mac) | XAMPP (Windows) |
|---|---|---|
| Installation Path | Applications/MAMP | C:/xampp |
| Web Root Directory | htdocs | htdocs |
| Error Display Default | Hidden | Hidden |
Copying the Class Files into the Web Server Folder
Throughout this comprehensive workbook, you'll be working with carefully crafted class files that demonstrate real-world PHP development patterns. These files must reside within your local web server's document root to execute properly—a fundamental requirement that ensures your PHP interpreter can access and process the code.
- If you haven't already downloaded the class files for this book, navigate to the Downloading the Class Files chapter for detailed instructions. These files contain production-ready examples you'll modify and extend throughout your learning journey.
- Navigate to Desktop > Class Files on your system.
- Click once on the phpclass folder to select it—this directory contains all the organized project files and dependencies you'll need.
- Press Cmd–C (Mac) or CTRL–C (Windows) to copy the entire folder structure.
Follow the appropriate instructions for your operating system below:
- Mac users: Navigate to Hard Drive > Applications > MAMP > htdocs
- Windows users: Navigate to My Computer > C: > xampp > htdocs
Press Cmd–V (Mac) or CTRL–V (Windows) to paste the class files into your web server's document root.
Your class files are now properly positioned in the root directory of your active web server, making them accessible via your browser at http://localhost/phpclass.
With your files in place, the next crucial step involves configuring your development environment to provide meaningful feedback when issues arise.
File Setup Process
Locate Class Files
Navigate to Desktop > Class Files and select the phpclass folder containing all tutorial materials
Copy Files
Use Cmd-C (Mac) or Ctrl-C (Windows) to copy the selected phpclass folder to your clipboard
Navigate to Web Root
Go to your web server's htdocs directory - either Applications/MAMP/htdocs or C:/xampp/htdocs
Paste and Verify
Paste files with Cmd-V (Mac) or Ctrl-V (Windows) into the htdocs directory to make them accessible via web server
Files must be placed in the web server's root directory (htdocs) to function properly. PHP files outside this directory cannot be executed by the web server.
File Setup Verification
Ensures you have all necessary tutorial materials
Makes files accessible to the web server
Confirms your development environment is active
MAMP PRO: Displaying Errors
By default, MAMP PRO follows production server conventions by suppressing PHP error output—displaying only blank pages when errors occur. While this approach protects production applications from exposing sensitive debugging information, it creates unnecessary obstacles during local development. For efficient coding and debugging, you need immediate, detailed error feedback.
Launch MAMP PRO from your Applications folder.
Click the PHP tab in the main interface to access PHP-specific configuration options.
Locate the Log errors setting at the bottom of the panel, then check the to screen option. This modification enables real-time error display directly in your browser.
Click Save to apply your configuration changes.
When prompted to restart the server, click Yes—this restart ensures your new error handling settings take effect immediately.
Error Display Configuration
Launch MAMP PRO
Open the MAMP PRO application to access server configuration settings
Access PHP Settings
Click the PHP tab to view and modify PHP-specific configuration options
Enable Error Display
Locate 'Log errors' section and check 'to screen' option to display errors in browser
Save and Restart
Click Save and restart the server when prompted to apply the new error display settings
Error display is disabled by default for security reasons in production environments. Always enable it for local development to facilitate debugging and learning.
Error Display Configuration