├── .gitignore ├── .htaccess ├── LICENSE.md ├── README.md ├── backend ├── config │ ├── .gitignore │ ├── main.php │ └── params.php ├── runtime │ └── .gitignore └── web │ ├── .gitignore │ ├── .htaccess │ └── assets │ └── .gitignore ├── cache └── .gitignore ├── common ├── config │ ├── .gitignore │ ├── aliases.php │ ├── db.php │ ├── main.php │ └── params.php └── data │ └── db.sql ├── composer.json ├── console ├── config │ ├── .gitignore │ ├── main.php │ └── params.php └── runtime │ └── .gitignore ├── environments ├── dev │ ├── backend │ │ ├── config │ │ │ ├── main-local.php │ │ │ └── params-local.php │ │ └── web │ │ │ └── index.php │ ├── common │ │ └── config │ │ │ ├── db-local.php │ │ │ ├── main-local.php │ │ │ └── params-local.php │ ├── console │ │ └── config │ │ │ ├── main-local.php │ │ │ └── params-local.php │ ├── frontend │ │ ├── config │ │ │ ├── main-local.php │ │ │ └── params-local.php │ │ └── web │ │ │ └── index.php │ └── yii ├── index.php └── prod │ ├── backend │ ├── config │ │ ├── main-local.php │ │ └── params-local.php │ └── web │ │ └── index.php │ ├── common │ └── config │ │ ├── db-local.php │ │ ├── main-local.php │ │ └── params-local.php │ ├── console │ └── config │ │ ├── main-local.php │ │ └── params-local.php │ ├── frontend │ ├── config │ │ ├── main-local.php │ │ └── params-local.php │ └── web │ │ └── index.php │ └── yii ├── frontend ├── config │ ├── .gitignore │ ├── main.php │ └── params.php ├── runtime │ └── .gitignore └── web │ ├── .gitignore │ ├── .htaccess │ └── assets │ └── .gitignore ├── init ├── init.bat ├── requirements.php ├── statics ├── temp │ └── .gitignore └── web │ ├── .htaccess │ ├── blogs │ ├── images │ │ └── .gitignore │ └── previews │ │ └── .gitignore │ └── users │ └── avatars │ └── .gitignore └── yii.bat /.gitignore: -------------------------------------------------------------------------------- 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 | 21 | # composer itself is not needed 22 | composer.phar 23 | # composer.lock 24 | /composer.lock 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 -------------------------------------------------------------------------------- /.htaccess: -------------------------------------------------------------------------------- 1 | # Mod_Autoindex 2 | 3 | # Disable Indexes 4 | Options -Indexes 5 | 6 | 7 | # Mod_Rewrite 8 | 9 | # Enable symlinks 10 | Options +FollowSymlinks 11 | # Enable mod_rewrite 12 | RewriteEngine On 13 | 14 | # Backend redirect 15 | RewriteCond %{REQUEST_URI} ^/backend 16 | RewriteRule ^backend/(.*)$ backend/web/$1 [L] 17 | 18 | # Statics redirect 19 | RewriteCond %{REQUEST_URI} ^/statics 20 | RewriteRule ^statics/(.*)$ statics/web/$1 [L] 21 | 22 | # Frontend redirect 23 | RewriteCond %{REQUEST_URI} ^(.*)$ 24 | RewriteRule ^(.*)$ frontend/web/$1 25 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | The Yii2-start application is free software. It is released under the terms of 2 | the following BSD License. 3 | 4 | Copyright © 2014 by vova07 (https://github.com/vova07) 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: -------------------------------------------------------------------------------- 1 | Yii2-start 2 | ========== 3 | 4 | DEMO: 5 | ----- 6 | 7 | **Frontend:** [http://yii2-start.find-freelancer.pro](http://yii2-start.find-freelancer.pro) 8 | **Backend:** [http://yii2-start.find-freelancer.pro/backend/](http://yii2-start.find-freelancer.pro/backend/) 9 | 10 | **Authentication:** 11 | _Login:_ `admin` 12 | _Password:_ `admin12345` 13 | 14 | Installation and getting started: 15 | --------------------------------- 16 | 17 | **If you do not have Composer, you may install it by following the instructions at getcomposer.org.** 18 | 19 | **If you do not have Composer-Asset-Plugin installed, you may install it by running command:** `php composer.phar global require "fxp/composer-asset-plugin:1.0.0"` 20 | 21 | 1. Run the following commands to install Yii2-Start: `php composer.phar create-project --prefer-dist --stability=dev vova07/yii2-start yii2-start` 22 | **During the installation process can be required `password` and\or `username` from your Github account. This is because you make too much request to Github service. Just remember that this can be.** 23 | 2. Run command: `cd /my/path/to/yii2-start/` and go to main application directory. 24 | 3. Run command: `php requirements.php` and check the requirements. 25 | 4. Run command: `php init` to initialize the application with a specific environment. 26 | 5. Create a new database and adjust it configuration in `common/config/db.php` accordingly. 27 | 6. Apply migrations with console commands: 28 | - `php yii migrate --migrationPath=@vova07/users/migrations` 29 | - `php yii migrate --migrationPath=@vova07/blogs/migrations` 30 | - `php yii migrate --migrationPath=@vova07/comments/migrations` 31 | - This will create tables needed for the application to work. 32 | - You also can use database dump `db.sql` from `my/path/to/yii2-start/common/data`, but however I recommend to use migrations. 33 | 7. Run modules RBAC commands: 34 | - `php yii rbac/rbac/init` 35 | - `php yii users/rbac/add` 36 | - `php yii blogs/rbac/add` 37 | - `php yii comments/rbac/add` 38 | 8. Set document roots of your Web server: 39 | 40 | **For Apache:** 41 | 42 | ``` 43 | 44 | ServerName www.yii2-start.domain # You need to change it to your own domain 45 | ServerAlias yii2-start.domain # You need to change it to your own domain 46 | DocumentRoot /my/path/to/yii2-start # You need to change it to your own path 47 | # You need to change it to your own path 48 | AllowOverride All 49 | 50 | 51 | ``` 52 | - Use the URL `http://yii2-start.domain` to access application frontend. 53 | - Use the URL `http://yii2-start.domain/backend/` to access application backend. 54 | 55 | **For Nginx:** 56 | 57 | ___Frontend___ 58 | 59 | ``` 60 | server { 61 | charset utf-8; 62 | client_max_body_size 128M; 63 | 64 | listen 80; ## listen for ipv4 65 | # listen [::]:80 ipv6only=on; ## listen for ipv6 66 | 67 | set $yii2StartRoot '/my/path/to/yii2-start'; ## You need to change it to your own path 68 | 69 | server_name yii2-start.domain; ## You need to change it to your own domain 70 | root $yii2StartRoot/frontend/web; 71 | index index.php; 72 | 73 | #access_log $yii2StartRoot/log/frontend/access.log; 74 | #error_log $yii2StartRoot/log/frontend/error.log; 75 | 76 | location / { 77 | # Redirect everything that isn't a real file to index.php 78 | try_files $uri $uri/ /index.php?$args; 79 | } 80 | 81 | location /statics { 82 | alias $yii2StartRoot/statics/web/; 83 | } 84 | 85 | # uncomment to avoid processing of calls to non-existing static files by Yii 86 | #location ~ \.(js|css|png|jpg|gif|swf|ico|pdf|mov|fla|zip|rar)$ { 87 | # try_files $uri =404; 88 | #} 89 | #error_page 404 /404.html; 90 | 91 | location ~ \.php$ { 92 | #include fastcgi_params; 93 | include fastcgi.conf; 94 | fastcgi_pass 127.0.0.1:9000; 95 | #fastcgi_pass unix:/var/run/php5-fpm.sock; 96 | try_files $uri =404; 97 | } 98 | 99 | location ~ /\.(ht|svn|git) { 100 | deny all; 101 | } 102 | } 103 | ``` 104 | 105 | __Backend__ 106 | 107 | ``` 108 | server { 109 | charset utf-8; 110 | client_max_body_size 128M; 111 | 112 | listen 80; ## listen for ipv4 113 | # listen [::]:80 ipv6only=on; ## listen for ipv6 114 | 115 | set $yii2StartRoot '/my/path/to/yii2-start'; ## You need to change it to your own path 116 | 117 | server_name backend.yii2-start.domain; ## You need to change it to your own domain 118 | root $yii2StartRoot/backend/web; 119 | index index.php; 120 | 121 | #access_log $yii2StartRoot/log/backend/access.log; 122 | #error_log $yii2StartRoot/log/backend/error.log; 123 | 124 | location / { 125 | # Redirect everything that isn't a real file to index.php 126 | try_files $uri $uri/ /index.php?$args; 127 | } 128 | 129 | location /statics { 130 | alias $yii2StartRoot/statics/web/; 131 | } 132 | 133 | # uncomment to avoid processing of calls to non-existing static files by Yii 134 | #location ~ \.(js|css|png|jpg|gif|swf|ico|pdf|mov|fla|zip|rar)$ { 135 | # try_files $uri =404; 136 | #} 137 | #error_page 404 /404.html; 138 | 139 | location ~ \.php$ { 140 | #include fastcgi_params; 141 | include fastcgi.conf; 142 | fastcgi_pass 127.0.0.1:9000; 143 | #fastcgi_pass unix:/var/run/php5-fpm.sock; 144 | try_files $uri =404; 145 | } 146 | 147 | location ~ /\.(ht|svn|git) { 148 | deny all; 149 | } 150 | } 151 | ``` 152 | 153 | **Remove `'baseUrl' => '/backend'` from `/my/path/to/yii2-start/backend/config/main.php`.** 154 | 155 | - Use the URL `http://yii2-start.domain` to access application frontend. 156 | - Use the URL `http://backend.yii2-start.domain` to access application backend. 157 | 158 | Notes: 159 | ------ 160 | 161 | By default will be created one super admin user with login `admin` and password `admin12345`, you can use this data to sing in application frontend and backend. 162 | 163 | Themes: 164 | ------- 165 | - Application backend it's based on "AdminLTE" template. More detail about this nice template you can find [here](http://www.bootstrapstage.com/admin-lte/). 166 | - Application frontend it's based on "Flat Theme". More detail about this nice theme you can find [here](http://shapebootstrap.net/item/flat-theme-free-responsive-multipurpose-site-template/). 167 | -------------------------------------------------------------------------------- /backend/config/.gitignore: -------------------------------------------------------------------------------- 1 | main-local.php 2 | params-local.php -------------------------------------------------------------------------------- /backend/config/main.php: -------------------------------------------------------------------------------- 1 | 'app-backend', 7 | 'name' => 'Yii2-Start', 8 | 'basePath' => dirname(__DIR__), 9 | 'defaultRoute' => 'admin/default/index', 10 | 'modules' => [ 11 | 'admin' => [ 12 | 'class' => 'vova07\admin\Module' 13 | ], 14 | 'users' => [ 15 | 'controllerNamespace' => 'vova07\users\controllers\backend' 16 | ], 17 | 'blogs' => [ 18 | 'isBackend' => true 19 | ], 20 | 'comments' => [ 21 | 'isBackend' => true 22 | ], 23 | 'rbac' => [ 24 | 'class' => 'vova07\rbac\Module', 25 | 'isBackend' => true 26 | ] 27 | ], 28 | 'components' => [ 29 | 'request' => [ 30 | 'cookieValidationKey' => '7fdsf%dbYd&djsb#sn0mlsfo(kj^kf98dfh', 31 | 'baseUrl' => '/backend' 32 | ], 33 | 'urlManager' => [ 34 | 'rules' => [ 35 | '' => 'admin/default/index', 36 | '<_m>/<_c>/<_a>' => '<_m>/<_c>/<_a>' 37 | ] 38 | ], 39 | 'view' => [ 40 | 'theme' => 'vova07\themes\admin\Theme' 41 | ], 42 | 'errorHandler' => [ 43 | 'errorAction' => 'admin/default/error' 44 | ], 45 | 'log' => [ 46 | 'traceLevel' => YII_DEBUG ? 3 : 0, 47 | 'targets' => [ 48 | [ 49 | 'class' => 'yii\log\FileTarget', 50 | 'levels' => ['error', 'warning'] 51 | ] 52 | ] 53 | ] 54 | ], 55 | 'params' => require(__DIR__ . '/params.php') 56 | ]; 57 | -------------------------------------------------------------------------------- /backend/config/params.php: -------------------------------------------------------------------------------- 1 | 3 | # Enable mod_rewrite 4 | RewriteEngine On 5 | 6 | # If a directory or a file exists, use the request directly 7 | RewriteCond %{REQUEST_FILENAME} !-f 8 | RewriteCond %{REQUEST_FILENAME} !-d 9 | # Otherwise forward the request to index.php 10 | RewriteRule . index.php 11 | -------------------------------------------------------------------------------- /backend/web/assets/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore -------------------------------------------------------------------------------- /cache/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore -------------------------------------------------------------------------------- /common/config/.gitignore: -------------------------------------------------------------------------------- 1 | main-local.php 2 | params-local.php 3 | db-local.php -------------------------------------------------------------------------------- /common/config/aliases.php: -------------------------------------------------------------------------------- 1 | 'yii\db\Connection', 5 | 'dsn' => 'mysql:host=127.0.0.1;dbname=yii2-start', 6 | 'username' => 'root', 7 | 'password' => '12345', 8 | 'charset' => 'utf8', 9 | 'tablePrefix' => 'yii2_start_' 10 | ]; 11 | -------------------------------------------------------------------------------- /common/config/main.php: -------------------------------------------------------------------------------- 1 | dirname(dirname(__DIR__)) . '/vendor', 5 | 'timeZone' => 'Europe/Moscow', 6 | 'modules' => [ 7 | 'users' => [ 8 | 'class' => 'vova07\users\Module', 9 | 'robotEmail' => 'no-reply@domain.com', 10 | 'robotName' => 'Robot' 11 | ], 12 | 'blogs' => [ 13 | 'class' => 'vova07\blogs\Module' 14 | ], 15 | 'comments' => [ 16 | 'class' => 'vova07\comments\Module' 17 | ] 18 | ], 19 | 'components' => [ 20 | 'user' => [ 21 | 'class' => 'yii\web\User', 22 | 'identityClass' => 'vova07\users\models\User', 23 | 'loginUrl' => ['/users/guest/login'] 24 | ], 25 | 'cache' => [ 26 | 'class' => 'yii\caching\FileCache', 27 | 'cachePath' => '@root/cache', 28 | 'keyPrefix' => 'yii2start' 29 | ], 30 | 'urlManager' => [ 31 | 'enablePrettyUrl' => true, 32 | 'enableStrictParsing' => true, 33 | 'showScriptName' => false, 34 | 'suffix' => '/' 35 | ], 36 | 'assetManager' => [ 37 | 'linkAssets' => true 38 | ], 39 | 'authManager' => [ 40 | 'class' => 'yii\rbac\PhpManager', 41 | 'defaultRoles' => [ 42 | 'user' 43 | ], 44 | 'itemFile' => '@vova07/rbac/data/items.php', 45 | 'assignmentFile' => '@vova07/rbac/data/assignments.php', 46 | 'ruleFile' => '@vova07/rbac/data/rules.php', 47 | ], 48 | 'formatter' => [ 49 | 'dateFormat' => 'dd.MM.y', 50 | 'datetimeFormat' => 'HH:mm:ss dd.MM.y' 51 | ], 52 | 'db' => require(__DIR__ . '/db.php') 53 | ], 54 | 'params' => require(__DIR__ . '/params.php') 55 | ]; 56 | -------------------------------------------------------------------------------- /common/config/params.php: -------------------------------------------------------------------------------- 1 | =5.4.0", 22 | "yiisoft/yii2": "*", 23 | "yiisoft/yii2-bootstrap": "*", 24 | "vova07/yii2-start-base": "*", 25 | "vova07/yii2-start-themes": "*", 26 | "vova07/yii2-start-admin-module": "*", 27 | "vova07/yii2-start-site-module": "*", 28 | "vova07/yii2-start-users-module": "*", 29 | "vova07/yii2-start-blogs-module": "*", 30 | "vova07/yii2-start-comments-module": "*", 31 | "vova07/yii2-start-rbac-module": "*" 32 | }, 33 | "require-dev": { 34 | "yiisoft/yii2-debug": "*", 35 | "yiisoft/yii2-gii": "*" 36 | }, 37 | "config": { 38 | "process-timeout": 1800 39 | }, 40 | "extra": { 41 | "asset-installer-paths": { 42 | "npm-asset-library": "vendor/npm", 43 | "bower-asset-library": "vendor/bower" 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /console/config/.gitignore: -------------------------------------------------------------------------------- 1 | main-local.php 2 | params-local.php -------------------------------------------------------------------------------- /console/config/main.php: -------------------------------------------------------------------------------- 1 | 'app-console', 5 | 'basePath' => dirname(__DIR__), 6 | 'controllerNamespace' => 'console\controllers', 7 | 'bootstrap' => [ 8 | 'log' 9 | ], 10 | 'modules' => [ 11 | 'rbac' => [ 12 | 'class' => 'vova07\rbac\Module', 13 | 'controllerNamespace' => 'vova07\rbac\commands' 14 | ], 15 | 'users' => [ 16 | 'class' => 'vova07\users\Module', 17 | 'controllerNamespace' => 'vova07\users\commands' 18 | ], 19 | 'blogs' => [ 20 | 'class' => 'vova07\blogs\Module', 21 | 'controllerNamespace' => 'vova07\blogs\commands' 22 | ], 23 | 'comments' => [ 24 | 'class' => 'vova07\comments\Module', 25 | 'controllerNamespace' => 'vova07\comments\commands' 26 | ] 27 | ], 28 | 'components' => [ 29 | 'log' => [ 30 | 'targets' => [ 31 | [ 32 | 'class' => 'yii\log\FileTarget', 33 | 'levels' => ['error', 'warning'] 34 | ] 35 | ] 36 | ] 37 | ], 38 | 'params' => require(__DIR__ . '/params.php') 39 | ]; 40 | -------------------------------------------------------------------------------- /console/config/params.php: -------------------------------------------------------------------------------- 1 | require(__DIR__ . '/params-local.php') 5 | ]; 6 | -------------------------------------------------------------------------------- /environments/dev/backend/config/params-local.php: -------------------------------------------------------------------------------- 1 | run(); 18 | -------------------------------------------------------------------------------- /environments/dev/common/config/db-local.php: -------------------------------------------------------------------------------- 1 | [ 4 | 'debug', 5 | 'gii' 6 | ], 7 | 'modules' => [ 8 | 'debug' => [ 9 | 'class' => 'yii\debug\Module' 10 | ], 11 | 'gii' => [ 12 | 'class' => 'yii\gii\Module' 13 | ] 14 | ], 15 | 'components' => [ 16 | 'db' => require(__DIR__ . '/db-local.php') 17 | ], 18 | 'params' => require(__DIR__ . '/params-local.php') 19 | ]; 20 | -------------------------------------------------------------------------------- /environments/dev/common/config/params-local.php: -------------------------------------------------------------------------------- 1 | require(__DIR__ . '/params-local.php') 4 | ]; 5 | -------------------------------------------------------------------------------- /environments/dev/console/config/params-local.php: -------------------------------------------------------------------------------- 1 | require(__DIR__ . '/params-local.php') 5 | ]; 6 | -------------------------------------------------------------------------------- /environments/dev/frontend/config/params-local.php: -------------------------------------------------------------------------------- 1 | run(); 18 | -------------------------------------------------------------------------------- /environments/dev/yii: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env php 2 | run(); 31 | exit($exitCode); 32 | -------------------------------------------------------------------------------- /environments/index.php: -------------------------------------------------------------------------------- 1 | [ 11 | * 'path' => 'directory storing the local files', 12 | * 'setWritable' => [ 13 | * // list of directories that should be set writable 14 | * ], 15 | * 'setExecutable' => [ 16 | * // list of directories that should be set executable 17 | * ], 18 | * 'setCookieValidationKey' => [ 19 | * // list of config files that need to be inserted with automatically generated cookie validation keys 20 | * ], 21 | * ], 22 | * ]; 23 | * ``` 24 | */ 25 | return [ 26 | 'Development' => [ 27 | 'path' => 'dev', 28 | 'setWritable' => [ 29 | 'backend/runtime', 30 | 'backend/web/assets', 31 | 'frontend/runtime', 32 | 'frontend/web/assets', 33 | ], 34 | 'setExecutable' => [ 35 | 'yii', 36 | ], 37 | 'setCookieValidationKey' => [ 38 | 'backend/config/main-local.php', 39 | 'frontend/config/main-local.php', 40 | ], 41 | ], 42 | 'Production' => [ 43 | 'path' => 'prod', 44 | 'setWritable' => [ 45 | 'backend/runtime', 46 | 'backend/web/assets', 47 | 'frontend/runtime', 48 | 'frontend/web/assets', 49 | ], 50 | 'setExecutable' => [ 51 | 'yii', 52 | ], 53 | 'setCookieValidationKey' => [ 54 | 'backend/config/main-local.php', 55 | 'frontend/config/main-local.php', 56 | ], 57 | ], 58 | ]; 59 | -------------------------------------------------------------------------------- /environments/prod/backend/config/main-local.php: -------------------------------------------------------------------------------- 1 | require(__DIR__ . '/params-local.php') 5 | ]; 6 | -------------------------------------------------------------------------------- /environments/prod/backend/config/params-local.php: -------------------------------------------------------------------------------- 1 | run(); 18 | -------------------------------------------------------------------------------- /environments/prod/common/config/db-local.php: -------------------------------------------------------------------------------- 1 | [ 4 | 'debug', 5 | 'gii' 6 | ], 7 | 'modules' => [ 8 | 'debug' => [ 9 | 'class' => 'yii\debug\Module' 10 | ], 11 | 'gii' => [ 12 | 'class' => 'yii\gii\Module' 13 | ] 14 | ], 15 | 'components' => [ 16 | 'db' => require(__DIR__ . '/db-local.php') 17 | ], 18 | 'params' => require(__DIR__ . '/params-local.php') 19 | ]; 20 | -------------------------------------------------------------------------------- /environments/prod/common/config/params-local.php: -------------------------------------------------------------------------------- 1 | require(__DIR__ . '/params-local.php') 4 | ]; 5 | -------------------------------------------------------------------------------- /environments/prod/console/config/params-local.php: -------------------------------------------------------------------------------- 1 | require(__DIR__ . '/params-local.php') 5 | ]; 6 | -------------------------------------------------------------------------------- /environments/prod/frontend/config/params-local.php: -------------------------------------------------------------------------------- 1 | run(); 18 | -------------------------------------------------------------------------------- /environments/prod/yii: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env php 2 | run(); 31 | exit($exitCode); 32 | -------------------------------------------------------------------------------- /frontend/config/.gitignore: -------------------------------------------------------------------------------- 1 | main-local.php 2 | params-local.php -------------------------------------------------------------------------------- /frontend/config/main.php: -------------------------------------------------------------------------------- 1 | 'app-frontend', 5 | 'name' => 'Yii2-Start', 6 | 'basePath' => dirname(__DIR__), 7 | 'defaultRoute' => 'site/default/index', 8 | 'modules' => [ 9 | 'site' => [ 10 | 'class' => 'vova07\site\Module' 11 | ], 12 | 'blogs' => [ 13 | 'controllerNamespace' => 'vova07\blogs\controllers\frontend' 14 | ], 15 | ], 16 | 'components' => [ 17 | 'request' => [ 18 | 'cookieValidationKey' => 'sdi8s#fnj98jwiqiw;qfh!fjgh0d8f', 19 | 'baseUrl' => '' 20 | ], 21 | 'urlManager' => [ 22 | 'rules' => [ 23 | '' => 'site/default/index', 24 | '<_a:(about|contacts|captcha)>' => 'site/default/<_a>' 25 | ] 26 | ], 27 | 'view' => [ 28 | 'theme' => 'vova07\themes\site\Theme' 29 | ], 30 | 'errorHandler' => [ 31 | 'errorAction' => 'site/default/error' 32 | ], 33 | 'log' => [ 34 | 'traceLevel' => YII_DEBUG ? 3 : 0, 35 | 'targets' => [ 36 | [ 37 | 'class' => 'yii\log\FileTarget', 38 | 'levels' => ['error', 'warning'] 39 | ] 40 | ] 41 | ] 42 | ], 43 | 'params' => require(__DIR__ . '/params.php') 44 | ]; 45 | -------------------------------------------------------------------------------- /frontend/config/params.php: -------------------------------------------------------------------------------- 1 | 3 | # Enable mod_rewrite 4 | RewriteEngine On 5 | 6 | # If a directory or a file exists, use the request directly 7 | RewriteCond %{REQUEST_FILENAME} !-f 8 | RewriteCond %{REQUEST_FILENAME} !-d 9 | # Otherwise forward the request to index.php 10 | RewriteRule . index.php 11 | -------------------------------------------------------------------------------- /frontend/web/assets/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore -------------------------------------------------------------------------------- /init: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env php 2 | 11 | * 12 | * @link http://www.yiiframework.com/ 13 | * @copyright Copyright (c) 2008 Yii Software LLC 14 | * @license http://www.yiiframework.com/license/ 15 | */ 16 | 17 | if (!extension_loaded('mcrypt')) { 18 | die('The mcrypt PHP extension is required by Yii2.'); 19 | } 20 | 21 | $params = getParams(); 22 | $root = str_replace('\\', '/', __DIR__); 23 | $envs = require("$root/environments/index.php"); 24 | $envNames = array_keys($envs); 25 | 26 | echo "Yii Application Initialization Tool v1.0\n\n"; 27 | 28 | $envName = null; 29 | if (empty($params['env']) || $params['env'] === '1') { 30 | echo "Which environment do you want the application to be initialized in?\n\n"; 31 | foreach ($envNames as $i => $name) { 32 | echo " [$i] $name\n"; 33 | } 34 | echo "\n Your choice [0-" . (count($envs) - 1) . ', or "q" to quit] '; 35 | $answer = trim(fgets(STDIN)); 36 | 37 | if (!ctype_digit($answer) || !in_array($answer, range(0, count($envs) - 1))) { 38 | echo "\n Quit initialization.\n"; 39 | exit(0); 40 | } 41 | 42 | if (isset($envNames[$answer])) { 43 | $envName = $envNames[$answer]; 44 | } 45 | } else { 46 | $envName = $params['env']; 47 | } 48 | 49 | if (!in_array($envName, $envNames)) { 50 | $envsList = implode(', ', $envNames); 51 | echo "\n $envName is not a valid environment. Try one of the following: $envsList. \n"; 52 | exit(2); 53 | } 54 | 55 | $env = $envs[$envName]; 56 | 57 | if (empty($params['env'])) { 58 | echo "\n Initialize the application under '{$envNames[$answer]}' environment? [yes|no] "; 59 | $answer = trim(fgets(STDIN)); 60 | if (strncasecmp($answer, 'y', 1)) { 61 | echo "\n Quit initialization.\n"; 62 | exit(0); 63 | } 64 | } 65 | 66 | echo "\n Start initialization ...\n\n"; 67 | $files = getFileList("$root/environments/{$env['path']}"); 68 | $all = false; 69 | foreach ($files as $file) { 70 | if (!copyFile($root, "environments/{$env['path']}/$file", $file, $all, $params)) { 71 | break; 72 | } 73 | } 74 | 75 | $callbacks = ['setCookieValidationKey', 'setWritable', 'setExecutable']; 76 | foreach ($callbacks as $callback) { 77 | if (!empty($env[$callback])) { 78 | $callback($root, $env[$callback]); 79 | } 80 | } 81 | 82 | echo "\n ... initialization completed.\n\n"; 83 | 84 | function getFileList($root, $basePath = '') 85 | { 86 | $files = []; 87 | $handle = opendir($root); 88 | while (($path = readdir($handle)) !== false) { 89 | if ($path === '.svn' || $path === '.' || $path === '..') { 90 | continue; 91 | } 92 | $fullPath = "$root/$path"; 93 | $relativePath = $basePath === '' ? $path : "$basePath/$path"; 94 | if (is_dir($fullPath)) { 95 | $files = array_merge($files, getFileList($fullPath, $relativePath)); 96 | } else { 97 | $files[] = $relativePath; 98 | } 99 | } 100 | closedir($handle); 101 | return $files; 102 | } 103 | 104 | function copyFile($root, $source, $target, &$all, $params) 105 | { 106 | if (!is_file($root . '/' . $source)) { 107 | echo " skip $target ($source not exist)\n"; 108 | return true; 109 | } 110 | if (is_file($root . '/' . $target)) { 111 | if (file_get_contents($root . '/' . $source) === file_get_contents($root . '/' . $target)) { 112 | echo " unchanged $target\n"; 113 | return true; 114 | } 115 | if ($all) { 116 | echo " overwrite $target\n"; 117 | } else { 118 | echo " exist $target\n"; 119 | echo " ...overwrite? [Yes|No|All|Quit] "; 120 | 121 | 122 | $answer = !empty($params['overwrite']) ? $params['overwrite'] : trim(fgets(STDIN)); 123 | if (!strncasecmp($answer, 'q', 1)) { 124 | return false; 125 | } else { 126 | if (!strncasecmp($answer, 'y', 1)) { 127 | echo " overwrite $target\n"; 128 | } else { 129 | if (!strncasecmp($answer, 'a', 1)) { 130 | echo " overwrite $target\n"; 131 | $all = true; 132 | } else { 133 | echo " skip $target\n"; 134 | return true; 135 | } 136 | } 137 | } 138 | } 139 | file_put_contents($root . '/' . $target, file_get_contents($root . '/' . $source)); 140 | return true; 141 | } 142 | echo " generate $target\n"; 143 | @mkdir(dirname($root . '/' . $target), 0777, true); 144 | file_put_contents($root . '/' . $target, file_get_contents($root . '/' . $source)); 145 | return true; 146 | } 147 | 148 | function getParams() 149 | { 150 | $rawParams = []; 151 | if (isset($_SERVER['argv'])) { 152 | $rawParams = $_SERVER['argv']; 153 | array_shift($rawParams); 154 | } 155 | 156 | $params = []; 157 | foreach ($rawParams as $param) { 158 | if (preg_match('/^--(\w+)(=(.*))?$/', $param, $matches)) { 159 | $name = $matches[1]; 160 | $params[$name] = isset($matches[3]) ? $matches[3] : true; 161 | } else { 162 | $params[] = $param; 163 | } 164 | } 165 | return $params; 166 | } 167 | 168 | function setWritable($root, $paths) 169 | { 170 | foreach ($paths as $writable) { 171 | echo " chmod 0777 $writable\n"; 172 | @chmod("$root/$writable", 0777); 173 | } 174 | } 175 | 176 | function setExecutable($root, $paths) 177 | { 178 | foreach ($paths as $executable) { 179 | echo " chmod 0755 $executable\n"; 180 | @chmod("$root/$executable", 0755); 181 | } 182 | } 183 | 184 | function setCookieValidationKey($root, $paths) 185 | { 186 | foreach ($paths as $file) { 187 | echo " generate cookie validation key in $file\n"; 188 | $file = $root . '/' . $file; 189 | $length = 32; 190 | $bytes = mcrypt_create_iv($length, MCRYPT_DEV_URANDOM); 191 | $key = strtr(substr(base64_encode($bytes), 0, $length), '+/=', '_-.'); 192 | $content = preg_replace('/(("|\')cookieValidationKey("|\')\s*=>\s*)(""|\'\')/', "\\1'$key'", file_get_contents($file)); 193 | file_put_contents($file, $content); 194 | } 195 | } 196 | -------------------------------------------------------------------------------- /init.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | rem ------------------------------------------------------------- 4 | rem Yii command line init script for Windows. 5 | rem 6 | rem @author Qiang Xue 7 | rem @link http://www.yiiframework.com/ 8 | rem @copyright Copyright © 2012 Yii Software LLC 9 | rem @license http://www.yiiframework.com/license/ 10 | rem ------------------------------------------------------------- 11 | 12 | @setlocal 13 | 14 | set YII_PATH=%~dp0 15 | 16 | if "%PHP_COMMAND%" == "" set PHP_COMMAND=php.exe 17 | 18 | "%PHP_COMMAND%" "%YII_PATH%init" %* 19 | 20 | @endlocal 21 | -------------------------------------------------------------------------------- /requirements.php: -------------------------------------------------------------------------------- 1 | Error'; 18 | echo '

