project yii2-boilerplate
An Yii2-based boilerplate
muvo/yii2-boilerplate
An Yii2-based boilerplate
- Sunday, April 15, 2018
- by muvo
- Repository
- 1 Watchers
- 0 Stars
- 8 Installations
- PHP
- 0 Dependents
- 0 Suggesters
- 0 Forks
- 0 Open issues
- 4 Versions
- 33 % Grown
Yii2 boilerplate
Prerequisites
- PHP >=7
-
composer installed
Installation
- Install globally
composer-asset-plugin
:
bash
$ composer global require "fxp/composer-asset-plugin"
- Then run:
bash
$ composer create-project muvo/yii2-boilerplate
PROFIT!
You can continue to make your best Yii2-application! :), (*1)
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:, (*2)
-
app/themes/admin/assets
: put in this direcory all required assets for your application, like js, css, etc…
-
Add your own asset-bundle:, (*3)
- Create file
app/themes/admin/AssetBundle.php
. That class-file extends a yii\web\AssetBundle
- In this class you should define a
$sourcePath = '@app/themes/admin/assets'
- Define a your theme-specific
$js
and $css
properties
- 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:
- Create file
lib/SomeComponent/Connector.php
with following content:
<?php namespace MuVO\Yii2\SomeComponent;
class Connector
{
// some code here
}
- 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, (*4)
dev-develop
dev-develop
An Yii2-based boilerplate
Sources
Download
The Requires
dev-MuVO-patch-1
dev-MuVO-patch-1
An Yii2-based boilerplate
Sources
Download
The Requires
dev-master
9999999-dev
An Yii2-based boilerplate
Sources
Download
The Requires