sinret / yii2-basic-easy

Yii 2 基础项目模板,支持自定义

安装: 24

依赖项: 0

建议者: 0

安全: 0

星星: 1

关注者: 2

分支: 1

开放问题: 0

语言:JavaScript

类型:项目

v1.3 2017-10-25 08:58 UTC

This package is not auto-updated.

Last update: 2024-09-14 19:20:16 UTC


README

Yii 2 基础项目模板是一个骨架 Yii 2 应用,非常适合快速创建小型项目。

模板包含基本功能,包括用户登录/注销、电子邮件系统、RBAC、解析和下载 Excel 文件以及一个联系页面。它包含所有常用配置,使您能够专注于添加新功能到您的应用程序中。

目录结构

  assets/             contains assets definition
  commands/           contains console commands (controllers)
  config/             contains application configurations
  controllers/        contains Web controller classes
  mail/               contains view files for e-mails
  models/             contains model classes
  runtime/            contains files generated during runtime
  tests/              contains various tests for the basic application
  vendor/             contains dependent 3rd-party packages
  views/              contains view files for the Web application
  web/uploads         contains excel file using parsing
  web/images/avatar   contains avatar users
  web/xls_parsing     contains the entry script and Web resources
  web/xls_sample      contains the entry script and Web resources

要求

此项目模板的最低要求是您的 Web 服务器支持 PHP 5.4.0。

安装

从存档文件安装

composer require sintret/yii2-basic-easy

config/web.php 文件中将 cookie 验证密钥设置为某个随机密钥字符串

'request' => [
    // !!! insert a secret key in the following (if it is empty) - this is required by cookie validation
    'cookieValidationKey' => '<secret random string goes here>',
],

然后您可以通过以下 URL 访问应用程序

http://localhost/basic/web/

通过 Composer 安装

如果您没有 Composer,您可以按照 getcomposer.org 上的说明进行安装。

然后可以使用以下命令安装此项目模板

composer global require "fxp/composer-asset-plugin:^1.2.0"
composer create-project --prefer-dist sintret/yii2-basic-easy basic

现在您应该可以通过以下 URL 访问应用程序,假设 basic 是 Web 根目录下的直接目录。

http://localhost/basic/web/

配置

数据库

使用真实数据编辑 config/db.php 文件,例如

return [
    'class' => 'yii\db\Connection',
    'dsn' => 'mysql:host=localhost;dbname=yii2basic',
    'username' => 'root',
    'password' => '1234',
    'charset' => 'utf8',
];

迁移

迁移很简单,通过默认数据包括网格注入您的数据库。您需要打开控制台,然后请按照以下代码进行操作

yii migrate

转到您的浏览器

打开浏览器并转到您的 URL,例如 "http://localhost/basic/web/"。默认用户名是 "admin",密码是 "123456"。

RBAC

如果您已使用此生成器 "DIESEL CRUD Generator" 生成表,则需要检查您定义的每个 "ROLE"。在 "role" 表中的默认角色是 "Admin",然后根据需要向 mysql 表 "role" 中添加更多角色。您可以在 "设置 - 访问角色" 菜单或 "http://localhost/basic/web/role" 中检查/取消勾选角色

审计跟踪

当您在 mysql 表中定义了如 "userCreate, userUpdate, createDate, updateDate" 字段时,mysql 表的审计跟踪。

图像处理

默认图像处理使用 GD 库,但您可以通过在 components SintretImagine 类的文件夹中可选 gmacick 或 imagick 来更改优先级。对于 mysql 字段名称的默认值为 "image"。

备注

  • Yii 不会为您创建数据库,您必须在访问它之前手动完成此操作。
  • 检查并编辑 config/ 目录中的其他文件,以根据需要自定义您的应用程序。
  • 有关基本应用程序测试的特定信息,请参阅 tests 目录中的 README。
  • 编码愉快