muvo / yii2-boilerplate
An Yii2-based boilerplate
Installs: 27
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
Type:project
Requires
- php: >=7.0
- guzzlehttp/guzzle: ~6.0
- ramsey/uuid: *
- vlucas/phpdotenv: *
- yiisoft/yii2: ~2.0.13
- yiisoft/yii2-bootstrap: *
- yiisoft/yii2-swiftmailer: *
This package is not auto-updated.
Last update: 2025-01-27 09:38:22 UTC
README
Prerequisites
- PHP >=7
- composer installed
Installation
- 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 formatKEY="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:
- Create file
app/themes/admin/AssetBundle.php
. That class-file extends ayii\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 ofapp/themes/admin/assets
-directory in public@webroot
and injects JS and CSS scripts in your view(layout)
- Create file
- 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 databaseapp\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 namespaceMuVO\Yii2
. For example, if I want to createConnector
forSomeComponent
, 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();
- Create file
Credits
If you have a questions or need an advice, you always can contact me. For example, via Telegram