Skip to content

Commit 0f77a43

Browse files
committed
first commit
0 parents  commit 0f77a43

File tree

182 files changed

+9267
-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.

182 files changed

+9267
-0
lines changed

.bowerrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"directory" : "vendor/bower-asset"
3+
}

.gitignore

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

LICENSE.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
The Yii App is free software. It is released under the terms of
2+
the following BSD License.
3+
4+
Copyright © 2018 by Akiraz
5+
All rights are not 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: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
# Yii2 App
2+
3+
Yii2-app is my advanced project template.
4+
5+
Default, the template includes three tiers: `frontend`, `backend`, and `console`, each of which is a separate Yii application.
6+
> **NOTE:** Template is in initial development. Anything may change at any time.
7+
8+
## Features
9+
* Admin template: [yiister/yii2-gentelella](https://github.com/yiister/yii2-gentelella), [Demo](https://colorlib.com/polygon/gentelella/)
10+
* Yii2 User: [dektrium/yii2-user](https://github.com/dektrium/yii2-user) (login `adminus`, password `adminus`)
11+
* Frontend and Backend User Controllers are filtered (by `dektrium/yii2-user`)
12+
* Redis cache
13+
* Yii2 queue (DB table `queue`)
14+
* Log DB Target with backend (`/log/index`)
15+
* **UrlManagerFrontend** for backend app (all url rules in file `frontend/config/urls.php`, hostInfo in `common/config/params.php`)
16+
* i18n translations in `common/messages` with config
17+
* ContactForm in frontend app is improved: [himiklab/yii2-recaptcha-widget](https://github.com/himiklab/yii2-recaptcha-widget),
18+
all email are saved to DB (`common/models/EmailForm` Model), optionally send message to Viber messenger via bot
19+
(install requirements and config, uncomment code in Model)
20+
* **postcss** config
21+
22+
23+
## Installation
24+
Yii2-app template can be installed using composer. Run following command to download and install Yii2-app:
25+
```
26+
composer create-project --prefer-dist akiraz2/yii2-app my-site
27+
```
28+
After installation run `init`
29+
30+
### Migrations
31+
32+
Make sure that you have properly configured `db` application component and run the following command
33+
34+
```
35+
php yii migrate/up --migrationPath=@vendor/dektrium/yii2-user/migrations
36+
php yii migrate --migrationPath=@yii/log/migrations/
37+
php yii migrate/up
38+
```
39+
40+
41+
## Development
42+
43+
### Messages
44+
Change in `common/config/main.php`
45+
```
46+
'language' => 'ru-RU',
47+
'sourceLanguage' => 'en-US',
48+
```
49+
In shell
50+
```
51+
php yii message/extract common/messages/config.php
52+
```
53+
54+
**POSTCSS**
55+
56+
```
57+
webstorm file-watcher
58+
59+
scope file[mites-site]:frontend/web/src/pcss//*.css
60+
61+
program C:\Users\user4957\AppData\Roaming\npm\postcss.cmd
62+
63+
arguments $ContentRoot$\frontend\web\css\style.css --config $ContentRoot$\post.config.js
64+
```
65+
66+
## Support
67+
68+
If you have any questions or problems with Yii2-App you can ask them directly
69+
by using following email address: `akiraz@bk.ru`.
70+
71+
72+
## Contributing
73+
74+
If you'd like to contribute, please fork the repository and use a feature branch. Pull requests are warmly welcome.
75+
+PSR-2 style coding.
76+
77+
I can apply patch, PR in 2-3 days! If not, please write me `akiraz@bk.ru`
78+
79+
## Licensing
80+
81+
Yii2-App is released under the BSD License. See the bundled [LICENSE.md](LICENSE.md)
82+
for details.

Vagrantfile

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

backend/assets/AppAsset.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
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+
'css/site.css',
16+
];
17+
public $js = [
18+
];
19+
public $depends = [
20+
'yii\web\YiiAsset',
21+
'yii\bootstrap\BootstrapAsset',
22+
];
23+
}

backend/codeception.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
namespace: backend\tests
2+
actor_suffix: Tester
3+
paths:
4+
tests: tests
5+
output: tests/_output
6+
data: tests/_data
7+
support: tests/_support
8+
settings:
9+
bootstrap: _bootstrap.php
10+
colors: true
11+
memory_limit: 1024M
12+
modules:
13+
config:
14+
Yii2:
15+
configFile: 'config/test-local.php'
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
/**
3+
* Project: yii2-blog for internal using
4+
* Author: akiraz2
5+
* Copyright (c) 2018.
6+
*/
7+
8+
namespace backend\components;
9+
10+
use yii\filters\AccessControl;
11+
12+
class AdminAccessControl extends AccessControl
13+
{
14+
15+
public function init()
16+
{
17+
$this->rules[] =[
18+
'allow' => true,
19+
'roles' => ['@'],
20+
'matchCallback' => function () {
21+
return \Yii::$app->user->identity->getIsAdmin();
22+
}
23+
];
24+
parent::init(); // TODO: Change the autogenerated stub
25+
}
26+
}

backend/config/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
main-local.php
2+
params-local.php
3+
test-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

0 commit comments

Comments
 (0)