- This is from this YouTube video: https://youtu.be/whuIf33v2Ug
- I skip the necessary tools installation. It should be the usual: XAMPP and Composer.
- The instructor is following the installation guide of Yii2 App Advanced here: https://github.com/yiisoft/yii2-app-advanced/blob/master/docs/guide/start-installation.md
A. Project Setup
( Click the link to jump to section )
B. Create Database and Run Migration
( Click the link to jump to section )
A. PROJECT SETUP
1. Create new project
First of, let's start with creating the project with:
composer create-project --prefer-dist yiisoft/yii2-app-advanced
YouTubeCloneYii
You may change 'YouTubeCloneYii' to any name you desire. You
MUST create the project in
C:\xampp\htdocs\
. If not, you wil get an error like this: https://i.stack.imgur.com/nTxd6.png (image from
StackOverflow).
2. Set up virtual host
Make a copy of
httpd-vhosts.conf
located in
C:\xampp\apache\conf\extra
with any code editor. As for me, I
open it in VSCode. We are going to edit this file so it is better to create a backup. If you don't change the default setting after we have edited this file later, there will be a problem where you can't run any project you put in htdocs folder except this Yii project.Copy the code for Apache from the
installation guide at step 4 and paste it to the end of the file.
Change the document root and directory path to the location of
your project and server name to anything that you desire. For
example:
from
/path/to/yii-application/frontend/web/
to C:\xampp\htdocs\YouTubeCloneYii\frontend\web
from
/path/to/yii-application/backend/web/
to C:\xampp\htdocs\YouTubeCloneYii\backend\web
from
frontend.test to yutub.test
from
backend.test to studio.yutub.test
Next, open
hosts
located in C:\Windows\System32\drivers\etc
and add
127.0.0.1 yourservername.test 127.0.0.1 studio.yourservername.test
Change yourservername to the one you use
in
httpd-vhosts.conf
. As for me, it is
yutub.test
and studio.yutub.test
. It will ask you
for administrator's permission to save the file. If for some reason you
can't save the file directly, save the file in another location (in desktop
for example), copy it, and replace the file in System32 > drivers >
etc folder. Before putting the file in the folder, make sure the file
doesn't have any .txt extension.
It must not have any extension.
Restart Apache (close XAMPP or stop and start Apache in the XAMPP control
panel). You now should be able to open your Yii project with your server
name.
3. Set up environment
Go inside your project folder and run
php init
. Choose
development by typing 0
and confirm by typing yes
.
Now, when you open your app, it will look like this.
B. CREATE DATABASE AND RUN MIGRATION
1. Create database
Create a new MySQL database in phpMyAdmin. Use the
utf8mb4_unicode_ci
collation.
yii2advanced
to your database name. As for me, it is youtubecloneyii
.
No comments:
Post a Comment