/yii2-youtubeClone

Youtube Clone with Yii2 PHP Framework

Primary LanguagePHPBSD 3-Clause "New" or "Revised" LicenseBSD-3-Clause

Yii 2 Advanced Project Template


Yii 2 Advanced Project Template is a skeleton Yii 2 application best for developing complex Web applications with multiple tiers.

The template includes three tiers: front end, back end, and console, each of which is a separate Yii application.

The template is designed to work in a team development environment. It supports deploying the application in different environments.

Documentation is at docs/guide/README.md.

Latest Stable Version Total Downloads build

DIRECTORY STRUCTURE

common
    config/              contains shared configurations
    mail/                contains view files for e-mails
    models/              contains model classes used in both backend and frontend
    tests/               contains tests for common classes    
console
    config/              contains console configurations
    controllers/         contains console controllers (commands)
    migrations/          contains database migrations
    models/              contains console-specific model classes
    runtime/             contains files generated during runtime
backend
    assets/              contains application assets such as JavaScript and CSS
    config/              contains backend configurations
    controllers/         contains Web controller classes
    models/              contains backend-specific model classes
    runtime/             contains files generated during runtime
    tests/               contains tests for backend application    
    views/               contains view files for the Web application
    web/                 contains the entry script and Web resources
frontend
    assets/              contains application assets such as JavaScript and CSS
    config/              contains frontend configurations
    controllers/         contains Web controller classes
    models/              contains frontend-specific model classes
    runtime/             contains files generated during runtime
    tests/               contains tests for frontend application
    views/               contains view files for the Web application
    web/                 contains the entry script and Web resources
    widgets/             contains frontend widgets
vendor/                  contains dependent 3rd-party packages
environments/            contains environment-based overrides

Installation

Configure apache on xampp

Open xampp\apache\conf\extra and add the following code
` <VirtualHost *:80> ServerName frontend.test DocumentRoot "C:\xampp\htdocs\youtubeCloneYii\frontend\web"

    <Directory "C:\xampp\htdocs\youtubeCloneYii\frontend\web">
        # use mod_rewrite for pretty URL support
        RewriteEngine on
        # If a directory or a file exists, use the request directly
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
        # Otherwise forward the request to index.php
        RewriteRule . index.php

        # use index.php as index file
        DirectoryIndex index.php

        # ...other settings...
        # Apache 2.4
        Require all granted
        
        ## Apache 2.2
        # Order allow,deny
        # Allow from all
    </Directory>
</VirtualHost>

<VirtualHost *:80>
    ServerName backend.test
    DocumentRoot "C:\xampp\htdocs\youtubeCloneYii\backend\web"
    
    <Directory "C:\xampp\htdocs\youtubeCloneYii\backend\web">
        # use mod_rewrite for pretty URL support
        RewriteEngine on
        # If a directory or a file exists, use the request directly
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
        # Otherwise forward the request to index.php
        RewriteRule . index.php

        # use index.php as index file
        DirectoryIndex index.php

        # ...other settings...
        # Apache 2.4
        Require all granted
        
        ## Apache 2.2
        # Order allow,deny
        # Allow from all
    </Directory>
</VirtualHost>

`

Migrations

Run

php yii migrate/create create_videos_table --fields="video_id:string(16):notNull,title:string(512):notNull,description:text,created_by:integer(11):foreignKey(user)" 

to generate a new migration for table video

Models

Navigate to http://backend.test/gii to generate a video model class