Home | About | View All Posts

6 Jul 2016

YII2 installation using composer method

How to install YII2 advanced application using composer at local server wamp or xampp window environment. YII2 installation are easy but problematic also. Solution of the problem has been written below.

Following are steps for YII2 advanced installation -
  1. Installing composer
  2. Getting yii2 app files from yii git repository
  3. Running and verifying the yii2 installation

  1. Install composer software. You can download it at https://getcomposer.org/
  2. Navigate and go at the place, where you want to install yii application.

    You need to run the 'create-project' command for installing yii applicaiton.

    Standard Syntax for 'create-project' command with command options -
    create-project [-s|--stability STABILITY] [--prefer-source] [--prefer-dist] [--repository REPOSITORY] [--repository-url REPOSITORY-URL] [--dev] [--no-dev] [--no-custom-installers] [--no-scripts] [--no-progress] [--no-secure-http] [--keep-vcs] [--remove-vcs] [--no-install] [--ignore-platform-reqs] [--] [] [] []

    Finally run the below command for installing latest stable version yii application.

    For Basic application(without backend and frontend folder structure) -
    H:\yii2cms>composer create-project --prefer-dist yiisoft/yii2-app-basic yii2cms

    For Advanced application(with backend and frontend folder structure) -
    H:\>composer create-project --prefer-dist yiisoft/yii2-app-advanced yii2cms

    Here,
    Command option : --prefer-dist
    Package : yiisoft/yii2-app-basic
    Directory : yii2cms

    Generally package url relates with github which is - https://github.com/yiisoft/yii2-app-basic. Directory will be automatically created that you have provided as name at above command line eg. 'yii2cms'. Please note - application will be installed in an auto created folder "yii2-app-basic or yii2-app-advanced", if you donot provide folder name.

    You can use --dev or --no dev command option if you want to install production or developement application.

    Finally all dependent module or packages like - bower-asset/bootstrap, yiisoft/yii2-swiftmailer, yiisoft/yii2-gii, symfony/yaml etc will be installed. Following is the screenshot for installation process.


  3. Now run the “init” file at command window for running the yii application initialization tool -
    G:/wamp/www/yii2cms/init
    The yii “init” file creates necessary files at appropriate directory for YII application environment initialization. It can be viewed at screenshot below -


  4. Now open the configuration file that have created by “init” and change or place you database name as screenshot below -

    In my case configuration file path was -
    G:/wamp/www/yii2cms/common/config/ main-local.php


  5. Finally go and browse the url below to check the installation success - /advanced/backend/web/ or /advanced/frontend/web/

    In my case it was -
    http://localhost/yii2cms/backend/web/
    http://localhost/yii2cms/frontend/web/

    The login form would visible after successful installation.



    You can signup via frontend module of YII2, which has inbuilt functionality for login and signup. Go for sign up at - /frontend/web/index.php?r=site/signup

    In my case it was -
    http://localhost/yii2cms/frontend/web/index.php?r=site%2Fsignup

  6. For invoking sign up functionality we need to run the migrate command at command window. This migration command primarily sets up the table for user management.

    Go at command prompt and run -
    >yii migrate

    It will run as below -
    Yii Migration Tool (based on Yii v2.0.6)
    
    Creating migration history table "migration"...Done.
    Total 1 new migration to be applied:
        m130524_201442_init
    
    Apply the above migration? (yes|no) [no]:yes
    *** applying m130524_201442_init
        > create table {{%user}} ... done (time: 0.007s)
    *** applied m130524_201442_init (time: 0.022s)
    
    
    Migrated up successfully.
    

    Finally go at sign up form and do sign up using mail and password then try to login into your YII2 project.

    In my case sign up url was -
    http://localhost/yii2cms/frontend/web/index.php?r=site%2Fsignup

    In my case login up url was -
    http://localhost/yii2cms/frontend/web/index.php?r=site%2Fsignup




Tags :

0 comments:

Post a Comment