To set up Yii2 with MAMP on macOS, install MAMP and Composer, create your Yii2 project inside the MAMP htdocs directory, and configure your database.
1. Start MAMP and Check PHP
- Open MAMP from your Applications folder and click Start Servers.
2. Install Composer (If Not Already Installed)
bash
curl -sS https://getcomposer.org | php
sudo mv composer.phar /usr/local/bin/composer
Use code with caution.
3. Create the Yii2 Project
- Navigate to your MAMP document root folder (
htdocs):bashcd /Applications/MAMP/htdocsUse code with caution. - Run the Composer command to create a basic Yii2 project template (replace
my-yii-appwith your project name):bashcomposer create-project --prefer-dist yiisoft/yii2-app-basic my-yii-appUse code with caution.
4. Configure the Database
- Open phpMyAdmin via your MAMP interface or by visiting
http://localhost:8888/phpMyAdmin/(or your configured port/host). [1] - Create a new blank database, for example:
yii2_db. - Open your project's database configuration file located at
my-yii-app/config/db.phpusing a text editor.
5. Run and Access Your Application
You can access your application in two ways:
If you'd like, let me know:
- Yii2 Basic or Advanced template?
- Virtual Host configuration for clean URLs?
I can provide the next steps.
0 Comments