vova07 / yii2-start
Yii2-Start 是一个用于快速启动项目的小型 Yii 2 应用程序模板。
0.4.5
2015-03-30 11:35 UTC
Requires
- php: >=5.4.0
- vova07/yii2-start-admin-module: *
- vova07/yii2-start-base: *
- vova07/yii2-start-blogs-module: *
- vova07/yii2-start-comments-module: *
- vova07/yii2-start-rbac-module: *
- vova07/yii2-start-site-module: *
- vova07/yii2-start-themes: *
- vova07/yii2-start-users-module: *
- yiisoft/yii2: *
- yiisoft/yii2-bootstrap: *
Requires (Dev)
README
DEMO
前端: http://yii2-start.find-freelancer.pro
后端: http://yii2-start.find-freelancer.pro/backend/
身份验证
登录: admin
密码: admin12345
安装和入门
如果您没有 Composer,您可以按照 getcomposer.org 上的说明进行安装。
如果您尚未安装 Composer-Asset-Plugin,可以通过运行以下命令进行安装: php composer.phar global require "fxp/composer-asset-plugin:1.0.0"
- 运行以下命令安装 Yii2-Start:
php composer.phar create-project --prefer-dist --stability=dev vova07/yii2-start yii2-start
在安装过程中可能需要从您的 Github 账户获取password
和/或username
。这是因为您向 Github 服务发送了过多的请求。只需记住这一点即可。 - 运行命令:
cd /my/path/to/yii2-start/
并进入主应用程序目录。 - 运行命令:
php requirements.php
并检查要求。 - 运行命令:
php init
以使用特定环境初始化应用程序。 - 创建新的数据库,并在
common/config/db.php
中相应地调整其配置。 - 使用控制台命令应用迁移
php yii migrate --migrationPath=@vova07/users/migrations
php yii migrate --migrationPath=@vova07/blogs/migrations
php yii migrate --migrationPath=@vova07/comments/migrations
- 这将创建应用程序运行所需的所有表。
- 您还可以使用
db.sql
数据库备份,位于my/path/to/yii2-start/common/data
中,但我建议使用迁移。
- 运行模块 RBAC 命令
php yii rbac/rbac/init
php yii users/rbac/add
php yii blogs/rbac/add
php yii comments/rbac/add
- 设置 Web 服务器的文档根目录
对于 Apache
<VirtualHost *:80>
ServerName www.yii2-start.domain # You need to change it to your own domain
ServerAlias yii2-start.domain # You need to change it to your own domain
DocumentRoot /my/path/to/yii2-start # You need to change it to your own path
<Directory /my/path/to/yii2-start> # You need to change it to your own path
AllowOverride All
</Directory>
</VirtualHost>
- 使用 URL
http://yii2-start.domain
访问应用程序前端。 - 使用 URL
http://yii2-start.domain/backend/
访问应用程序后端。
对于 Nginx
___Frontend___
```
server {
charset utf-8;
client_max_body_size 128M;
listen 80; ## listen for ipv4
# listen [::]:80 ipv6only=on; ## listen for ipv6
set $yii2StartRoot '/my/path/to/yii2-start'; ## You need to change it to your own path
server_name yii2-start.domain; ## You need to change it to your own domain
root $yii2StartRoot/frontend/web;
index index.php;
#access_log $yii2StartRoot/log/frontend/access.log;
#error_log $yii2StartRoot/log/frontend/error.log;
location / {
# Redirect everything that isn't a real file to index.php
try_files $uri $uri/ /index.php?$args;
}
location /statics {
alias $yii2StartRoot/statics/web/;
}
# uncomment to avoid processing of calls to non-existing static files by Yii
#location ~ \.(js|css|png|jpg|gif|swf|ico|pdf|mov|fla|zip|rar)$ {
# try_files $uri =404;
#}
#error_page 404 /404.html;
location ~ \.php$ {
#include fastcgi_params;
include fastcgi.conf;
fastcgi_pass 127.0.0.1:9000;
#fastcgi_pass unix:/var/run/php5-fpm.sock;
try_files $uri =404;
}
location ~ /\.(ht|svn|git) {
deny all;
}
}
```
__Backend__
```
server {
charset utf-8;
client_max_body_size 128M;
listen 80; ## listen for ipv4
# listen [::]:80 ipv6only=on; ## listen for ipv6
set $yii2StartRoot '/my/path/to/yii2-start'; ## You need to change it to your own path
server_name backend.yii2-start.domain; ## You need to change it to your own domain
root $yii2StartRoot/backend/web;
index index.php;
#access_log $yii2StartRoot/log/backend/access.log;
#error_log $yii2StartRoot/log/backend/error.log;
location / {
# Redirect everything that isn't a real file to index.php
try_files $uri $uri/ /index.php?$args;
}
location /statics {
alias $yii2StartRoot/statics/web/;
}
# uncomment to avoid processing of calls to non-existing static files by Yii
#location ~ \.(js|css|png|jpg|gif|swf|ico|pdf|mov|fla|zip|rar)$ {
# try_files $uri =404;
#}
#error_page 404 /404.html;
location ~ \.php$ {
#include fastcgi_params;
include fastcgi.conf;
fastcgi_pass 127.0.0.1:9000;
#fastcgi_pass unix:/var/run/php5-fpm.sock;
try_files $uri =404;
}
location ~ /\.(ht|svn|git) {
deny all;
}
}
```
**Remove `'baseUrl' => '/backend'` from `/my/path/to/yii2-start/backend/config/main.php`.**
- Use the URL `http://yii2-start.domain` to access application frontend.
- Use the URL `http://backend.yii2-start.domain` to access application backend.
注意
默认情况下将创建一个超级管理员用户,登录名为 admin
,密码为 admin12345
,您可以使用这些数据登录到应用程序前端和后端。