Download the PHP package webxloo/yii2-advanced-template without Composer
On this page you can find all versions of the php package webxloo/yii2-advanced-template. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package yii2-advanced-template
yii2-advanced-template
This is improved template of nenad-zivkovic/yii2-advanced-template.
Additional features:
- API app - entry script for api side of application and
_protected/api
added. - Db logs view in backend.
- Logs archive.
- Docs generator.
- Test runner.
- Api doc runner (via admin panel, see
_protected/backend/config/main.php
sectioncomponents - urlManager - rules
documentation module example andcontrollerMap
).
You can see detailed info about theses new features below.
Yii2-advanced-template is based on yii2-app-advanced created by yii2 core developers. There are several upgrades made to this template.
- This template has additional features listed in the next section of this guide.
- Application structure has been changed to be 'shared hosting friendly'.
Features
- Signup with/without account activation
- You can chose whether or not new users need to activate their account using email account activation system before they can log in. (see: common/config/params.php).
- Login using email/password or username/password combo.
- You can chose how users will login into system. They can log in either by using their username|password combo or email|password. (see: common/config/params.php).
- Rbac tables are installed with other migrations when you run command.
- RbacController's init() action will insert 5 roles and 2 permissions in our rbac tables created by migration.
- Roles can be easily assigned to users by administrators of the site (see: backend/user).
- Nice example of how to use rbac in your code is given in this application. See: BackendController.
- Users with editor+ roles can create articles.
- Session data is stored in database out of box.
- System setting are stored in config/params.php file ( changes from v2 ).
- Theming is supported out of the box.
- Translation is supported out of the box.
- Administrators and The Creator can manage users ( changes from v2 ).
- Password strength validation and strength meter.
- All functionalities of default advanced template are included in this template.
- Code is heavily commented out.
Installation
I am assuming that you know how to: install and use Composer, and install additional packages/drivers that may be needed for you to run everything on your system. In case you are new to all of this, you can check my guides for installing default yii2 application templates, provided by yii2 developers, on Windows 8 and Ubuntu based Linux operating systems, posted on www.freetuts.org.
-
Create database that you are going to use for your application (you can use phpMyAdmin or any other tool you like).
-
Now open up your console and to your web root directory, for example:
-
Run the Composer command:
-
Once template is downloaded, you need to initialize it in one of two environments: development (dev) or production (prod). Change your working directory to
and execute command.Type 0 for development, execute coomant, type yes to confirm, and execute again.
-
Now you need to tell your application to use database that you have previously created. Open up main-local.php config file in
and adjust your connection credentials. -
Back to the console. It is time to run yii migrations that will create necessary tables in our database. While you are inside folder execute :
or if you are on Windows
-
Execute rbac controller init action that will populate our rbac tables with default roles and permissions:
or if you are on Windows
You are done, you can start your application in your browser.
*Tip: if your application name is, for example, advanced, to see the frontend side of it you just have to visit this url in local host: . To see backend side, this is enough: .
Note: First user that signs up will get 'The Creator' (super admin) role. This is supposed to be you. This role have all possible super powers :) . Every other user that signs up after the first one will get 'member' role. Member is just normal authenticated user.
Logs archive
To archive logs cd to _protected
and run
This command archives all logs (Log) older
than Yii::$app->params[ModelsToDeleteService::PREVENT_DELETING_LAST_DAYS]
value is in (_protected/common/config/params.php
).
You can add this command to your crontab, example of every day cron schedule expression:
To clear logs archive run:
Note: This command deletes all records in table
log_archive
.
Docs generating
To generate docs cd to _protected
directory
and run ./doc-generator.sh
.
Note:
.md
files of docs are located in_protected/guide
.
Testing
If you want to run tests you should create additional database that will be used to store your testing data. Usually testing database will have the same structure like the production one. I am assuming that you have Codeception installed globally, and that you know how to use it. Here is how you can set up everything easily:
-
Let's say that you have created database called . Go create the testing one called .
-
Inside your config file change database you are going to use to .
-
Open up your console and to the folder of your application.
-
Run the migrations again: or if you are on Windows
-
Run rbac/init again: or if you are on Windows
-
Run rbac/init again: or if you are on Windows
-
Now you can tell your application to use your database again instead of . Adjust your config file again.
-
Now you are ready to tell Codeception to use database.
Inside: file tell your to use database.
-
Start your php server inside the root of your application:
(if the name of your application is advanced, then root is folder) -
Create
_protected/tests/codeception/config/_params-local.php
copy content fromprotected/tests/codeception/config/_params-local.example.php
(content can be changed sometimes): -
To run tests written for frontend side of your application to , run and then run your tests.
-
Take similar steps like in previous step for common, console and api tests.
-
Running tests:
or
or
To run api
, console
, common
tests at once cd to _protected
and run ./test-runner.sh
.
Note: Please also reed
_protected/tests/README.md
.
Directory structure
Version 2.2.0 changes
1) Adds uploads
folder to the application root that can be shared by both frontend and backend applications.
2) @uploads
alias has been added, so you can use it in your code ( will target your_app_name/uploads folder )
3) Additional translations are included. Thanks to MeFuMo and hior
4) Alert widget call is added to backend main.php layout
5) Minor fixes
Version 2.1.0 changes
1) option to CRUD articles ( posts ) has been added
2) translation support has been included and Serbian translation has been added
3) themes has been improved
4) new roles, permissions and rules are added
5) other code refactoring has been done
Version 2.0 changes
1) settings are stored in config/params.php configuration file to reduce database load
2) account update is merged with user management and user management is more powerful now
3) User model has been separated on UserIdentity and User (for easier understanding and use)
4) 4 beautiful bootstrap responsive themes are included out of the box
5) comment style is changed according to yii2 official style
6) tests has been rewritten according to the changes that has been made
7) a lot of other polishing has been done
Password strength guide
Since 1.1.1 version has been released, password strength extension has been included as a core part of improved templates. Usage is very simple:
In our signup, user create/update and password reset forms password strength meter is always displayed when users are entering their password. This will give them visual representation of their password strength.
But this is not all. As The Creator you have option in your settings "Force Strong Password" that you can use. If you turn it on, users will be forced to use strong passwords according to preset you chose. For example if you use normal preset, users will be forced to use at least 8 characters long password, with at least one upper-case and one lower-case letter, plus at least one digit.
Since version 2 settings are stored in config/params.php file!
Choosing presets:
By default normal preset is used for signup and user create/update forms. For password reset we are using 'reset' preset if you want to customize which presets is used, see SignupForm model, User model and ResetPasswordForm model. You will see rules declared for using strong passwords. Presets are located in . You can chose some other preset declared in presets.php, or create new ones.
All versions of yii2-advanced-template with dependencies
yiisoft/yii2 Version *
yiisoft/yii2-bootstrap Version *
yiisoft/yii2-swiftmailer Version *
kartik-v/yii2-password Version @dev
dmstr/yii2-adminlte-asset Version ^2.1
himiklab/yii2-recaptcha-widget Version ^1.2
kartik-v/yii2-widget-select2 Version ^2.1
kartik-v/yii2-datecontrol Version ^1.9
kartik-v/yii2-widget-datetimepicker Version ^1.4
kartik-v/yii2-date-range Version ^1.6
kartik-v/yii2-widget-datepicker Version ^1.4
nterms/yii2-pagesize-widget Version ^2.0
yiisoft/yii2-apidoc Version ~2.1.0
autoxloo/rest-api-doc Version ^0.0.5