/yii2-basic-starter

Yii2 basic app starter template with tweaks

Primary LanguagePHPMIT LicenseMIT

Yii2 basic app starter template

WHAT'S SPECIAL

  • Boost composer-asset-plugin update speed, more detail here

  • Create and use environments, more detail here

  • Theming supports, guide here

  • Include required dependencies

    "yiisoft/yii2-imagine": "*",
    "dektrium/yii2-user": "0.9.*@dev",
    "dektrium/yii2-rbac": "1.0.0-alpha@dev",
    "froala/yii2-froala-editor": "*",
    "bower-asset/sweetalert": "*"
    

REQUIREMENTS

The minimum requirement by this project that your Web server supports PHP 5.4.0.

Be sure your web server satisfies the requirements by run command:

php requirements.php

INSTALLATION

Install Composer

curl -sS https://getcomposer.org/installer | php
mv composer.phar /usr/local/bin/composer

On Windows, you'll download and run Composer-Setup.exe.

Install Composer Asset Plugin

composer global require "fxp/composer-asset-plugin:^1.2.0"

Install dependencies

composer install

Create your environment configuration

php init

Can use the built-in PHP web server by running the following console command while in the project web directory:

php yii serve --port=8888

You can use your browser to access the installed Yii application with the following URL:

http://localhost:8888/

CONFIGURATION

Database

Edit the file config/web-local.php with real data, for example:

return [
    'class' => 'yii\db\Connection',
    'dsn' => 'mysql:host=localhost;dbname=yii2basic',
    'username' => 'root',
    'password' => '1234',
    'charset' => 'utf8',
];

NOTES:

  • Yii won't create the database for you, this has to be done manually before you can access it.

Running migrations

Run below command for creating database tables:

./yii migrate/up --migrationPath=@vendor/dektrium/yii2-user/migrations
./yii migrate

I18N

Adjust the parameters to fit your needs at messages/config.php. Pay special attention to:

  • languages: an array representing what languages your app should be translated to;
  • messagePath: path where to store message files, which should match the i18n's basePath parameter stated in config.

You may also use ./yii message/config command to dynamically generate configuration file with specified options via cli. For example, you can set languages and messagePath parameters like the following:

./yii message/config --languages=de,ja --messagePath=messages messages/config.php

Once you're done with the configuration file you can finally extract your messages with the command:

./yii message messages/config.php