muvo/yii2-boilerplate

There is no license information available for the latest version (1.0.1) of this package.

An Yii2-based boilerplate

1.0.1 2018-01-07 10:17 UTC

This package is not auto-updated.

Last update: 2024-04-22 05:49:08 UTC


README

Prerequisites

  1. PHP >=7
  2. composer installed

Installation

  1. Run:
    $ composer create-project muvo/yii2-boilerplate

PROFIT!

You can continue to make your best Yii2-application! :)

Some additional notices about files and directories

  • .env: In this file you can predefine environment variables for application in format KEY="SOME VALUE" (per one key-value pair in string)
  • app/themes: In this directory you can place your application's themes (assets, views, layouts, …) For example, I recommend following structure:
    • app/themes/admin/assets: put in this direcory all required assets for your application, like js, css, etc…
    • Add your own asset-bundle:
      1. Create file app/themes/admin/AssetBundle.php. That class-file extends a yii\web\AssetBundle
      2. In this class you should define a $sourcePath = '@app/themes/admin/assets'
      3. Define a your theme-specific $js and $css properties
      4. Then you can register your asset-bundle in view/layout, like <?php \app\themes\admin\AssetBundle::register($this) ?>. When your asset-bundle registers in a view, application will automatically publish contents of app/themes/admin/assets-directory in public @webroot and injects JS and CSS scripts in your view(layout)
    • Create directory for layouts and views: app/themes/admin/views/layouts
    • Look more information about Yii theming
  • app\models: Put there your data-models, for example ActiveRecord models for interact with database
  • app\modules: There you can place your separate Yii-modules, like user's panel, admin's panel, etc…
  • lib: This is arbitrary directory for development separate custom components. Classes to be placed there must be in namespace MuVO\Yii2. For example, if I want to create Connector for SomeComponent, I should:
    1. Create file lib/SomeComponent/Connector.php with following content:
      <?php namespace MuVO\Yii2\SomeComponent;
      
      class Connector
      {
      // some code here
      }
    2. Now you can call this Connector in your project like this:
      $connector = new \MuVO\Yii2\SomeComponent\Connector();

Credits

If you have a questions or need an advice, you always can contact me. For example, via Telegram