nenad/yii2-basic-template
Composer 安装命令:
composer create-project nenad/yii2-basic-template
包简介
Improved Yii 2 Basic Application Template By Nenad Zivkovic
README 文档
README
Yii2-basic-template is based on yii2-app-basic created by yii2 core developers, but it also uses some of the features presented in their advanced template too. There are several upgrades made to this template.
- This template comes with almost all features that default yii2-app-advanced has.
- It 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.
- 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.
- Rbac tables are installed with other migrations when you run
yii migratecommand.- 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.
- Session data is stored in _protected/session folder.
- System setting are stored in config/params.php file.
- Theming is supported out of the box.
- Translation is supported out of the box.
- Administrator+ roles can manage users.
- Password strength validation and strength meter are included out of the box.
- Simple role management is included out of the box.
- 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 that you like).
-
Now open up your console and
cdto your web root directory, for example:cd /var/www/html/ -
Run the Composer
create-projectcommand:composer create-project nenad/yii2-basic-template basic -
Now you need to tell your application to use database that you have previously created. Open up db.php config file in
basic/_protected/config/db.phpand adjust your connection credentials. -
Back to the console. Inside your newly installed application,
cdto the_protectedfolder. -
Execute yii migration command that will install necessary database tables:
./yii migrateor if you are on Windowsyii migrate -
Execute rbac controller init action that will populate our rbac tables with default roles and permissions:
./yii rbac/initor if you are on Windowsyii rbac/init
You are done, you can start your application in your browser.
Note: First user that signs up will get 'theCreator' (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 NOT get any role by default. This is because authenticated user (@ by default) is same like our member role.
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
basic. Go create the testing one calledbasic_tests. -
Inside your
db.phpconfig file change database you are going to use tobasic_tests. -
Open up your console and
cdto the_protectedfolder of your application. -
Run the migrations again:
./yii migrateor if you are on Windowsyii migrate -
Run rbac/init again:
./yii rbac/initor if you are on Windowsyii rbac/init -
Now you can tell your application to use your
basicdatabase again instead ofbasic_tests. Adjust yourdb.phpconfig file again. -
Now you are ready to tell Codeception to use
basic_testsdatabase.Inside:
_protected/tests/codeception/config/config.phpfile tell yourdbto usebasic_testsdatabase. -
Start your php server inside the root of your application:
php -S localhost:8080(if the name of your application is basic, then root isbasicfolder) -
Move to
_protected/tests, runcodecept buildand then run your tests.
Directory structure
_protected
assets/ contains assets definition
components/ contains custom made application components
config/ contains application configurations
console contains console commands (controllers and migrations)
controllers/ contains Web controller classes
helpers/ contains helper classes
mail/ contains view files for e-mails
models/ contains model classes
rbac/ contains role based access control classes
runtime/ contains files generated during runtime
tests/ contains various tests for the basic application
translations/ contains application translations
views/ contains view files for the Web application
widgets/ contains widgets
assets contains application assets generated during runtime
themes contains your themes
uploads contains various files that can be uploaded by application users
Version 2.3.0 changes
- Adds
componentsfolder to the _protected folder, andAliasesclass in it. - Articles have been removed from the template.
- Themes have been changed.
- A lot of code improvements have been done.
- More translation messages have been added.
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.
Choosing presets:
By default normal preset is used for signup and user create/update forms. For password reset we are using 'simple' 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 vendor/kartik-v/yii2-password/presets.php. You can chose some other preset declared in presets.php, or create new ones.
nenad/yii2-basic-template 适用场景与选型建议
nenad/yii2-basic-template 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 6.51k 次下载、GitHub Stars 达 46, 最近一次更新时间为 2014 年 10 月 29 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「framework」 「basic」 「application template」 「yii2」 「nenad」 「improved」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 nenad/yii2-basic-template 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 nenad/yii2-basic-template 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 nenad/yii2-basic-template 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
PHP Framework HLEB2 is the foundation of the web application. Provides ease of development and application performance.
Kinikit - PHP Application development framework MVC component
Laravel middleware to restrict a site or specific routes using HTTP basic authentication
A Laravel queue connector to process jobs at the end of the application
redis log extension of yii2
C3JS By phpanonymous (Mahmoud Ibrahim)
统计信息
- 总下载量: 6.51k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 49
- 点击次数: 13
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: BSD-3-Clause
- 更新时间: 2014-10-29