The path to yii framework seems to be incorrect.

'; 19 | echo '

You need to install Yii framework via composer or adjust the framework path in file ' . basename(__FILE__) . '.

'; 20 | echo '

Please refer to the README on how to install Yii.

'; 21 | } 22 | 23 | require_once($frameworkPath . '/requirements/YiiRequirementChecker.php'); 24 | $requirementsChecker = new YiiRequirementChecker(); 25 | 26 | /** 27 | * Adjust requirements according to your application specifics. 28 | */ 29 | $requirements = array( 30 | // Database : 31 | array( 32 | 'name' => 'PDO extension', 33 | 'mandatory' => true, 34 | 'condition' => extension_loaded('pdo'), 35 | 'by' => 'All DB-related classes', 36 | ), 37 | array( 38 | 'name' => 'PDO SQLite extension', 39 | 'mandatory' => false, 40 | 'condition' => extension_loaded('pdo_sqlite'), 41 | 'by' => 'All DB-related classes', 42 | 'memo' => 'Required for SQLite database.', 43 | ), 44 | array( 45 | 'name' => 'PDO MySQL extension', 46 | 'mandatory' => false, 47 | 'condition' => extension_loaded('pdo_mysql'), 48 | 'by' => 'All DB-related classes', 49 | 'memo' => 'Required for MySQL database.', 50 | ), 51 | array( 52 | 'name' => 'PDO PostgreSQL extension', 53 | 'mandatory' => false, 54 | 'condition' => extension_loaded('pdo_pgsql'), 55 | 'by' => 'All DB-related classes', 56 | 'memo' => 'Required for PostgreSQL database.', 57 | ), 58 | // Cache : 59 | array( 60 | 'name' => 'Memcache extension', 61 | 'mandatory' => false, 62 | 'condition' => extension_loaded('memcache') || extension_loaded('memcached'), 63 | 'by' => 'MemCache', 64 | 'memo' => extension_loaded('memcached') ? 'To use memcached set MemCache::useMemcached to true.' : '' 65 | ), 66 | array( 67 | 'name' => 'APC extension', 68 | 'mandatory' => false, 69 | 'condition' => extension_loaded('apc'), 70 | 'by' => 'ApcCache', 71 | ), 72 | // PHP ini : 73 | 'phpSafeMode' => array( 74 | 'name' => 'PHP safe mode', 75 | 'mandatory' => false, 76 | 'condition' => $requirementsChecker->checkPhpIniOff("safe_mode"), 77 | 'by' => 'File uploading and console command execution', 78 | 'memo' => '"safe_mode" should be disabled at php.ini', 79 | ), 80 | 'phpExposePhp' => array( 81 | 'name' => 'Expose PHP', 82 | 'mandatory' => false, 83 | 'condition' => $requirementsChecker->checkPhpIniOff("expose_php"), 84 | 'by' => 'Security reasons', 85 | 'memo' => '"expose_php" should be disabled at php.ini', 86 | ), 87 | 'phpAllowUrlInclude' => array( 88 | 'name' => 'PHP allow url include', 89 | 'mandatory' => false, 90 | 'condition' => $requirementsChecker->checkPhpIniOff("allow_url_include"), 91 | 'by' => 'Security reasons', 92 | 'memo' => '"allow_url_include" should be disabled at php.ini', 93 | ), 94 | 'phpSmtp' => array( 95 | 'name' => 'PHP mail SMTP', 96 | 'mandatory' => false, 97 | 'condition' => strlen(ini_get('SMTP')) > 0, 98 | 'by' => 'Email sending', 99 | 'memo' => 'PHP mail SMTP server required', 100 | ), 101 | ); 102 | $requirementsChecker->checkYii()->check($requirements)->render(); -------------------------------------------------------------------------------- /statics/temp/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore -------------------------------------------------------------------------------- /statics/web/.htaccess: -------------------------------------------------------------------------------- 1 | # Mod_Rewrite 2 | 3 | # If a directory or a file exists, use the request directly 4 | RewriteCond %{REQUEST_FILENAME} !-f 5 | RewriteCond %{REQUEST_FILENAME} !-d 6 | # Otherwise forward the request to frontend/web/index.php 7 | RewriteRule ^(.*)$ /frontend/web/index.php 8 | -------------------------------------------------------------------------------- /statics/web/blogs/images/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore -------------------------------------------------------------------------------- /statics/web/blogs/previews/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore -------------------------------------------------------------------------------- /statics/web/users/avatars/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore -------------------------------------------------------------------------------- /yii.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | rem ------------------------------------------------------------- 4 | rem Yii command line bootstrap script for Windows. 5 | rem 6 | rem @author Qiang Xue 7 | rem @link http://www.yiiframework.com/ 8 | rem @copyright Copyright © 2012 Yii Software LLC 9 | rem @license http://www.yiiframework.com/license/ 10 | rem ------------------------------------------------------------- 11 | 12 | @setlocal 13 | 14 | set YII_PATH=%~dp0 15 | 16 | if "%PHP_COMMAND%" == "" set PHP_COMMAND=php.exe 17 | 18 | "%PHP_COMMAND%" "%YII_PATH%yii" %* 19 | 20 | @endlocal 21 | --------------------------------------------------------------------------------