Skip to content

Commit 8a6e4e0

Browse files
committed
提交Yii2-Admin初始化项目
0 parents  commit 8a6e4e0

File tree

2,119 files changed

+466048
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

2,119 files changed

+466048
-0
lines changed

.gitignore

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# yii console command
2+
/yii
3+
4+
# phpstorm project files
5+
.idea
6+
7+
# netbeans project files
8+
nbproject
9+
10+
# zend studio for eclipse project files
11+
.buildpath
12+
.project
13+
.settings
14+
15+
# windows thumbnail cache
16+
Thumbs.db
17+
18+
# composer vendor dir
19+
#!/vendor
20+
#/vendor/*
21+
#!/vendor/mdmsoft
22+
/vendor
23+
24+
# composer itself is not needed
25+
composer.phar
26+
27+
# Mac DS_Store Files
28+
.DS_Store
29+
30+
# phpunit itself is not needed
31+
phpunit.phar
32+
# local phpunit config
33+
/phpunit.xml
34+
35+
# vagrant runtime
36+
/.vagrant

LICENSE.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
The Yii framework is free software. It is released under the terms of
2+
the following BSD License.
3+
4+
Copyright © 2008 by Yii Software LLC (http://www.yiisoft.com)
5+
All rights reserved.
6+
7+
Redistribution and use in source and binary forms, with or without
8+
modification, are permitted provided that the following conditions
9+
are met:
10+
11+
* Redistributions of source code must retain the above copyright
12+
notice, this list of conditions and the following disclaimer.
13+
* Redistributions in binary form must reproduce the above copyright
14+
notice, this list of conditions and the following disclaimer in
15+
the documentation and/or other materials provided with the
16+
distribution.
17+
* Neither the name of Yii Software LLC nor the names of its
18+
contributors may be used to endorse or promote products derived
19+
from this software without specific prior written permission.
20+
21+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24+
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25+
COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26+
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27+
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28+
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30+
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31+
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32+
POSSIBILITY OF SUCH DAMAGE.

README.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
Yii 2 Advanced Project Template
2+
===============================
3+
4+
Yii 2 Advanced Project Template is a skeleton [Yii 2](http://www.yiiframework.com/) application best for
5+
developing complex Web applications with multiple tiers.
6+
7+
The template includes three tiers: front end, back end, and console, each of which
8+
is a separate Yii application.
9+
10+
The template is designed to work in a team development environment. It supports
11+
deploying the application in different environments.
12+
13+
Documentation is at [docs/guide/README.md](docs/guide/README.md).
14+
15+
[![Latest Stable Version](https://poser.pugx.org/yiisoft/yii2-app-advanced/v/stable.png)](https://packagist.org/packages/yiisoft/yii2-app-advanced)
16+
[![Total Downloads](https://poser.pugx.org/yiisoft/yii2-app-advanced/downloads.png)](https://packagist.org/packages/yiisoft/yii2-app-advanced)
17+
[![Build Status](https://travis-ci.org/yiisoft/yii2-app-advanced.svg?branch=master)](https://travis-ci.org/yiisoft/yii2-app-advanced)
18+
19+
DIRECTORY STRUCTURE
20+
-------------------
21+
22+
```
23+
common
24+
config/ contains shared configurations
25+
mail/ contains view files for e-mails
26+
models/ contains model classes used in both backend and frontend
27+
console
28+
config/ contains console configurations
29+
controllers/ contains console controllers (commands)
30+
migrations/ contains database migrations
31+
models/ contains console-specific model classes
32+
runtime/ contains files generated during runtime
33+
backend
34+
assets/ contains application assets such as JavaScript and CSS
35+
config/ contains backend configurations
36+
controllers/ contains Web controller classes
37+
models/ contains backend-specific model classes
38+
runtime/ contains files generated during runtime
39+
views/ contains view files for the Web application
40+
web/ contains the entry script and Web resources
41+
frontend
42+
assets/ contains application assets such as JavaScript and CSS
43+
config/ contains frontend configurations
44+
controllers/ contains Web controller classes
45+
models/ contains frontend-specific model classes
46+
runtime/ contains files generated during runtime
47+
views/ contains view files for the Web application
48+
web/ contains the entry script and Web resources
49+
widgets/ contains frontend widgets
50+
vendor/ contains dependent 3rd-party packages
51+
environments/ contains environment-based overrides
52+
tests contains various tests for the advanced application
53+
codeception/ contains tests developed with Codeception PHP Testing Framework
54+
```

Vagrantfile

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
require 'yaml'
2+
require 'fileutils'
3+
4+
domains = {
5+
frontend: 'y2aa-frontend.dev',
6+
backend: 'y2aa-backend.dev'
7+
}
8+
9+
config = {
10+
local: './vagrant/config/vagrant-local.yml',
11+
example: './vagrant/config/vagrant-local.example.yml'
12+
}
13+
14+
# copy config from example if local config not exists
15+
FileUtils.cp config[:example], config[:local] unless File.exist?(config[:local])
16+
# read config
17+
options = YAML.load_file config[:local]
18+
19+
# check github token
20+
if options['github_token'].nil? || options['github_token'].to_s.length != 40
21+
puts "You must place REAL GitHub token into configuration:\n/yii2-app-advancded/vagrant/config/vagrant-local.yml"
22+
exit
23+
end
24+
25+
# vagrant configurate
26+
Vagrant.configure(2) do |config|
27+
# select the box
28+
config.vm.box = 'ubuntu/trusty64'
29+
30+
# should we ask about box updates?
31+
config.vm.box_check_update = options['box_check_update']
32+
33+
config.vm.provider 'virtualbox' do |vb|
34+
# machine cpus count
35+
vb.cpus = options['cpus']
36+
# machine memory size
37+
vb.memory = options['memory']
38+
# machine name (for VirtualBox UI)
39+
vb.name = options['machine_name']
40+
end
41+
42+
# machine name (for vagrant console)
43+
config.vm.define options['machine_name']
44+
45+
# machine name (for guest machine console)
46+
config.vm.hostname = options['machine_name']
47+
48+
# network settings
49+
config.vm.network 'private_network', ip: options['ip']
50+
51+
# sync: folder 'yii2-app-advanced' (host machine) -> folder '/app' (guest machine)
52+
config.vm.synced_folder './', '/app', owner: 'vagrant', group: 'vagrant'
53+
54+
# disable folder '/vagrant' (guest machine)
55+
config.vm.synced_folder '.', '/vagrant', disabled: true
56+
57+
# hosts settings (host machine)
58+
config.vm.provision :hostmanager
59+
config.hostmanager.enabled = true
60+
config.hostmanager.manage_host = true
61+
config.hostmanager.ignore_private_ip = false
62+
config.hostmanager.include_offline = true
63+
config.hostmanager.aliases = domains.values
64+
65+
# provisioners
66+
config.vm.provision 'shell', path: './vagrant/provision/once-as-root.sh', args: [options['timezone']]
67+
config.vm.provision 'shell', path: './vagrant/provision/once-as-vagrant.sh', args: [options['github_token']], privileged: false
68+
config.vm.provision 'shell', path: './vagrant/provision/always-as-root.sh', run: 'always'
69+
70+
# post-install message (vagrant console)
71+
config.vm.post_up_message = "Frontend URL: http://#{domains[:frontend]}\nBackend URL: http://#{domains[:backend]}"
72+
end

backend/assets/AppAsset.php

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
3+
namespace backend\assets;
4+
5+
use yii\web\AssetBundle;
6+
7+
/**
8+
* Main backend application asset bundle.
9+
*/
10+
class AppAsset extends AssetBundle
11+
{
12+
public $basePath = '@webroot';
13+
public $baseUrl = '@web';
14+
public $css = [
15+
'statics/css/bootstrap.min.css',
16+
'statics/css/bootstrap-reset.css',
17+
'statics/assets/font-awesome/css/font-awesome.css',
18+
'statics/css/style.css',
19+
'statics/css/style-responsive.css',
20+
];
21+
public $js = [
22+
// 'statics/js/jquery.js',
23+
'statics/js/bootstrap.min.js',
24+
'statics/js/jquery.dcjqaccordion.2.7.js',
25+
'statics/js/jquery.scrollTo.min.js',
26+
'statics/js/jquery.nicescroll.js',
27+
'statics/js/jquery.sparkline.js',
28+
'statics/js/slidebars.min.js',
29+
'statics/js/common-scripts.js',
30+
];
31+
public $depends = [
32+
'yii\web\YiiAsset',
33+
// 'yii\bootstrap\BootstrapAsset',
34+
];
35+
}

backend/config/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
main-local.php
2+
params-local.php

backend/config/bootstrap.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<?php

backend/config/main.php

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
<?php
2+
$params = array_merge(
3+
require(__DIR__ . '/../../common/config/params.php'),
4+
require(__DIR__ . '/../../common/config/params-local.php'),
5+
require(__DIR__ . '/params.php'),
6+
require(__DIR__ . '/params-local.php')
7+
);
8+
9+
return [
10+
'id' => 'app-backend',
11+
'basePath' => dirname(__DIR__),
12+
'controllerNamespace' => 'backend\controllers',
13+
'bootstrap' => ['log'],
14+
'language' => 'zh-CN',
15+
'modules' => [
16+
'admin' => [
17+
'class' => 'izyue\admin\Module',
18+
// 'layout' => 'left-menu',
19+
'layout' => '@app/views/layouts/main.php',
20+
]
21+
],
22+
'components' => [
23+
'user' => [
24+
'identityClass' => 'common\models\AdminModel',
25+
'enableAutoLogin' => true,
26+
],
27+
'log' => [
28+
'traceLevel' => YII_DEBUG ? 3 : 0,
29+
'targets' => [
30+
[
31+
'class' => 'yii\log\FileTarget',
32+
'levels' => ['error', 'warning'],
33+
],
34+
],
35+
],
36+
'errorHandler' => [
37+
'errorAction' => 'site/error',
38+
],
39+
'authManager' => [
40+
'class' => 'yii\rbac\DbManager', // or use 'yii\rbac\PhpManager'
41+
],
42+
'i18n' => [
43+
'translations' => [
44+
'common' => [
45+
'class' => 'yii\i18n\PhpMessageSource',
46+
//'basePath' => '/messages',
47+
'fileMap' => [
48+
'common' => 'common.php',
49+
],
50+
],
51+
'login' => [
52+
'class' => 'yii\i18n\PhpMessageSource',
53+
//'basePath' => '/messages',
54+
'fileMap' => [
55+
'login' => 'login.php',
56+
],
57+
],
58+
'signup' => [
59+
'class' => 'yii\i18n\PhpMessageSource',
60+
//'basePath' => '/messages',
61+
'fileMap' => [
62+
'admin' => 'sginup.php',
63+
],
64+
],
65+
'admin' => [
66+
'class' => 'yii\i18n\PhpMessageSource',
67+
//'basePath' => '/messages',
68+
'fileMap' => [
69+
'admin' => 'admin.php',
70+
],
71+
],
72+
],
73+
],
74+
// 'urlManager' => [
75+
// 'enablePrettyUrl' => true,
76+
// 'showScriptName' => false,
77+
// 'suffix' => '.html',
78+
// 'rules'=>[
79+
// ],
80+
// ],
81+
/*
82+
'urlManager' => [
83+
'enablePrettyUrl' => true,
84+
'showScriptName' => false,
85+
'rules' => [
86+
],
87+
],
88+
*/
89+
],
90+
'as access' => [
91+
'class' => 'izyue\admin\components\AccessControl',
92+
'allowActions' => [
93+
'debug/*',
94+
'site/*',
95+
// 'admin/*',
96+
// The actions listed here will be allowed to everyone including guests.
97+
// So, 'admin/*' should not appear here in the production, of course.
98+
// But in the earlier stages of your development, you may probably want to
99+
// add a lot of actions here until you finally completed setting up rbac,
100+
// otherwise you may not even take a first step.
101+
]
102+
],
103+
'params' => $params,
104+
];

backend/config/params.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?php
2+
return [
3+
'adminEmail' => '[email protected]',
4+
];

0 commit comments

Comments
 (0)