├── .bowerrc ├── .gitignore ├── README.md ├── common ├── config │ ├── .gitignore │ ├── bootstrap.php │ ├── main.php │ └── params.php └── mail │ ├── layouts │ ├── html.php │ └── text.php │ ├── passwordResetToken-html.php │ └── passwordResetToken-text.php ├── composer.json ├── composer.lock ├── console ├── config │ ├── .gitignore │ ├── bootstrap.php │ ├── main.php │ └── params.php ├── controllers │ └── .gitkeep ├── migrations │ └── m130524_201442_init.php ├── models │ └── .gitkeep └── runtime │ └── .gitignore ├── environments ├── dev │ ├── backend │ │ ├── config │ │ │ ├── main-local.php │ │ │ └── params-local.php │ │ └── web │ │ │ ├── index-test.php │ │ │ └── index.php │ ├── common │ │ └── config │ │ │ ├── main-local.php │ │ │ └── params-local.php │ ├── console │ │ └── config │ │ │ ├── main-local.php │ │ │ └── params-local.php │ ├── frontend │ │ ├── config │ │ │ ├── main-local.php │ │ │ └── params-local.php │ │ └── web │ │ │ ├── index-test.php │ │ │ └── index.php │ ├── tests │ │ └── codeception │ │ │ └── config │ │ │ └── config-local.php │ └── yii ├── index.php └── prod │ ├── backend │ ├── config │ │ ├── main-local.php │ │ └── params-local.php │ └── web │ │ └── index.php │ ├── common │ └── config │ │ ├── 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 │ ├── tests │ └── codeception │ │ └── config │ │ └── config-local.php │ └── yii ├── frontend ├── assets │ └── AppAsset.php ├── config │ ├── .gitignore │ ├── bootstrap.php │ ├── main.php │ └── params.php ├── controllers │ └── SiteController.php ├── runtime │ └── .gitignore ├── v1 │ ├── V1.php │ ├── controllers │ │ └── TestController.php │ ├── logics │ │ └── Response.php │ └── views │ │ └── default │ │ └── index.php ├── views │ └── site │ │ └── index.php └── web │ ├── .bowerrc │ ├── .gitignore │ ├── app.js │ ├── app.vue │ ├── assets │ └── .gitignore │ ├── bower.json │ ├── favicon.ico │ ├── index.template.php │ ├── package.json │ ├── robots.txt │ ├── src │ ├── components │ │ ├── bar.vue │ │ └── card.vue │ └── views │ │ └── home.vue │ ├── webpack.config.js │ └── webpack.dev.config.js ├── init ├── init.bat ├── requirements.php ├── tests ├── README.md ├── codeception.yml └── codeception │ ├── _output │ └── .gitignore │ ├── backend │ ├── .gitignore │ ├── _bootstrap.php │ ├── _output │ │ └── .gitignore │ ├── acceptance.suite.yml │ ├── acceptance │ │ ├── LoginCept.php │ │ └── _bootstrap.php │ ├── codeception.yml │ ├── functional.suite.yml │ ├── functional │ │ ├── LoginCept.php │ │ └── _bootstrap.php │ ├── unit.suite.yml │ └── unit │ │ ├── DbTestCase.php │ │ ├── TestCase.php │ │ ├── _bootstrap.php │ │ └── fixtures │ │ └── data │ │ └── .gitkeep │ ├── bin │ ├── _bootstrap.php │ ├── yii │ └── yii.bat │ ├── common │ ├── .gitignore │ ├── _bootstrap.php │ ├── _output │ │ └── .gitignore │ ├── _pages │ │ └── LoginPage.php │ ├── _support │ │ └── FixtureHelper.php │ ├── codeception.yml │ ├── fixtures │ │ ├── UserFixture.php │ │ └── data │ │ │ └── init_login.php │ ├── templates │ │ └── fixtures │ │ │ └── user.php │ ├── unit.suite.yml │ └── unit │ │ ├── DbTestCase.php │ │ ├── TestCase.php │ │ ├── _bootstrap.php │ │ ├── fixtures │ │ └── data │ │ │ └── models │ │ │ └── user.php │ │ └── models │ │ └── LoginFormTest.php │ ├── config │ ├── .gitignore │ ├── acceptance.php │ ├── backend │ │ ├── acceptance.php │ │ ├── config.php │ │ ├── functional.php │ │ └── unit.php │ ├── common │ │ └── unit.php │ ├── config.php │ ├── console │ │ └── unit.php │ ├── frontend │ │ ├── acceptance.php │ │ ├── config.php │ │ ├── functional.php │ │ └── unit.php │ ├── functional.php │ └── unit.php │ ├── console │ ├── .gitignore │ ├── _bootstrap.php │ ├── _output │ │ └── .gitignore │ ├── codeception.yml │ ├── unit.suite.yml │ └── unit │ │ ├── DbTestCase.php │ │ ├── TestCase.php │ │ ├── _bootstrap.php │ │ └── fixtures │ │ └── data │ │ └── .gitkeep │ └── frontend │ ├── .gitignore │ ├── _bootstrap.php │ ├── _output │ └── .gitignore │ ├── _pages │ ├── AboutPage.php │ ├── ContactPage.php │ └── SignupPage.php │ ├── acceptance.suite.yml │ ├── acceptance │ ├── AboutCept.php │ ├── ContactCept.php │ ├── HomeCept.php │ ├── LoginCept.php │ ├── SignupCest.php │ └── _bootstrap.php │ ├── codeception.yml │ ├── functional.suite.yml │ ├── functional │ ├── AboutCept.php │ ├── ContactCept.php │ ├── HomeCept.php │ ├── LoginCept.php │ ├── SignupCest.php │ └── _bootstrap.php │ ├── unit.suite.yml │ └── unit │ ├── DbTestCase.php │ ├── TestCase.php │ ├── _bootstrap.php │ ├── fixtures │ └── data │ │ └── models │ │ └── user.php │ └── models │ ├── ContactFormTest.php │ ├── PasswordResetRequestFormTest.php │ ├── ResetPasswordFormTest.php │ └── SignupFormTest.php └── yii.bat /.bowerrc: -------------------------------------------------------------------------------- 1 | { 2 | "directory" : "vendor/bower" 3 | } 4 | -------------------------------------------------------------------------------- /.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 | 24 | # Mac DS_Store Files 25 | .DS_Store 26 | 27 | # phpunit itself is not needed 28 | phpunit.phar 29 | # local phpunit config 30 | /phpunit.xml 31 | 32 | # vagrant runtime 33 | /.vagrant 34 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Vuejs In Yii2 Template 2 | =============================== 3 | 4 | HOW TO USE 5 | ------------------- 6 | - step1: composer install 7 | - step2: php init 8 | - step3: cd /frontend/web 9 | - step4: npm install 10 | - step5: bower install 11 | - step6: npm run test(or build) 12 | - step7: open website '' 13 | 14 | DIRECTORY STRUCTURE 15 | ------------------- 16 | 17 | ``` 18 | common 19 | config/ contains shared configurations 20 | mail/ contains view files for e-mails 21 | models/ contains model classes used in both backend and frontend 22 | console 23 | config/ contains console configurations 24 | controllers/ contains console controllers (commands) 25 | migrations/ contains database migrations 26 | models/ contains console-specific model classes 27 | runtime/ contains files generated during runtime 28 | backend 29 | assets/ contains application assets such as JavaScript and CSS 30 | config/ contains backend configurations 31 | controllers/ contains Web controller classes 32 | models/ contains backend-specific model classes 33 | runtime/ contains files generated during runtime 34 | views/ contains view files for the Web application 35 | web/ contains the entry script and Web resources 36 | frontend 37 | assets/ contains application assets such as JavaScript and CSS 38 | config/ contains frontend configurations 39 | controllers/ contains Web controller classes 40 | models/ contains frontend-specific model classes 41 | runtime/ contains files generated during runtime 42 | views/ contains view files for the Web application 43 | web/ contains the entry script and Web resources 44 | widgets/ contains frontend widgets 45 | vendor/ contains dependent 3rd-party packages 46 | environments/ contains environment-based overrides 47 | tests contains various tests for the advanced application 48 | codeception/ contains tests developed with Codeception PHP Testing Framework 49 | ``` 50 | -------------------------------------------------------------------------------- /common/config/.gitignore: -------------------------------------------------------------------------------- 1 | main-local.php 2 | params-local.php 3 | -------------------------------------------------------------------------------- /common/config/bootstrap.php: -------------------------------------------------------------------------------- 1 | dirname(dirname(__DIR__)) . '/vendor', 4 | 'components' => [ 5 | 'cache' => [ 6 | 'class' => 'yii\caching\FileCache', 7 | ], 8 | ], 9 | ]; 10 | -------------------------------------------------------------------------------- /common/config/params.php: -------------------------------------------------------------------------------- 1 | 'admin@example.com', 4 | 'supportEmail' => 'support@example.com', 5 | 'user.passwordResetTokenExpire' => 3600, 6 | ]; 7 | -------------------------------------------------------------------------------- /common/mail/layouts/html.php: -------------------------------------------------------------------------------- 1 | 8 | beginPage() ?> 9 | 10 | 11 | 12 | 13 | <?= Html::encode($this->title) ?> 14 | head() ?> 15 | 16 | 17 | beginBody() ?> 18 | 19 | endBody() ?> 20 | 21 | 22 | endPage() ?> 23 | -------------------------------------------------------------------------------- /common/mail/layouts/text.php: -------------------------------------------------------------------------------- 1 | 8 | beginPage() ?> 9 | beginBody() ?> 10 | 11 | endBody() ?> 12 | endPage() ?> 13 | -------------------------------------------------------------------------------- /common/mail/passwordResetToken-html.php: -------------------------------------------------------------------------------- 1 | urlManager->createAbsoluteUrl(['site/reset-password', 'token' => $user->password_reset_token]); 8 | ?> 9 |
10 |

Hello username) ?>,

11 | 12 |

Follow the link below to reset your password:

13 | 14 |

15 |
16 | -------------------------------------------------------------------------------- /common/mail/passwordResetToken-text.php: -------------------------------------------------------------------------------- 1 | urlManager->createAbsoluteUrl(['site/reset-password', 'token' => $user->password_reset_token]); 7 | ?> 8 | Hello username ?>, 9 | 10 | Follow the link below to reset your password: 11 | 12 | 13 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "yiisoft/yii2-app-advanced", 3 | "description": "Yii 2 Advanced Project Template", 4 | "keywords": ["yii2", "framework", "advanced", "project template"], 5 | "homepage": "http://www.yiiframework.com/", 6 | "type": "project", 7 | "license": "BSD-3-Clause", 8 | "support": { 9 | "issues": "https://github.com/yiisoft/yii2/issues?state=open", 10 | "forum": "http://www.yiiframework.com/forum/", 11 | "wiki": "http://www.yiiframework.com/wiki/", 12 | "irc": "irc://irc.freenode.net/yii", 13 | "source": "https://github.com/yiisoft/yii2" 14 | }, 15 | "minimum-stability": "stable", 16 | "require": { 17 | "php": ">=5.4.0", 18 | "yiisoft/yii2": ">=2.0.6", 19 | "yiisoft/yii2-bootstrap": "*", 20 | "yiisoft/yii2-swiftmailer": "*" 21 | }, 22 | "require-dev": { 23 | "yiisoft/yii2-codeception": "*", 24 | "yiisoft/yii2-debug": "*", 25 | "yiisoft/yii2-gii": "*", 26 | "yiisoft/yii2-faker": "*" 27 | }, 28 | "config": { 29 | "process-timeout": 1800 30 | }, 31 | "extra": { 32 | "asset-installer-paths": { 33 | "npm-asset-library": "vendor/npm", 34 | "bower-asset-library": "vendor/bower" 35 | } 36 | }, 37 | "scripts": { 38 | "post-install-cmd": "php init --env=Development --overwrite=n" 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /composer.lock: -------------------------------------------------------------------------------- 1 | { 2 | "_readme": [ 3 | "This file locks the dependencies of your project to a known state", 4 | "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", 5 | "This file is @generated automatically" 6 | ], 7 | "hash": "914f9194a4d021de88b285b03e683984", 8 | "content-hash": "e1929a97e872bdbaacc8530468eccb67", 9 | "packages": [ 10 | { 11 | "name": "bower-asset/bootstrap", 12 | "version": "v3.3.5", 13 | "source": { 14 | "type": "git", 15 | "url": "https://github.com/twbs/bootstrap.git", 16 | "reference": "16b48259a62f576e52c903c476bd42b90ab22482" 17 | }, 18 | "dist": { 19 | "type": "zip", 20 | "url": "https://api.github.com/repos/twbs/bootstrap/zipball/16b48259a62f576e52c903c476bd42b90ab22482", 21 | "reference": "16b48259a62f576e52c903c476bd42b90ab22482", 22 | "shasum": "" 23 | }, 24 | "require": { 25 | "bower-asset/jquery": ">=1.9.1" 26 | }, 27 | "type": "bower-asset-library", 28 | "extra": { 29 | "bower-asset-main": [ 30 | "less/bootstrap.less", 31 | "dist/js/bootstrap.js" 32 | ], 33 | "bower-asset-ignore": [ 34 | "/.*", 35 | "_config.yml", 36 | "CNAME", 37 | "composer.json", 38 | "CONTRIBUTING.md", 39 | "docs", 40 | "js/tests", 41 | "test-infra" 42 | ] 43 | }, 44 | "license": [ 45 | "MIT" 46 | ], 47 | "description": "The most popular front-end framework for developing responsive, mobile first projects on the web.", 48 | "keywords": [ 49 | "css", 50 | "framework", 51 | "front-end", 52 | "js", 53 | "less", 54 | "mobile-first", 55 | "responsive", 56 | "web" 57 | ] 58 | }, 59 | { 60 | "name": "bower-asset/jquery", 61 | "version": "2.2.4", 62 | "source": { 63 | "type": "git", 64 | "url": "https://github.com/jquery/jquery-dist.git", 65 | "reference": "c0185ab7c75aab88762c5aae780b9d83b80eda72" 66 | }, 67 | "dist": { 68 | "type": "zip", 69 | "url": "https://api.github.com/repos/jquery/jquery-dist/zipball/c0185ab7c75aab88762c5aae780b9d83b80eda72", 70 | "reference": "c0185ab7c75aab88762c5aae780b9d83b80eda72", 71 | "shasum": "" 72 | }, 73 | "type": "bower-asset-library", 74 | "extra": { 75 | "bower-asset-main": "dist/jquery.js", 76 | "bower-asset-ignore": [ 77 | "package.json" 78 | ] 79 | }, 80 | "license": [ 81 | "MIT" 82 | ], 83 | "keywords": [ 84 | "browser", 85 | "javascript", 86 | "jquery", 87 | "library" 88 | ] 89 | }, 90 | { 91 | "name": "bower-asset/jquery.inputmask", 92 | "version": "3.2.7", 93 | "source": { 94 | "type": "git", 95 | "url": "https://github.com/RobinHerbots/jquery.inputmask.git", 96 | "reference": "5a72c563b502b8e05958a524cdfffafe9987be38" 97 | }, 98 | "dist": { 99 | "type": "zip", 100 | "url": "https://api.github.com/repos/RobinHerbots/jquery.inputmask/zipball/5a72c563b502b8e05958a524cdfffafe9987be38", 101 | "reference": "5a72c563b502b8e05958a524cdfffafe9987be38", 102 | "shasum": "" 103 | }, 104 | "require": { 105 | "bower-asset/jquery": ">=1.7" 106 | }, 107 | "type": "bower-asset-library", 108 | "extra": { 109 | "bower-asset-main": [ 110 | "./dist/inputmask/inputmask.js" 111 | ], 112 | "bower-asset-ignore": [ 113 | "**/*", 114 | "!dist/*", 115 | "!dist/inputmask/*", 116 | "!dist/min/*", 117 | "!dist/min/inputmask/*", 118 | "!extra/bindings/*", 119 | "!extra/dependencyLibs/*", 120 | "!extra/phone-codes/*" 121 | ] 122 | }, 123 | "license": [ 124 | "http://opensource.org/licenses/mit-license.php" 125 | ], 126 | "description": "jquery.inputmask is a jquery plugin which create an input mask.", 127 | "keywords": [ 128 | "form", 129 | "input", 130 | "inputmask", 131 | "jquery", 132 | "mask", 133 | "plugins" 134 | ] 135 | }, 136 | { 137 | "name": "bower-asset/punycode", 138 | "version": "v1.3.2", 139 | "source": { 140 | "type": "git", 141 | "url": "https://github.com/bestiejs/punycode.js.git", 142 | "reference": "38c8d3131a82567bfef18da09f7f4db68c84f8a3" 143 | }, 144 | "dist": { 145 | "type": "zip", 146 | "url": "https://api.github.com/repos/bestiejs/punycode.js/zipball/38c8d3131a82567bfef18da09f7f4db68c84f8a3", 147 | "reference": "38c8d3131a82567bfef18da09f7f4db68c84f8a3", 148 | "shasum": "" 149 | }, 150 | "type": "bower-asset-library", 151 | "extra": { 152 | "bower-asset-main": "punycode.js", 153 | "bower-asset-ignore": [ 154 | "coverage", 155 | "tests", 156 | ".*", 157 | "component.json", 158 | "Gruntfile.js", 159 | "node_modules", 160 | "package.json" 161 | ] 162 | } 163 | }, 164 | { 165 | "name": "bower-asset/yii2-pjax", 166 | "version": "v2.0.6", 167 | "source": { 168 | "type": "git", 169 | "url": "https://github.com/yiisoft/jquery-pjax.git", 170 | "reference": "60728da6ade5879e807a49ce59ef9a72039b8978" 171 | }, 172 | "dist": { 173 | "type": "zip", 174 | "url": "https://api.github.com/repos/yiisoft/jquery-pjax/zipball/60728da6ade5879e807a49ce59ef9a72039b8978", 175 | "reference": "60728da6ade5879e807a49ce59ef9a72039b8978", 176 | "shasum": "" 177 | }, 178 | "require": { 179 | "bower-asset/jquery": ">=1.8" 180 | }, 181 | "type": "bower-asset-library", 182 | "extra": { 183 | "bower-asset-main": "./jquery.pjax.js", 184 | "bower-asset-ignore": [ 185 | ".travis.yml", 186 | "Gemfile", 187 | "Gemfile.lock", 188 | "CONTRIBUTING.md", 189 | "vendor/", 190 | "script/", 191 | "test/" 192 | ] 193 | }, 194 | "license": [ 195 | "MIT" 196 | ] 197 | }, 198 | { 199 | "name": "cebe/markdown", 200 | "version": "1.1.0", 201 | "source": { 202 | "type": "git", 203 | "url": "https://github.com/cebe/markdown.git", 204 | "reference": "54a2c49de31cc44e864ebf0500a35ef21d0010b2" 205 | }, 206 | "dist": { 207 | "type": "zip", 208 | "url": "https://packagist.phpcomposer.com/files/cebe/markdown/54a2c49de31cc44e864ebf0500a35ef21d0010b2.zip", 209 | "reference": "54a2c49de31cc44e864ebf0500a35ef21d0010b2", 210 | "shasum": "" 211 | }, 212 | "require": { 213 | "lib-pcre": "*", 214 | "php": ">=5.4.0" 215 | }, 216 | "require-dev": { 217 | "cebe/indent": "*", 218 | "facebook/xhprof": "*@dev", 219 | "phpunit/phpunit": "4.1.*" 220 | }, 221 | "bin": [ 222 | "bin/markdown" 223 | ], 224 | "type": "library", 225 | "extra": { 226 | "branch-alias": { 227 | "dev-master": "1.1.x-dev" 228 | } 229 | }, 230 | "autoload": { 231 | "psr-4": { 232 | "cebe\\markdown\\": "" 233 | } 234 | }, 235 | "notification-url": "https://packagist.org/downloads/", 236 | "license": [ 237 | "MIT" 238 | ], 239 | "authors": [ 240 | { 241 | "name": "Carsten Brandt", 242 | "email": "mail@cebe.cc", 243 | "homepage": "http://cebe.cc/", 244 | "role": "Creator" 245 | } 246 | ], 247 | "description": "A super fast, highly extensible markdown parser for PHP", 248 | "homepage": "https://github.com/cebe/markdown#readme", 249 | "keywords": [ 250 | "extensible", 251 | "fast", 252 | "gfm", 253 | "markdown", 254 | "markdown-extra" 255 | ], 256 | "time": "2015-03-06 05:28:07" 257 | }, 258 | { 259 | "name": "ezyang/htmlpurifier", 260 | "version": "v4.7.0", 261 | "source": { 262 | "type": "git", 263 | "url": "https://github.com/ezyang/htmlpurifier.git", 264 | "reference": "ae1828d955112356f7677c465f94f7deb7d27a40" 265 | }, 266 | "dist": { 267 | "type": "zip", 268 | "url": "https://packagist.phpcomposer.com/files/ezyang/htmlpurifier/ae1828d955112356f7677c465f94f7deb7d27a40.zip", 269 | "reference": "ae1828d955112356f7677c465f94f7deb7d27a40", 270 | "shasum": "" 271 | }, 272 | "require": { 273 | "php": ">=5.2" 274 | }, 275 | "type": "library", 276 | "autoload": { 277 | "psr-0": { 278 | "HTMLPurifier": "library/" 279 | }, 280 | "files": [ 281 | "library/HTMLPurifier.composer.php" 282 | ] 283 | }, 284 | "notification-url": "https://packagist.org/downloads/", 285 | "license": [ 286 | "LGPL" 287 | ], 288 | "authors": [ 289 | { 290 | "name": "Edward Z. Yang", 291 | "email": "admin@htmlpurifier.org", 292 | "homepage": "http://ezyang.com" 293 | } 294 | ], 295 | "description": "Standards compliant HTML filter written in PHP", 296 | "homepage": "http://htmlpurifier.org/", 297 | "keywords": [ 298 | "html" 299 | ], 300 | "time": "2015-08-05 01:03:42" 301 | }, 302 | { 303 | "name": "swiftmailer/swiftmailer", 304 | "version": "v5.4.2", 305 | "source": { 306 | "type": "git", 307 | "url": "https://github.com/swiftmailer/swiftmailer.git", 308 | "reference": "d8db871a54619458a805229a057ea2af33c753e8" 309 | }, 310 | "dist": { 311 | "type": "zip", 312 | "url": "https://packagist.phpcomposer.com/files/swiftmailer/swiftmailer/d8db871a54619458a805229a057ea2af33c753e8.zip", 313 | "reference": "d8db871a54619458a805229a057ea2af33c753e8", 314 | "shasum": "" 315 | }, 316 | "require": { 317 | "php": ">=5.3.3" 318 | }, 319 | "require-dev": { 320 | "mockery/mockery": "~0.9.1,<0.9.4" 321 | }, 322 | "type": "library", 323 | "extra": { 324 | "branch-alias": { 325 | "dev-master": "5.4-dev" 326 | } 327 | }, 328 | "autoload": { 329 | "files": [ 330 | "lib/swift_required.php" 331 | ] 332 | }, 333 | "notification-url": "https://packagist.org/downloads/", 334 | "license": [ 335 | "MIT" 336 | ], 337 | "authors": [ 338 | { 339 | "name": "Chris Corbyn" 340 | }, 341 | { 342 | "name": "Fabien Potencier", 343 | "email": "fabien@symfony.com" 344 | } 345 | ], 346 | "description": "Swiftmailer, free feature-rich PHP mailer", 347 | "homepage": "http://swiftmailer.org", 348 | "keywords": [ 349 | "email", 350 | "mail", 351 | "mailer" 352 | ], 353 | "time": "2016-05-01 08:45:47" 354 | }, 355 | { 356 | "name": "yiisoft/yii2", 357 | "version": "2.0.8", 358 | "source": { 359 | "type": "git", 360 | "url": "https://github.com/yiisoft/yii2-framework.git", 361 | "reference": "53992b136b993e32ca7b6f399cf42b143f8685a6" 362 | }, 363 | "dist": { 364 | "type": "zip", 365 | "url": "https://packagist.phpcomposer.com/files/yiisoft/yii2-framework/53992b136b993e32ca7b6f399cf42b143f8685a6.zip", 366 | "reference": "53992b136b993e32ca7b6f399cf42b143f8685a6", 367 | "shasum": "" 368 | }, 369 | "require": { 370 | "bower-asset/jquery": "2.2.*@stable | 2.1.*@stable | 1.11.*@stable", 371 | "bower-asset/jquery.inputmask": "~3.2.2", 372 | "bower-asset/punycode": "1.3.*", 373 | "bower-asset/yii2-pjax": "~2.0.1", 374 | "cebe/markdown": "~1.0.0 | ~1.1.0", 375 | "ext-ctype": "*", 376 | "ext-mbstring": "*", 377 | "ezyang/htmlpurifier": "~4.6", 378 | "lib-pcre": "*", 379 | "php": ">=5.4.0", 380 | "yiisoft/yii2-composer": "~2.0.4" 381 | }, 382 | "bin": [ 383 | "yii" 384 | ], 385 | "type": "library", 386 | "extra": { 387 | "branch-alias": { 388 | "dev-master": "2.0.x-dev" 389 | } 390 | }, 391 | "autoload": { 392 | "psr-4": { 393 | "yii\\": "" 394 | } 395 | }, 396 | "notification-url": "https://packagist.org/downloads/", 397 | "license": [ 398 | "BSD-3-Clause" 399 | ], 400 | "authors": [ 401 | { 402 | "name": "Qiang Xue", 403 | "email": "qiang.xue@gmail.com", 404 | "homepage": "http://www.yiiframework.com/", 405 | "role": "Founder and project lead" 406 | }, 407 | { 408 | "name": "Alexander Makarov", 409 | "email": "sam@rmcreative.ru", 410 | "homepage": "http://rmcreative.ru/", 411 | "role": "Core framework development" 412 | }, 413 | { 414 | "name": "Maurizio Domba", 415 | "homepage": "http://mdomba.info/", 416 | "role": "Core framework development" 417 | }, 418 | { 419 | "name": "Carsten Brandt", 420 | "email": "mail@cebe.cc", 421 | "homepage": "http://cebe.cc/", 422 | "role": "Core framework development" 423 | }, 424 | { 425 | "name": "Timur Ruziev", 426 | "email": "resurtm@gmail.com", 427 | "homepage": "http://resurtm.com/", 428 | "role": "Core framework development" 429 | }, 430 | { 431 | "name": "Paul Klimov", 432 | "email": "klimov.paul@gmail.com", 433 | "role": "Core framework development" 434 | }, 435 | { 436 | "name": "Dmitry Naumenko", 437 | "email": "d.naumenko.a@gmail.com", 438 | "role": "Core framework development" 439 | } 440 | ], 441 | "description": "Yii PHP Framework Version 2", 442 | "homepage": "http://www.yiiframework.com/", 443 | "keywords": [ 444 | "framework", 445 | "yii2" 446 | ], 447 | "time": "2016-04-28 14:50:20" 448 | }, 449 | { 450 | "name": "yiisoft/yii2-bootstrap", 451 | "version": "2.0.6", 452 | "source": { 453 | "type": "git", 454 | "url": "https://github.com/yiisoft/yii2-bootstrap.git", 455 | "reference": "3fd2b8c950cce79d60e9702d6bcb24eb3c80f6c5" 456 | }, 457 | "dist": { 458 | "type": "zip", 459 | "url": "https://packagist.phpcomposer.com/files/yiisoft/yii2-bootstrap/3fd2b8c950cce79d60e9702d6bcb24eb3c80f6c5.zip", 460 | "reference": "3fd2b8c950cce79d60e9702d6bcb24eb3c80f6c5", 461 | "shasum": "" 462 | }, 463 | "require": { 464 | "bower-asset/bootstrap": "3.3.* | 3.2.* | 3.1.*", 465 | "yiisoft/yii2": ">=2.0.6" 466 | }, 467 | "type": "yii2-extension", 468 | "extra": { 469 | "branch-alias": { 470 | "dev-master": "2.0.x-dev" 471 | }, 472 | "asset-installer-paths": { 473 | "npm-asset-library": "vendor/npm", 474 | "bower-asset-library": "vendor/bower" 475 | } 476 | }, 477 | "autoload": { 478 | "psr-4": { 479 | "yii\\bootstrap\\": "" 480 | } 481 | }, 482 | "notification-url": "https://packagist.org/downloads/", 483 | "license": [ 484 | "BSD-3-Clause" 485 | ], 486 | "authors": [ 487 | { 488 | "name": "Qiang Xue", 489 | "email": "qiang.xue@gmail.com" 490 | } 491 | ], 492 | "description": "The Twitter Bootstrap extension for the Yii framework", 493 | "keywords": [ 494 | "bootstrap", 495 | "yii2" 496 | ], 497 | "time": "2016-03-17 03:29:28" 498 | }, 499 | { 500 | "name": "yiisoft/yii2-composer", 501 | "version": "2.0.4", 502 | "source": { 503 | "type": "git", 504 | "url": "https://github.com/yiisoft/yii2-composer.git", 505 | "reference": "7452fd908a5023b8bb5ea1b123a174ca080de464" 506 | }, 507 | "dist": { 508 | "type": "zip", 509 | "url": "https://packagist.phpcomposer.com/files/yiisoft/yii2-composer/7452fd908a5023b8bb5ea1b123a174ca080de464.zip", 510 | "reference": "7452fd908a5023b8bb5ea1b123a174ca080de464", 511 | "shasum": "" 512 | }, 513 | "require": { 514 | "composer-plugin-api": "^1.0" 515 | }, 516 | "type": "composer-plugin", 517 | "extra": { 518 | "class": "yii\\composer\\Plugin", 519 | "branch-alias": { 520 | "dev-master": "2.0.x-dev" 521 | } 522 | }, 523 | "autoload": { 524 | "psr-4": { 525 | "yii\\composer\\": "" 526 | } 527 | }, 528 | "notification-url": "https://packagist.org/downloads/", 529 | "license": [ 530 | "BSD-3-Clause" 531 | ], 532 | "authors": [ 533 | { 534 | "name": "Qiang Xue", 535 | "email": "qiang.xue@gmail.com" 536 | } 537 | ], 538 | "description": "The composer plugin for Yii extension installer", 539 | "keywords": [ 540 | "composer", 541 | "extension installer", 542 | "yii2" 543 | ], 544 | "time": "2016-02-06 00:49:24" 545 | }, 546 | { 547 | "name": "yiisoft/yii2-swiftmailer", 548 | "version": "2.0.5", 549 | "source": { 550 | "type": "git", 551 | "url": "https://github.com/yiisoft/yii2-swiftmailer.git", 552 | "reference": "e2c6315caff30a9271a7afad4d684627721dc69a" 553 | }, 554 | "dist": { 555 | "type": "zip", 556 | "url": "https://packagist.phpcomposer.com/files/yiisoft/yii2-swiftmailer/e2c6315caff30a9271a7afad4d684627721dc69a.zip", 557 | "reference": "e2c6315caff30a9271a7afad4d684627721dc69a", 558 | "shasum": "" 559 | }, 560 | "require": { 561 | "swiftmailer/swiftmailer": "~5.0", 562 | "yiisoft/yii2": ">=2.0.4" 563 | }, 564 | "type": "yii2-extension", 565 | "extra": { 566 | "branch-alias": { 567 | "dev-master": "2.0.x-dev" 568 | } 569 | }, 570 | "autoload": { 571 | "psr-4": { 572 | "yii\\swiftmailer\\": "" 573 | } 574 | }, 575 | "notification-url": "https://packagist.org/downloads/", 576 | "license": [ 577 | "BSD-3-Clause" 578 | ], 579 | "authors": [ 580 | { 581 | "name": "Paul Klimov", 582 | "email": "klimov.paul@gmail.com" 583 | } 584 | ], 585 | "description": "The SwiftMailer integration for the Yii framework", 586 | "keywords": [ 587 | "email", 588 | "mail", 589 | "mailer", 590 | "swift", 591 | "swiftmailer", 592 | "yii2" 593 | ], 594 | "time": "2016-03-17 03:58:49" 595 | } 596 | ], 597 | "packages-dev": [ 598 | { 599 | "name": "bower-asset/typeahead.js", 600 | "version": "v0.11.1", 601 | "source": { 602 | "type": "git", 603 | "url": "https://github.com/twitter/typeahead.js.git", 604 | "reference": "588440f66559714280628a4f9799f0c4eb880a4a" 605 | }, 606 | "dist": { 607 | "type": "zip", 608 | "url": "https://api.github.com/repos/twitter/typeahead.js/zipball/588440f66559714280628a4f9799f0c4eb880a4a", 609 | "reference": "588440f66559714280628a4f9799f0c4eb880a4a", 610 | "shasum": "" 611 | }, 612 | "require": { 613 | "bower-asset/jquery": ">=1.7" 614 | }, 615 | "require-dev": { 616 | "bower-asset/jasmine-ajax": "~1.3.1", 617 | "bower-asset/jasmine-jquery": "~1.5.2", 618 | "bower-asset/jquery": "~1.7" 619 | }, 620 | "type": "bower-asset-library", 621 | "extra": { 622 | "bower-asset-main": "dist/typeahead.bundle.js" 623 | } 624 | }, 625 | { 626 | "name": "fzaninotto/faker", 627 | "version": "v1.6.0", 628 | "source": { 629 | "type": "git", 630 | "url": "https://github.com/fzaninotto/Faker.git", 631 | "reference": "44f9a286a04b80c76a4e5fb7aad8bb539b920123" 632 | }, 633 | "dist": { 634 | "type": "zip", 635 | "url": "https://packagist.phpcomposer.com/files/fzaninotto/Faker/44f9a286a04b80c76a4e5fb7aad8bb539b920123.zip", 636 | "reference": "44f9a286a04b80c76a4e5fb7aad8bb539b920123", 637 | "shasum": "" 638 | }, 639 | "require": { 640 | "php": "^5.3.3|^7.0" 641 | }, 642 | "require-dev": { 643 | "ext-intl": "*", 644 | "phpunit/phpunit": "~4.0", 645 | "squizlabs/php_codesniffer": "~1.5" 646 | }, 647 | "type": "library", 648 | "extra": { 649 | "branch-alias": [] 650 | }, 651 | "autoload": { 652 | "psr-4": { 653 | "Faker\\": "src/Faker/" 654 | } 655 | }, 656 | "notification-url": "https://packagist.org/downloads/", 657 | "license": [ 658 | "MIT" 659 | ], 660 | "authors": [ 661 | { 662 | "name": "François Zaninotto" 663 | } 664 | ], 665 | "description": "Faker is a PHP library that generates fake data for you.", 666 | "keywords": [ 667 | "data", 668 | "faker", 669 | "fixtures" 670 | ], 671 | "time": "2016-04-29 12:21:54" 672 | }, 673 | { 674 | "name": "phpspec/php-diff", 675 | "version": "v1.1.0", 676 | "source": { 677 | "type": "git", 678 | "url": "https://github.com/phpspec/php-diff.git", 679 | "reference": "0464787bfa7cd13576c5a1e318709768798bec6a" 680 | }, 681 | "dist": { 682 | "type": "zip", 683 | "url": "https://packagist.phpcomposer.com/files/phpspec/php-diff/0464787bfa7cd13576c5a1e318709768798bec6a.zip", 684 | "reference": "0464787bfa7cd13576c5a1e318709768798bec6a", 685 | "shasum": "" 686 | }, 687 | "type": "library", 688 | "extra": { 689 | "branch-alias": { 690 | "dev-master": "1.0.x-dev" 691 | } 692 | }, 693 | "autoload": { 694 | "psr-0": { 695 | "Diff": "lib/" 696 | } 697 | }, 698 | "notification-url": "https://packagist.org/downloads/", 699 | "license": [ 700 | "BSD-3-Clause" 701 | ], 702 | "authors": [ 703 | { 704 | "name": "Chris Boulton", 705 | "homepage": "http://github.com/chrisboulton" 706 | } 707 | ], 708 | "description": "A comprehensive library for generating differences between two hashable objects (strings or arrays).", 709 | "time": "2016-04-07 12:29:16" 710 | }, 711 | { 712 | "name": "yiisoft/yii2-codeception", 713 | "version": "2.0.5", 714 | "source": { 715 | "type": "git", 716 | "url": "https://github.com/yiisoft/yii2-codeception.git", 717 | "reference": "c916a36d09fc128b05a374e7922bc56854334d56" 718 | }, 719 | "dist": { 720 | "type": "zip", 721 | "url": "https://packagist.phpcomposer.com/files/yiisoft/yii2-codeception/c916a36d09fc128b05a374e7922bc56854334d56.zip", 722 | "reference": "c916a36d09fc128b05a374e7922bc56854334d56", 723 | "shasum": "" 724 | }, 725 | "require": { 726 | "yiisoft/yii2": ">=2.0.4" 727 | }, 728 | "type": "yii2-extension", 729 | "extra": { 730 | "branch-alias": { 731 | "dev-master": "2.0.x-dev" 732 | } 733 | }, 734 | "autoload": { 735 | "psr-4": { 736 | "yii\\codeception\\": "" 737 | } 738 | }, 739 | "notification-url": "https://packagist.org/downloads/", 740 | "license": [ 741 | "BSD-3-Clause" 742 | ], 743 | "authors": [ 744 | { 745 | "name": "Mark Jebri", 746 | "email": "mark.github@yandex.ru" 747 | } 748 | ], 749 | "description": "The Codeception integration for the Yii framework", 750 | "keywords": [ 751 | "codeception", 752 | "yii2" 753 | ], 754 | "time": "2016-03-17 03:41:26" 755 | }, 756 | { 757 | "name": "yiisoft/yii2-debug", 758 | "version": "2.0.6", 759 | "source": { 760 | "type": "git", 761 | "url": "https://github.com/yiisoft/yii2-debug.git", 762 | "reference": "55ed2e853ed8050a34415f63a4da84f88a56f895" 763 | }, 764 | "dist": { 765 | "type": "zip", 766 | "url": "https://packagist.phpcomposer.com/files/yiisoft/yii2-debug/55ed2e853ed8050a34415f63a4da84f88a56f895.zip", 767 | "reference": "55ed2e853ed8050a34415f63a4da84f88a56f895", 768 | "shasum": "" 769 | }, 770 | "require": { 771 | "yiisoft/yii2": ">=2.0.4", 772 | "yiisoft/yii2-bootstrap": "*" 773 | }, 774 | "type": "yii2-extension", 775 | "extra": { 776 | "branch-alias": { 777 | "dev-master": "2.0.x-dev" 778 | } 779 | }, 780 | "autoload": { 781 | "psr-4": { 782 | "yii\\debug\\": "" 783 | } 784 | }, 785 | "notification-url": "https://packagist.org/downloads/", 786 | "license": [ 787 | "BSD-3-Clause" 788 | ], 789 | "authors": [ 790 | { 791 | "name": "Qiang Xue", 792 | "email": "qiang.xue@gmail.com" 793 | } 794 | ], 795 | "description": "The debugger extension for the Yii framework", 796 | "keywords": [ 797 | "debug", 798 | "debugger", 799 | "yii2" 800 | ], 801 | "time": "2016-03-17 03:50:19" 802 | }, 803 | { 804 | "name": "yiisoft/yii2-faker", 805 | "version": "2.0.3", 806 | "source": { 807 | "type": "git", 808 | "url": "https://github.com/yiisoft/yii2-faker.git", 809 | "reference": "b88ca69ee226a3610b2c26c026c3203d7ac50f6c" 810 | }, 811 | "dist": { 812 | "type": "zip", 813 | "url": "https://packagist.phpcomposer.com/files/yiisoft/yii2-faker/b88ca69ee226a3610b2c26c026c3203d7ac50f6c.zip", 814 | "reference": "b88ca69ee226a3610b2c26c026c3203d7ac50f6c", 815 | "shasum": "" 816 | }, 817 | "require": { 818 | "fzaninotto/faker": "*", 819 | "yiisoft/yii2": "*" 820 | }, 821 | "type": "yii2-extension", 822 | "extra": { 823 | "branch-alias": { 824 | "dev-master": "2.0.x-dev" 825 | } 826 | }, 827 | "autoload": { 828 | "psr-4": { 829 | "yii\\faker\\": "" 830 | } 831 | }, 832 | "notification-url": "https://packagist.org/downloads/", 833 | "license": [ 834 | "BSD-3-Clause" 835 | ], 836 | "authors": [ 837 | { 838 | "name": "Mark Jebri", 839 | "email": "mark.github@yandex.ru" 840 | } 841 | ], 842 | "description": "Fixture generator. The Faker integration for the Yii framework.", 843 | "keywords": [ 844 | "Fixture", 845 | "faker", 846 | "yii2" 847 | ], 848 | "time": "2015-03-01 06:22:44" 849 | }, 850 | { 851 | "name": "yiisoft/yii2-gii", 852 | "version": "2.0.5", 853 | "source": { 854 | "type": "git", 855 | "url": "https://github.com/yiisoft/yii2-gii.git", 856 | "reference": "1bd6df6804ca077ec022587905a0d43eb286f507" 857 | }, 858 | "dist": { 859 | "type": "zip", 860 | "url": "https://packagist.phpcomposer.com/files/yiisoft/yii2-gii/1bd6df6804ca077ec022587905a0d43eb286f507.zip", 861 | "reference": "1bd6df6804ca077ec022587905a0d43eb286f507", 862 | "shasum": "" 863 | }, 864 | "require": { 865 | "bower-asset/typeahead.js": "0.10.* | ~0.11.0", 866 | "phpspec/php-diff": ">=1.0.2", 867 | "yiisoft/yii2": ">=2.0.4", 868 | "yiisoft/yii2-bootstrap": "~2.0" 869 | }, 870 | "type": "yii2-extension", 871 | "extra": { 872 | "branch-alias": { 873 | "dev-master": "2.0.x-dev" 874 | }, 875 | "asset-installer-paths": { 876 | "npm-asset-library": "vendor/npm", 877 | "bower-asset-library": "vendor/bower" 878 | } 879 | }, 880 | "autoload": { 881 | "psr-4": { 882 | "yii\\gii\\": "" 883 | } 884 | }, 885 | "notification-url": "https://packagist.org/downloads/", 886 | "license": [ 887 | "BSD-3-Clause" 888 | ], 889 | "authors": [ 890 | { 891 | "name": "Qiang Xue", 892 | "email": "qiang.xue@gmail.com" 893 | } 894 | ], 895 | "description": "The Gii extension for the Yii framework", 896 | "keywords": [ 897 | "code generator", 898 | "gii", 899 | "yii2" 900 | ], 901 | "time": "2016-03-18 14:09:46" 902 | } 903 | ], 904 | "aliases": [], 905 | "minimum-stability": "stable", 906 | "stability-flags": [], 907 | "prefer-stable": false, 908 | "prefer-lowest": false, 909 | "platform": { 910 | "php": ">=5.4.0" 911 | }, 912 | "platform-dev": [] 913 | } 914 | -------------------------------------------------------------------------------- /console/config/.gitignore: -------------------------------------------------------------------------------- 1 | main-local.php 2 | params-local.php -------------------------------------------------------------------------------- /console/config/bootstrap.php: -------------------------------------------------------------------------------- 1 | 'app-console', 11 | 'basePath' => dirname(__DIR__), 12 | 'bootstrap' => ['log'], 13 | 'controllerNamespace' => 'console\controllers', 14 | 'components' => [ 15 | 'log' => [ 16 | 'targets' => [ 17 | [ 18 | 'class' => 'yii\log\FileTarget', 19 | 'levels' => ['error', 'warning'], 20 | ], 21 | ], 22 | ], 23 | ], 24 | 'params' => $params, 25 | ]; 26 | -------------------------------------------------------------------------------- /console/config/params.php: -------------------------------------------------------------------------------- 1 | 'admin@example.com', 4 | ]; 5 | -------------------------------------------------------------------------------- /console/controllers/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TIGERB/vue-in-yii2/ac8bfdada22683c481e9cd96be79ef8d742c0f7c/console/controllers/.gitkeep -------------------------------------------------------------------------------- /console/migrations/m130524_201442_init.php: -------------------------------------------------------------------------------- 1 | db->driverName === 'mysql') { 11 | // http://stackoverflow.com/questions/766809/whats-the-difference-between-utf8-general-ci-and-utf8-unicode-ci 12 | $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB'; 13 | } 14 | 15 | $this->createTable('{{%user}}', [ 16 | 'id' => $this->primaryKey(), 17 | 'username' => $this->string()->notNull()->unique(), 18 | 'auth_key' => $this->string(32)->notNull(), 19 | 'password_hash' => $this->string()->notNull(), 20 | 'password_reset_token' => $this->string()->unique(), 21 | 'email' => $this->string()->notNull()->unique(), 22 | 23 | 'status' => $this->smallInteger()->notNull()->defaultValue(10), 24 | 'created_at' => $this->integer()->notNull(), 25 | 'updated_at' => $this->integer()->notNull(), 26 | ], $tableOptions); 27 | } 28 | 29 | public function down() 30 | { 31 | $this->dropTable('{{%user}}'); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /console/models/.gitkeep: -------------------------------------------------------------------------------- 1 | * 2 | -------------------------------------------------------------------------------- /console/runtime/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore -------------------------------------------------------------------------------- /environments/dev/backend/config/main-local.php: -------------------------------------------------------------------------------- 1 | [ 5 | 'request' => [ 6 | // !!! insert a secret key in the following (if it is empty) - this is required by cookie validation 7 | 'cookieValidationKey' => '', 8 | ], 9 | ], 10 | ]; 11 | 12 | if (!YII_ENV_TEST) { 13 | // configuration adjustments for 'dev' environment 14 | $config['bootstrap'][] = 'debug'; 15 | $config['modules']['debug'] = [ 16 | 'class' => 'yii\debug\Module', 17 | ]; 18 | 19 | $config['bootstrap'][] = 'gii'; 20 | $config['modules']['gii'] = [ 21 | 'class' => 'yii\gii\Module', 22 | 'allowedIPs' => ['127.0.0.1', '192.168.*.*'], // add gii allow ip 23 | ]; 24 | } 25 | 26 | return $config; 27 | -------------------------------------------------------------------------------- /environments/dev/backend/config/params-local.php: -------------------------------------------------------------------------------- 1 | run(); 20 | -------------------------------------------------------------------------------- /environments/dev/backend/web/index.php: -------------------------------------------------------------------------------- 1 | run(); 19 | -------------------------------------------------------------------------------- /environments/dev/common/config/main-local.php: -------------------------------------------------------------------------------- 1 | [ 4 | 'db' => [ 5 | 'class' => 'yii\db\Connection', 6 | 'dsn' => 'mysql:host=localhost;dbname=yii2advanced', 7 | 'username' => 'root', 8 | 'password' => '', 9 | 'charset' => 'utf8', 10 | ], 11 | 'mailer' => [ 12 | 'class' => 'yii\swiftmailer\Mailer', 13 | 'viewPath' => '@common/mail', 14 | // send all mails to a file by default. You have to set 15 | // 'useFileTransport' to false and configure a transport 16 | // for the mailer to send real emails. 17 | 'useFileTransport' => true, 18 | ], 19 | ], 20 | ]; 21 | -------------------------------------------------------------------------------- /environments/dev/common/config/params-local.php: -------------------------------------------------------------------------------- 1 | ['gii'], 4 | 'modules' => [ 5 | 'gii' => 'yii\gii\Module', 6 | ], 7 | ]; 8 | -------------------------------------------------------------------------------- /environments/dev/console/config/params-local.php: -------------------------------------------------------------------------------- 1 | [ 5 | 'request' => [ 6 | // !!! insert a secret key in the following (if it is empty) - this is required by cookie validation 7 | 'cookieValidationKey' => '', 8 | ], 9 | ], 10 | ]; 11 | 12 | if (!YII_ENV_TEST) { 13 | // configuration adjustments for 'dev' environment 14 | $config['bootstrap'][] = 'debug'; 15 | $config['modules']['debug'] = [ 16 | 'class' => 'yii\debug\Module', 17 | ]; 18 | $config['bootstrap'][] = 'gii'; 19 | $config['modules']['gii'] = [ 20 | 'class' => 'yii\gii\Module', 21 | ]; 22 | } 23 | 24 | return $config; 25 | -------------------------------------------------------------------------------- /environments/dev/frontend/config/params-local.php: -------------------------------------------------------------------------------- 1 | run(); 19 | -------------------------------------------------------------------------------- /environments/dev/frontend/web/index.php: -------------------------------------------------------------------------------- 1 | run(); 19 | -------------------------------------------------------------------------------- /environments/dev/tests/codeception/config/config-local.php: -------------------------------------------------------------------------------- 1 | [ 4 | 'db' => [ 5 | 'dsn' => 'mysql:host=localhost;dbname=yii2_advanced_tests', 6 | 'username' => 'root', 7 | 'password' => '', 8 | 'charset' => 'utf8', 9 | ], 10 | ], 11 | ]; 12 | -------------------------------------------------------------------------------- /environments/dev/yii: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env php 2 | run(); 28 | exit($exitCode); 29 | -------------------------------------------------------------------------------- /environments/index.php: -------------------------------------------------------------------------------- 1 | [ 11 | * 'path' => 'directory storing the local files', 12 | * 'skipFiles' => [ 13 | * // list of files that should only copied once and skipped if they already exist 14 | * ], 15 | * 'setWritable' => [ 16 | * // list of directories that should be set writable 17 | * ], 18 | * 'setExecutable' => [ 19 | * // list of files that should be set executable 20 | * ], 21 | * 'setCookieValidationKey' => [ 22 | * // list of config files that need to be inserted with automatically generated cookie validation keys 23 | * ], 24 | * 'createSymlink' => [ 25 | * // list of symlinks to be created. Keys are symlinks, and values are the targets. 26 | * ], 27 | * ], 28 | * ]; 29 | * ``` 30 | */ 31 | return [ 32 | 'Development' => [ 33 | 'path' => 'dev', 34 | 'setWritable' => [ 35 | 'frontend/runtime', 36 | 'frontend/web/assets', 37 | ], 38 | 'setExecutable' => [ 39 | 'yii', 40 | 'tests/codeception/bin/yii', 41 | ], 42 | 'setCookieValidationKey' => [ 43 | 'frontend/config/main-local.php', 44 | ], 45 | ], 46 | 'Production' => [ 47 | 'path' => 'prod', 48 | 'setWritable' => [ 49 | 'frontend/runtime', 50 | 'frontend/web/assets', 51 | ], 52 | 'setExecutable' => [ 53 | 'yii', 54 | ], 55 | 'setCookieValidationKey' => [ 56 | 'frontend/config/main-local.php', 57 | ], 58 | ], 59 | ]; 60 | -------------------------------------------------------------------------------- /environments/prod/backend/config/main-local.php: -------------------------------------------------------------------------------- 1 | [ 4 | 'request' => [ 5 | // !!! insert a secret key in the following (if it is empty) - this is required by cookie validation 6 | 'cookieValidationKey' => '', 7 | ], 8 | ], 9 | ]; 10 | -------------------------------------------------------------------------------- /environments/prod/backend/config/params-local.php: -------------------------------------------------------------------------------- 1 | run(); 19 | -------------------------------------------------------------------------------- /environments/prod/common/config/main-local.php: -------------------------------------------------------------------------------- 1 | [ 4 | 'db' => [ 5 | 'class' => 'yii\db\Connection', 6 | 'dsn' => 'mysql:host=localhost;dbname=yii2advanced', 7 | 'username' => 'root', 8 | 'password' => '', 9 | 'charset' => 'utf8', 10 | ], 11 | 'mailer' => [ 12 | 'class' => 'yii\swiftmailer\Mailer', 13 | 'viewPath' => '@common/mail', 14 | ], 15 | ], 16 | ]; 17 | -------------------------------------------------------------------------------- /environments/prod/common/config/params-local.php: -------------------------------------------------------------------------------- 1 | [ 4 | 'request' => [ 5 | // !!! insert a secret key in the following (if it is empty) - this is required by cookie validation 6 | 'cookieValidationKey' => '', 7 | ], 8 | ], 9 | ]; 10 | -------------------------------------------------------------------------------- /environments/prod/frontend/config/params-local.php: -------------------------------------------------------------------------------- 1 | run(); 19 | -------------------------------------------------------------------------------- /environments/prod/tests/codeception/config/config-local.php: -------------------------------------------------------------------------------- 1 | [ 4 | 'db' => [ 5 | 'dsn' => 'mysql:host=localhost;dbname=yii2_advanced_tests', 6 | 'username' => 'root', 7 | 'password' => '', 8 | 'charset' => 'utf8', 9 | ], 10 | ], 11 | ]; 12 | -------------------------------------------------------------------------------- /environments/prod/yii: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env php 2 | run(); 28 | exit($exitCode); 29 | -------------------------------------------------------------------------------- /frontend/assets/AppAsset.php: -------------------------------------------------------------------------------- 1 | 'app-frontend', 11 | 'basePath' => dirname(__DIR__), 12 | 'bootstrap' => ['log'], 13 | 'controllerNamespace' => 'frontend\controllers', 14 | 'components' => [ 15 | 'user' => [ 16 | 'identityClass' => 'common\models\User', 17 | 'enableAutoLogin' => true, 18 | ], 19 | 'log' => [ 20 | 'traceLevel' => YII_DEBUG ? 3 : 0, 21 | 'targets' => [ 22 | [ 23 | 'class' => 'yii\log\FileTarget', 24 | 'levels' => ['error', 'warning'], 25 | ], 26 | ], 27 | ], 28 | 'errorHandler' => [ 29 | 'errorAction' => 'site/error', 30 | ], 31 | 32 | 'urlManager' => [ 33 | 'enablePrettyUrl' => true, 34 | 'showScriptName' => false, 35 | 'rules' => [ 36 | ], 37 | ], 38 | 39 | ], 40 | // module 41 | 'modules' => [ 42 | 'v1' => [ 43 | 'class' => 'frontend\v1\V1', 44 | 'defaultRoute' => 'test/list', 45 | ], 46 | ], 47 | 'params' => $params, 48 | ]; 49 | -------------------------------------------------------------------------------- /frontend/config/params.php: -------------------------------------------------------------------------------- 1 | 'admin@example.com', 4 | ]; 5 | -------------------------------------------------------------------------------- /frontend/controllers/SiteController.php: -------------------------------------------------------------------------------- 1 | render('index'); 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /frontend/runtime/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore -------------------------------------------------------------------------------- /frontend/v1/V1.php: -------------------------------------------------------------------------------- 1 | 'yii\web\Response', 11 | 'format' => \yii\web\Response::FORMAT_JSON, 12 | 'data' => [ 13 | 'message' => $message, 14 | 'code' => $code, 15 | ], 16 | ]); 17 | } 18 | 19 | public static function successReturn($result=array()) 20 | { 21 | return \Yii::createObject([ 22 | 'class' => 'yii\web\Response', 23 | 'format' => \yii\web\Response::FORMAT_JSON, 24 | 'data' => [ 25 | 'result' => $result, 26 | 'message' => 'success', 27 | 'code' => 200, 28 | ], 29 | ]); 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /frontend/v1/views/default/index.php: -------------------------------------------------------------------------------- 1 |
2 |

context->action->uniqueId ?>

3 |

4 | This is the view content for action "context->action->id ?>". 5 | The action belongs to the controller "context) ?>" 6 | in the "context->module->id ?>" module. 7 |

8 |

9 | You may customize this page by editing the following file:
10 | 11 |

12 |
13 | -------------------------------------------------------------------------------- /frontend/views/site/index.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | -------------------------------------------------------------------------------- /frontend/web/.bowerrc: -------------------------------------------------------------------------------- 1 | { 2 | "directory":"bower_components" 3 | } 4 | -------------------------------------------------------------------------------- /frontend/web/.gitignore: -------------------------------------------------------------------------------- 1 | /index.php 2 | /index-test.php 3 | /dist 4 | /node_modules 5 | /bower_components -------------------------------------------------------------------------------- /frontend/web/app.js: -------------------------------------------------------------------------------- 1 | var Vue     = require('vue'); // get vue 2 | var VueRouter = require('vue-router'); //get vue-router 3 | var App     = require('./app.vue');// get root module 4 | 5 | Vue.use(VueRouter);//error: Please install the Router with Vue.use() before creating an instance 6 | var router = new VueRouter();//init 7 | var viewPath = './src/views/';//component src 8 | 9 | router.map({ 10 | '/':{ 11 | name:'', 12 | component:require(viewPath+'home.vue') 13 | }, 14 | '/login':{ 15 | name:'login', 16 | component:require(viewPath+'home.vue') 17 | } 18 | }); 19 | 20 | router.start(App,'#app'); 21 | 22 | 23 | -------------------------------------------------------------------------------- /frontend/web/app.vue: -------------------------------------------------------------------------------- 1 | 6 | 7 | 11 | 12 | 17 | 18 | -------------------------------------------------------------------------------- /frontend/web/assets/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /frontend/web/bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "easy-vue", 3 | "description": "Learn Vue Easy", 4 | "main": "index.html", 5 | "authors": [ 6 | "tigerb <624661874@qq.com>" 7 | ], 8 | "license": "ISC", 9 | "keywords": [ 10 | "vue" 11 | ], 12 | "homepage": "https://github.com/TIGERB/easy-vue", 13 | "moduleType": [], 14 | "ignore": [ 15 | "**/.*", 16 | "node_modules", 17 | "bower_components", 18 | "test", 19 | "tests" 20 | ], 21 | "dependencies": { 22 | "ratchet": "^2.0.2", 23 | "font-awesome": "^4.5.0", 24 | "fastclick": "^1.0.6" 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /frontend/web/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TIGERB/vue-in-yii2/ac8bfdada22683c481e9cd96be79ef8d742c0f7c/frontend/web/favicon.ico -------------------------------------------------------------------------------- /frontend/web/index.template.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | -------------------------------------------------------------------------------- /frontend/web/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "test", 3 | "version": "1.0.0", 4 | "description": "webpack", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "DOMAIN=http://localhost:666/ webpack -p && sudo php -S localhost:666", 8 | "build": "DOMAIN=http://localhost:666/ NODE_ENV=production webpack -p" 9 | }, 10 | "author": "", 11 | "license": "ISC", 12 | "devDependencies": { 13 | "babel-core": "^6.4.5", 14 | "babel-loader": "^6.2.1", 15 | "babel-plugin-transform-runtime": "^6.4.3", 16 | "babel-preset-es2015": "^6.3.13", 17 | "babel-runtime": "^5.8.35", 18 | "clean-webpack-plugin": "^0.1.9", 19 | "css-loader": "^0.23.1", 20 | "extract-text-webpack-plugin": "^1.0.1", 21 | "file-loader": "^0.8.5", 22 | "html-webpack-plugin": "^2.16.0", 23 | "json-loader": "^0.5.4", 24 | "style-loader": "^0.13.0", 25 | "vue-hot-reload-api": "^1.3.0", 26 | "vue-html-loader": "^1.1.0", 27 | "vue-loader": "^8.0.5", 28 | "vue-style-loader": "^1.0.0", 29 | "webpack": "^1.12.12", 30 | "webpack-dev-server": "^1.14.1" 31 | }, 32 | "dependencies": { 33 | "fetch": "^1.0.1", 34 | "vue": "^1.0.15", 35 | "vue-infinite-scroll": "^0.1.2", 36 | "vue-router": "^0.7.10", 37 | "whatwg-fetch": "^0.11.0" 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /frontend/web/robots.txt: -------------------------------------------------------------------------------- 1 | User-agent: * 2 | Disallow: -------------------------------------------------------------------------------- /frontend/web/src/components/bar.vue: -------------------------------------------------------------------------------- 1 | 7 | 8 | 17 | 18 | 21 | -------------------------------------------------------------------------------- /frontend/web/src/components/card.vue: -------------------------------------------------------------------------------- 1 | 6 | 7 | 45 | 46 | -------------------------------------------------------------------------------- /frontend/web/src/views/home.vue: -------------------------------------------------------------------------------- 1 | 7 | 8 | 19 | 20 | 23 | -------------------------------------------------------------------------------- /frontend/web/webpack.config.js: -------------------------------------------------------------------------------- 1 | var webpack = require('webpack'); 2 | var webpackDevServer = require('webpack-dev-server'); 3 | var HtmlWebpackPlugin = require('html-webpack-plugin'); 4 | var ExtractPlugin = require('extract-text-webpack-plugin');// separate css 5 | var CleanPlugin = require('clean-webpack-plugin');// clean bulid file 6 | 7 | var webpackConfig = module.exports = {};// init object 8 | var production = process.env.NODE_ENV === 'production';// production environment 9 | 10 | var domain = process.env.DOMAIN; // your domain process.env.domain 11 | 12 | // input 13 | webpackConfig.entry  = { 14 | app:[ 15 | // vender 16 | './bower_components/ratchet/dist/css/ratchet.css', 17 | './bower_components/font-awesome/css/font-awesome.css', 18 | 19 | // main 20 | './app.js', 21 | ], 22 | }; 23 | 24 | webpackConfig.output = { 25 | path: './dist', 26 | publicPath: domain+'dist/', 27 | filename: production? '[name].[hash].js': '[name].js' 28 | };// output 29 | 30 | //doc loader 31 | webpackConfig.module = { 32 | loaders : [ 33 | { 34 | test: /\.css$/, 35 | loader: ExtractPlugin.extract('style', 'css') 36 | }, 37 | { 38 | test: /\.vue$/, 39 | loader: 'vue' 40 | }, 41 | { 42 | test: /\.js$/, 43 | loader: 'babel', 44 | query: {compact: false} 45 | }, 46 | { 47 | test: /\.(eot(|\?v=.*)|woff(|\?v=.*)|woff2(|\?v=.*)|ttf(|\?v=.*)|svg(|\?v=.*))$/, 48 | loader: 'file' 49 | }, 50 | { 51 | test: /\.json/, 52 | loader: 'json' 53 | }, 54 | ] 55 | }; 56 | 57 | webpackConfig.plugins = [ 58 | // make index.html 59 | new HtmlWebpackPlugin({ 60 | title: 'easy-vue', 61 | filename: '../../views/site/index.php', 62 | template: './index.template.php' 63 | }), 64 | // separate css file 65 | new ExtractPlugin(production? 'app.[hash].css': 'app.css'), 66 | // cancel warn when use webpack -p 67 | new webpack.optimize.UglifyJsPlugin({ 68 | compress: { 69 | warnings: false 70 | } 71 | }), 72 | ]; 73 | 74 | /* production plugins need */ 75 | if (production) { 76 | webpackConfig.plugins.concat([ 77 | // clean build file 78 | new CleanPlugin('dist') 79 | ]); 80 | } 81 | -------------------------------------------------------------------------------- /frontend/web/webpack.dev.config.js: -------------------------------------------------------------------------------- 1 | var config = require("./webpack.config.js"); 2 | config.plugins = [new webpack.HotModuleReplacementPlugin()]; 3 | config.entry.app.unshift("webpack-dev-server/client?http://localhost:9999", "webpack/hot/dev-server"); 4 | var compiler = webpack(config); 5 | var server = new webpackDevServer(compiler, { 6 | hot: true 7 | }); 8 | server.listen(9999); 9 | -------------------------------------------------------------------------------- /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('openssl')) { 18 | die('The OpenSSL 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 | if (isset($env['skipFiles'])) { 69 | $skipFiles = $env['skipFiles']; 70 | array_walk($skipFiles, function(&$value) use($env, $root) { $value = "$root/$value"; }); 71 | $files = array_diff($files, array_intersect_key($env['skipFiles'], array_filter($skipFiles, 'file_exists'))); 72 | } 73 | $all = false; 74 | foreach ($files as $file) { 75 | if (!copyFile($root, "environments/{$env['path']}/$file", $file, $all, $params)) { 76 | break; 77 | } 78 | } 79 | 80 | $callbacks = ['setCookieValidationKey', 'setWritable', 'setExecutable', 'createSymlink']; 81 | foreach ($callbacks as $callback) { 82 | if (!empty($env[$callback])) { 83 | $callback($root, $env[$callback]); 84 | } 85 | } 86 | 87 | echo "\n ... initialization completed.\n\n"; 88 | 89 | function getFileList($root, $basePath = '') 90 | { 91 | $files = []; 92 | $handle = opendir($root); 93 | while (($path = readdir($handle)) !== false) { 94 | if ($path === '.git' || $path === '.svn' || $path === '.' || $path === '..') { 95 | continue; 96 | } 97 | $fullPath = "$root/$path"; 98 | $relativePath = $basePath === '' ? $path : "$basePath/$path"; 99 | if (is_dir($fullPath)) { 100 | $files = array_merge($files, getFileList($fullPath, $relativePath)); 101 | } else { 102 | $files[] = $relativePath; 103 | } 104 | } 105 | closedir($handle); 106 | return $files; 107 | } 108 | 109 | function copyFile($root, $source, $target, &$all, $params) 110 | { 111 | if (!is_file($root . '/' . $source)) { 112 | echo " skip $target ($source not exist)\n"; 113 | return true; 114 | } 115 | if (is_file($root . '/' . $target)) { 116 | if (file_get_contents($root . '/' . $source) === file_get_contents($root . '/' . $target)) { 117 | echo " unchanged $target\n"; 118 | return true; 119 | } 120 | if ($all) { 121 | echo " overwrite $target\n"; 122 | } else { 123 | echo " exist $target\n"; 124 | echo " ...overwrite? [Yes|No|All|Quit] "; 125 | 126 | 127 | $answer = !empty($params['overwrite']) ? $params['overwrite'] : trim(fgets(STDIN)); 128 | if (!strncasecmp($answer, 'q', 1)) { 129 | return false; 130 | } else { 131 | if (!strncasecmp($answer, 'y', 1)) { 132 | echo " overwrite $target\n"; 133 | } else { 134 | if (!strncasecmp($answer, 'a', 1)) { 135 | echo " overwrite $target\n"; 136 | $all = true; 137 | } else { 138 | echo " skip $target\n"; 139 | return true; 140 | } 141 | } 142 | } 143 | } 144 | file_put_contents($root . '/' . $target, file_get_contents($root . '/' . $source)); 145 | return true; 146 | } 147 | echo " generate $target\n"; 148 | @mkdir(dirname($root . '/' . $target), 0777, true); 149 | file_put_contents($root . '/' . $target, file_get_contents($root . '/' . $source)); 150 | return true; 151 | } 152 | 153 | function getParams() 154 | { 155 | $rawParams = []; 156 | if (isset($_SERVER['argv'])) { 157 | $rawParams = $_SERVER['argv']; 158 | array_shift($rawParams); 159 | } 160 | 161 | $params = []; 162 | foreach ($rawParams as $param) { 163 | if (preg_match('/^--(\w+)(=(.*))?$/', $param, $matches)) { 164 | $name = $matches[1]; 165 | $params[$name] = isset($matches[3]) ? $matches[3] : true; 166 | } else { 167 | $params[] = $param; 168 | } 169 | } 170 | return $params; 171 | } 172 | 173 | function setWritable($root, $paths) 174 | { 175 | foreach ($paths as $writable) { 176 | if (is_dir("$root/$writable")) { 177 | echo " chmod 0777 $writable\n"; 178 | @chmod("$root/$writable", 0777); 179 | } else { 180 | echo "\n Error. Directory $writable does not exist. \n"; 181 | } 182 | } 183 | } 184 | 185 | function setExecutable($root, $paths) 186 | { 187 | foreach ($paths as $executable) { 188 | echo " chmod 0755 $executable\n"; 189 | @chmod("$root/$executable", 0755); 190 | } 191 | } 192 | 193 | function setCookieValidationKey($root, $paths) 194 | { 195 | foreach ($paths as $file) { 196 | echo " generate cookie validation key in $file\n"; 197 | $file = $root . '/' . $file; 198 | $length = 32; 199 | $bytes = openssl_random_pseudo_bytes($length); 200 | $key = strtr(substr(base64_encode($bytes), 0, $length), '+/=', '_-.'); 201 | $content = preg_replace('/(("|\')cookieValidationKey("|\')\s*=>\s*)(""|\'\')/', "\\1'$key'", file_get_contents($file)); 202 | file_put_contents($file, $content); 203 | } 204 | } 205 | 206 | function createSymlink($root, $links) { 207 | foreach ($links as $link => $target) { 208 | echo " symlink " . $root . "/" . $target . " " . $root . "/" . $link . "\n"; 209 | //first removing folders to avoid errors if the folder already exists 210 | @rmdir($root . "/" . $link); 211 | //next removing existing symlink in order to update the target 212 | if (is_link($root . "/" . $link)) { 213 | @unlink($root . "/" . $link); 214 | } 215 | @symlink($root . "/" . $target, $root . "/" . $link); 216 | } 217 | } 218 | -------------------------------------------------------------------------------- /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 (c) 2008 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 | $gdMemo = $imagickMemo = 'Either GD PHP extension with FreeType support or ImageMagick PHP extension with PNG support is required for image CAPTCHA.'; 27 | $gdOK = $imagickOK = false; 28 | 29 | if (extension_loaded('imagick')) { 30 | $imagick = new Imagick(); 31 | $imagickFormats = $imagick->queryFormats('PNG'); 32 | if (in_array('PNG', $imagickFormats)) { 33 | $imagickOK = true; 34 | } else { 35 | $imagickMemo = 'Imagick extension should be installed with PNG support in order to be used for image CAPTCHA.'; 36 | } 37 | } 38 | 39 | if (extension_loaded('gd')) { 40 | $gdInfo = gd_info(); 41 | if (!empty($gdInfo['FreeType Support'])) { 42 | $gdOK = true; 43 | } else { 44 | $gdMemo = 'GD extension should be installed with FreeType support in order to be used for image CAPTCHA.'; 45 | } 46 | } 47 | 48 | /** 49 | * Adjust requirements according to your application specifics. 50 | */ 51 | $requirements = array( 52 | // Database : 53 | array( 54 | 'name' => 'PDO extension', 55 | 'mandatory' => true, 56 | 'condition' => extension_loaded('pdo'), 57 | 'by' => 'All DB-related classes', 58 | ), 59 | array( 60 | 'name' => 'PDO SQLite extension', 61 | 'mandatory' => false, 62 | 'condition' => extension_loaded('pdo_sqlite'), 63 | 'by' => 'All DB-related classes', 64 | 'memo' => 'Required for SQLite database.', 65 | ), 66 | array( 67 | 'name' => 'PDO MySQL extension', 68 | 'mandatory' => false, 69 | 'condition' => extension_loaded('pdo_mysql'), 70 | 'by' => 'All DB-related classes', 71 | 'memo' => 'Required for MySQL database.', 72 | ), 73 | array( 74 | 'name' => 'PDO PostgreSQL extension', 75 | 'mandatory' => false, 76 | 'condition' => extension_loaded('pdo_pgsql'), 77 | 'by' => 'All DB-related classes', 78 | 'memo' => 'Required for PostgreSQL database.', 79 | ), 80 | // Cache : 81 | array( 82 | 'name' => 'Memcache extension', 83 | 'mandatory' => false, 84 | 'condition' => extension_loaded('memcache') || extension_loaded('memcached'), 85 | 'by' => 'MemCache', 86 | 'memo' => extension_loaded('memcached') ? 'To use memcached set MemCache::useMemcached to true.' : '' 87 | ), 88 | array( 89 | 'name' => 'APC extension', 90 | 'mandatory' => false, 91 | 'condition' => extension_loaded('apc'), 92 | 'by' => 'ApcCache', 93 | ), 94 | // CAPTCHA: 95 | array( 96 | 'name' => 'GD PHP extension with FreeType support', 97 | 'mandatory' => false, 98 | 'condition' => $gdOK, 99 | 'by' => 'Captcha', 100 | 'memo' => $gdMemo, 101 | ), 102 | array( 103 | 'name' => 'ImageMagick PHP extension with PNG support', 104 | 'mandatory' => false, 105 | 'condition' => $imagickOK, 106 | 'by' => 'Captcha', 107 | 'memo' => $imagickMemo, 108 | ), 109 | // PHP ini : 110 | 'phpExposePhp' => array( 111 | 'name' => 'Expose PHP', 112 | 'mandatory' => false, 113 | 'condition' => $requirementsChecker->checkPhpIniOff("expose_php"), 114 | 'by' => 'Security reasons', 115 | 'memo' => '"expose_php" should be disabled at php.ini', 116 | ), 117 | 'phpAllowUrlInclude' => array( 118 | 'name' => 'PHP allow url include', 119 | 'mandatory' => false, 120 | 'condition' => $requirementsChecker->checkPhpIniOff("allow_url_include"), 121 | 'by' => 'Security reasons', 122 | 'memo' => '"allow_url_include" should be disabled at php.ini', 123 | ), 124 | 'phpSmtp' => array( 125 | 'name' => 'PHP mail SMTP', 126 | 'mandatory' => false, 127 | 'condition' => strlen(ini_get('SMTP')) > 0, 128 | 'by' => 'Email sending', 129 | 'memo' => 'PHP mail SMTP server required', 130 | ), 131 | ); 132 | $requirementsChecker->checkYii()->check($requirements)->render(); 133 | -------------------------------------------------------------------------------- /tests/README.md: -------------------------------------------------------------------------------- 1 | This directory contains various tests for the advanced applications. 2 | 3 | Tests in `codeception` directory are developed with [Codeception PHP Testing Framework](http://codeception.com/). 4 | 5 | After creating and setting up the advanced application, follow these steps to prepare for the tests: 6 | 7 | 1. Install Codeception if it's not yet installed: 8 | 9 | ``` 10 | composer global require "codeception/codeception=2.1.*" "codeception/specify=*" "codeception/verify=*" 11 | ``` 12 | 13 | If you've never used Composer for global packages run `composer global status`. It should output: 14 | 15 | ``` 16 | Changed current directory to 17 | ``` 18 | 19 | Then add `/vendor/bin` to you `PATH` environment variable. Now you're able to use `codecept` from command 20 | line globally. 21 | 22 | 2. Install faker extension by running the following from template root directory where `composer.json` is: 23 | 24 | ``` 25 | composer require --dev yiisoft/yii2-faker:* 26 | ``` 27 | 28 | 3. Create a database for tests, adjust the `components['db']` configuration in `tests/codeception/config/config-local.php`, 29 | then update it by applying migrations: 30 | 31 | ``` 32 | codeception/bin/yii migrate 33 | ``` 34 | 35 | 4. In order to be able to run acceptance tests you need to start a webserver. The simplest way is to use PHP built in 36 | webserver. In the root directory where `common`, `frontend` etc. are execute the following: 37 | 38 | ``` 39 | php -S localhost:8080 40 | ``` 41 | 42 | 5. Now you can run the tests with the following commands, assuming you are in the `tests/codeception` directory: 43 | 44 | ``` 45 | # frontend tests 46 | cd frontend 47 | codecept build 48 | codecept run 49 | 50 | # backend tests 51 | 52 | cd backend 53 | codecept build 54 | codecept run 55 | 56 | # etc. 57 | ``` 58 | 59 | If you already have run `codecept build` for each application, you can skip that step and run all tests by a single `codecept run`. 60 | -------------------------------------------------------------------------------- /tests/codeception.yml: -------------------------------------------------------------------------------- 1 | include: 2 | - codeception/common 3 | - codeception/console 4 | - codeception/backend 5 | - codeception/frontend 6 | 7 | paths: 8 | log: codeception/_output 9 | 10 | settings: 11 | colors: true 12 | -------------------------------------------------------------------------------- /tests/codeception/_output/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /tests/codeception/backend/.gitignore: -------------------------------------------------------------------------------- 1 | # these files are auto generated by codeception build 2 | /unit/UnitTester.php 3 | /functional/FunctionalTester.php 4 | /acceptance/AcceptanceTester.php 5 | -------------------------------------------------------------------------------- /tests/codeception/backend/_bootstrap.php: -------------------------------------------------------------------------------- 1 | wantTo('ensure login page works'); 10 | 11 | $loginPage = LoginPage::openBy($I); 12 | 13 | $I->amGoingTo('submit login form with no data'); 14 | $loginPage->login('', ''); 15 | if (method_exists($I, 'wait')) { 16 | $I->wait(3); // only for selenium 17 | } 18 | $I->expectTo('see validations errors'); 19 | $I->see('Username cannot be blank.', '.help-block'); 20 | $I->see('Password cannot be blank.', '.help-block'); 21 | 22 | $I->amGoingTo('try to login with wrong credentials'); 23 | $I->expectTo('see validations errors'); 24 | $loginPage->login('admin', 'wrong'); 25 | if (method_exists($I, 'wait')) { 26 | $I->wait(3); // only for selenium 27 | } 28 | $I->expectTo('see validations errors'); 29 | $I->see('Incorrect username or password.', '.help-block'); 30 | 31 | $I->amGoingTo('try to login with correct credentials'); 32 | $loginPage->login('erau', 'password_0'); 33 | if (method_exists($I, 'wait')) { 34 | $I->wait(3); // only for selenium 35 | } 36 | $I->expectTo('see that user is logged'); 37 | $I->see('Logout (erau)', 'form button[type=submit]'); 38 | $I->dontSeeLink('Login'); 39 | $I->dontSeeLink('Signup'); 40 | /** Uncomment if using WebDriver 41 | * $I->click('Logout (erau)'); 42 | * $I->dontSeeLink('Logout (erau)'); 43 | * $I->seeLink('Login'); 44 | */ 45 | -------------------------------------------------------------------------------- /tests/codeception/backend/acceptance/_bootstrap.php: -------------------------------------------------------------------------------- 1 | wantTo('ensure login page works'); 10 | 11 | $loginPage = LoginPage::openBy($I); 12 | 13 | $I->amGoingTo('submit login form with no data'); 14 | $loginPage->login('', ''); 15 | $I->expectTo('see validations errors'); 16 | $I->see('Username cannot be blank.', '.help-block'); 17 | $I->see('Password cannot be blank.', '.help-block'); 18 | 19 | $I->amGoingTo('try to login with wrong credentials'); 20 | $I->expectTo('see validations errors'); 21 | $loginPage->login('admin', 'wrong'); 22 | $I->expectTo('see validations errors'); 23 | $I->see('Incorrect username or password.', '.help-block'); 24 | 25 | $I->amGoingTo('try to login with correct credentials'); 26 | $loginPage->login('erau', 'password_0'); 27 | $I->expectTo('see that user is logged'); 28 | $I->see('Logout (erau)', 'form button[type=submit]'); 29 | $I->dontSeeLink('Login'); 30 | $I->dontSeeLink('Signup'); 31 | -------------------------------------------------------------------------------- /tests/codeception/backend/functional/_bootstrap.php: -------------------------------------------------------------------------------- 1 | run(); 24 | exit($exitCode); 25 | -------------------------------------------------------------------------------- /tests/codeception/bin/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 (c) 2008 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 | -------------------------------------------------------------------------------- /tests/codeception/common/.gitignore: -------------------------------------------------------------------------------- 1 | # these files are auto generated by codeception build 2 | /unit/UnitTester.php 3 | /functional/FunctionalTester.php 4 | /acceptance/AcceptanceTester.php 5 | -------------------------------------------------------------------------------- /tests/codeception/common/_bootstrap.php: -------------------------------------------------------------------------------- 1 | actor->fillField('input[name="LoginForm[username]"]', $username); 22 | $this->actor->fillField('input[name="LoginForm[password]"]', $password); 23 | $this->actor->click('login-button'); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /tests/codeception/common/_support/FixtureHelper.php: -------------------------------------------------------------------------------- 1 | loadFixtures(); 41 | } 42 | 43 | /** 44 | * Method is called after all suite tests run 45 | */ 46 | public function _afterSuite() 47 | { 48 | $this->unloadFixtures(); 49 | } 50 | 51 | /** 52 | * @inheritdoc 53 | */ 54 | public function globalFixtures() 55 | { 56 | return [ 57 | InitDbFixture::className(), 58 | ]; 59 | } 60 | 61 | /** 62 | * @inheritdoc 63 | */ 64 | public function fixtures() 65 | { 66 | return [ 67 | 'user' => [ 68 | 'class' => UserFixture::className(), 69 | 'dataFile' => '@tests/codeception/common/fixtures/data/init_login.php', 70 | ], 71 | ]; 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /tests/codeception/common/codeception.yml: -------------------------------------------------------------------------------- 1 | namespace: tests\codeception\common 2 | actor: Tester 3 | paths: 4 | tests: . 5 | log: _output 6 | data: _data 7 | helpers: _support 8 | settings: 9 | bootstrap: _bootstrap.php 10 | suite_class: \PHPUnit_Framework_TestSuite 11 | colors: true 12 | memory_limit: 1024M 13 | log: true 14 | -------------------------------------------------------------------------------- /tests/codeception/common/fixtures/UserFixture.php: -------------------------------------------------------------------------------- 1 | 'erau', 6 | 'auth_key' => 'tUu1qHcde0diwUol3xeI-18MuHkkprQI', 7 | // password_0 8 | 'password_hash' => '$2y$13$nJ1WDlBaGcbCdbNC5.5l4.sgy.OMEKCqtDQOdQ2OWpgiKRWYyzzne', 9 | 'password_reset_token' => 'RkD_Jw0_8HEedzLk7MM-ZKEFfYR7VbMr_1392559490', 10 | 'created_at' => '1392559490', 11 | 'updated_at' => '1392559490', 12 | 'email' => 'sfriesen@jenkins.info', 13 | ], 14 | ]; 15 | -------------------------------------------------------------------------------- /tests/codeception/common/templates/fixtures/user.php: -------------------------------------------------------------------------------- 1 | getSecurity(); 8 | 9 | return [ 10 | 'username' => $faker->userName, 11 | 'email' => $faker->email, 12 | 'auth_key' => $security->generateRandomString(), 13 | 'password_hash' => $security->generatePasswordHash('password_' . $index), 14 | 'password_reset_token' => $security->generateRandomString() . '_' . time(), 15 | 'created_at' => time(), 16 | 'updated_at' => time(), 17 | ]; 18 | -------------------------------------------------------------------------------- /tests/codeception/common/unit.suite.yml: -------------------------------------------------------------------------------- 1 | # Codeception Test Suite Configuration 2 | 3 | # suite for unit (internal) tests. 4 | # RUN `build` COMMAND AFTER ADDING/REMOVING MODULES. 5 | 6 | class_name: UnitTester 7 | -------------------------------------------------------------------------------- /tests/codeception/common/unit/DbTestCase.php: -------------------------------------------------------------------------------- 1 | 'bayer.hudson', 6 | 'auth_key' => 'HP187Mvq7Mmm3CTU80dLkGmni_FUH_lR', 7 | //password_0 8 | 'password_hash' => '$2y$13$EjaPFBnZOQsHdGuHI.xvhuDp1fHpo8hKRSk6yshqa9c5EG8s3C3lO', 9 | 'password_reset_token' => 'ExzkCOaYc1L8IOBs4wdTGGbgNiG3Wz1I_1402312317', 10 | 'created_at' => '1402312317', 11 | 'updated_at' => '1402312317', 12 | 'email' => 'nicole.paucek@schultz.info', 13 | ], 14 | ]; 15 | -------------------------------------------------------------------------------- /tests/codeception/common/unit/models/LoginFormTest.php: -------------------------------------------------------------------------------- 1 | [ 25 | 'user' => [ 26 | 'class' => 'yii\web\User', 27 | 'identityClass' => 'common\models\User', 28 | ], 29 | ], 30 | ]); 31 | } 32 | 33 | protected function tearDown() 34 | { 35 | Yii::$app->user->logout(); 36 | parent::tearDown(); 37 | } 38 | 39 | public function testLoginNoUser() 40 | { 41 | $model = new LoginForm([ 42 | 'username' => 'not_existing_username', 43 | 'password' => 'not_existing_password', 44 | ]); 45 | 46 | $this->specify('user should not be able to login, when there is no identity', function () use ($model) { 47 | expect('model should not login user', $model->login())->false(); 48 | expect('user should not be logged in', Yii::$app->user->isGuest)->true(); 49 | }); 50 | } 51 | 52 | public function testLoginWrongPassword() 53 | { 54 | $model = new LoginForm([ 55 | 'username' => 'bayer.hudson', 56 | 'password' => 'wrong_password', 57 | ]); 58 | 59 | $this->specify('user should not be able to login with wrong password', function () use ($model) { 60 | expect('model should not login user', $model->login())->false(); 61 | expect('error message should be set', $model->errors)->hasKey('password'); 62 | expect('user should not be logged in', Yii::$app->user->isGuest)->true(); 63 | }); 64 | } 65 | 66 | public function testLoginCorrect() 67 | { 68 | 69 | $model = new LoginForm([ 70 | 'username' => 'bayer.hudson', 71 | 'password' => 'password_0', 72 | ]); 73 | 74 | $this->specify('user should be able to login with correct credentials', function () use ($model) { 75 | expect('model should login user', $model->login())->true(); 76 | expect('error message should not be set', $model->errors)->hasntKey('password'); 77 | expect('user should be logged in', Yii::$app->user->isGuest)->false(); 78 | }); 79 | } 80 | 81 | /** 82 | * @inheritdoc 83 | */ 84 | public function fixtures() 85 | { 86 | return [ 87 | 'user' => [ 88 | 'class' => UserFixture::className(), 89 | 'dataFile' => '@tests/codeception/common/unit/fixtures/data/models/user.php' 90 | ], 91 | ]; 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /tests/codeception/config/.gitignore: -------------------------------------------------------------------------------- 1 | config-local.php 2 | -------------------------------------------------------------------------------- /tests/codeception/config/acceptance.php: -------------------------------------------------------------------------------- 1 | 'app-common', 13 | 'basePath' => dirname(__DIR__), 14 | ] 15 | ); 16 | -------------------------------------------------------------------------------- /tests/codeception/config/config.php: -------------------------------------------------------------------------------- 1 | 'en-US', 7 | 'controllerMap' => [ 8 | 'fixture' => [ 9 | 'class' => 'yii\faker\FixtureController', 10 | 'fixtureDataPath' => '@tests/codeception/common/fixtures/data', 11 | 'templatePath' => '@tests/codeception/common/templates/fixtures', 12 | 'namespace' => 'tests\codeception\common\fixtures', 13 | ], 14 | ], 15 | 'components' => [ 16 | 'db' => [ 17 | 'dsn' => 'mysql:host=localhost;dbname=yii2_advanced_tests', 18 | ], 19 | 'mailer' => [ 20 | 'useFileTransport' => true, 21 | ], 22 | 'urlManager' => [ 23 | 'showScriptName' => true, 24 | ], 25 | ], 26 | ]; 27 | -------------------------------------------------------------------------------- /tests/codeception/config/console/unit.php: -------------------------------------------------------------------------------- 1 | [ 7 | 'request' => [ 8 | // it's not recommended to run functional tests with CSRF validation enabled 9 | 'enableCsrfValidation' => false, 10 | // but if you absolutely need it set cookie domain to localhost 11 | /* 12 | 'csrfCookie' => [ 13 | 'domain' => 'localhost', 14 | ], 15 | */ 16 | ], 17 | ], 18 | ]; -------------------------------------------------------------------------------- /tests/codeception/config/unit.php: -------------------------------------------------------------------------------- 1 | $value) { 21 | $inputType = $field === 'body' ? 'textarea' : 'input'; 22 | $this->actor->fillField($inputType . '[name="ContactForm[' . $field . ']"]', $value); 23 | } 24 | $this->actor->click('contact-button'); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /tests/codeception/frontend/_pages/SignupPage.php: -------------------------------------------------------------------------------- 1 | $value) { 22 | $inputType = $field === 'body' ? 'textarea' : 'input'; 23 | $this->actor->fillField($inputType . '[name="SignupForm[' . $field . ']"]', $value); 24 | } 25 | $this->actor->click('signup-button'); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /tests/codeception/frontend/acceptance.suite.yml: -------------------------------------------------------------------------------- 1 | # Codeception Test Suite Configuration 2 | 3 | # suite for acceptance tests. 4 | # perform tests in browser using the Selenium-like tools. 5 | # powered by Mink (http://mink.behat.org). 6 | # (tip: that's what your customer will see). 7 | # (tip: test your ajax and javascript by one of Mink drivers). 8 | 9 | # RUN `build` COMMAND AFTER ADDING/REMOVING MODULES. 10 | 11 | class_name: AcceptanceTester 12 | modules: 13 | enabled: 14 | - PhpBrowser 15 | - tests\codeception\common\_support\FixtureHelper 16 | # you can use WebDriver instead of PhpBrowser to test javascript and ajax. 17 | # This will require you to install selenium. See http://codeception.com/docs/04-AcceptanceTests#Selenium 18 | # "restart" option is used by the WebDriver to start each time per test-file new session and cookies, 19 | # it is useful if you want to login in your app in each test. 20 | # - WebDriver 21 | config: 22 | PhpBrowser: 23 | # PLEASE ADJUST IT TO THE ACTUAL ENTRY POINT WITHOUT PATH INFO 24 | url: http://localhost:8080 25 | # WebDriver: 26 | # url: http://localhost:8080 27 | # browser: firefox 28 | # restart: true 29 | -------------------------------------------------------------------------------- /tests/codeception/frontend/acceptance/AboutCept.php: -------------------------------------------------------------------------------- 1 | wantTo('ensure that about works'); 9 | AboutPage::openBy($I); 10 | $I->see('About', 'h1'); 11 | -------------------------------------------------------------------------------- /tests/codeception/frontend/acceptance/ContactCept.php: -------------------------------------------------------------------------------- 1 | wantTo('ensure that contact works'); 9 | 10 | $contactPage = ContactPage::openBy($I); 11 | 12 | $I->see('Contact', 'h1'); 13 | 14 | $I->amGoingTo('submit contact form with no data'); 15 | $contactPage->submit([]); 16 | if (method_exists($I, 'wait')) { 17 | $I->wait(3); // only for selenium 18 | } 19 | $I->expectTo('see validations errors'); 20 | $I->see('Contact', 'h1'); 21 | $I->see('Name cannot be blank', '.help-block'); 22 | $I->see('Email cannot be blank', '.help-block'); 23 | $I->see('Subject cannot be blank', '.help-block'); 24 | $I->see('Body cannot be blank', '.help-block'); 25 | $I->see('The verification code is incorrect', '.help-block'); 26 | 27 | $I->amGoingTo('submit contact form with not correct email'); 28 | $contactPage->submit([ 29 | 'name' => 'tester', 30 | 'email' => 'tester.email', 31 | 'subject' => 'test subject', 32 | 'body' => 'test content', 33 | 'verifyCode' => 'testme', 34 | ]); 35 | if (method_exists($I, 'wait')) { 36 | $I->wait(3); // only for selenium 37 | } 38 | $I->expectTo('see that email address is wrong'); 39 | $I->dontSee('Name cannot be blank', '.help-block'); 40 | $I->see('Email is not a valid email address.', '.help-block'); 41 | $I->dontSee('Subject cannot be blank', '.help-block'); 42 | $I->dontSee('Body cannot be blank', '.help-block'); 43 | $I->dontSee('The verification code is incorrect', '.help-block'); 44 | 45 | $I->amGoingTo('submit contact form with correct data'); 46 | $contactPage->submit([ 47 | 'name' => 'tester', 48 | 'email' => 'tester@example.com', 49 | 'subject' => 'test subject', 50 | 'body' => 'test content', 51 | 'verifyCode' => 'testme', 52 | ]); 53 | if (method_exists($I, 'wait')) { 54 | $I->wait(3); // only for selenium 55 | } 56 | $I->see('Thank you for contacting us. We will respond to you as soon as possible.'); 57 | -------------------------------------------------------------------------------- /tests/codeception/frontend/acceptance/HomeCept.php: -------------------------------------------------------------------------------- 1 | wantTo('ensure that home page works'); 8 | $I->amOnPage(Yii::$app->homeUrl); 9 | $I->see('My Company'); 10 | $I->seeLink('About'); 11 | $I->click('About'); 12 | $I->see('This is the About page.'); 13 | -------------------------------------------------------------------------------- /tests/codeception/frontend/acceptance/LoginCept.php: -------------------------------------------------------------------------------- 1 | wantTo('ensure login page works'); 9 | 10 | $loginPage = LoginPage::openBy($I); 11 | 12 | $I->amGoingTo('submit login form with no data'); 13 | $loginPage->login('', ''); 14 | $I->expectTo('see validations errors'); 15 | $I->see('Username cannot be blank.', '.help-block'); 16 | $I->see('Password cannot be blank.', '.help-block'); 17 | 18 | $I->amGoingTo('try to login with wrong credentials'); 19 | $I->expectTo('see validations errors'); 20 | $loginPage->login('admin', 'wrong'); 21 | $I->expectTo('see validations errors'); 22 | $I->see('Incorrect username or password.', '.help-block'); 23 | 24 | $I->amGoingTo('try to login with correct credentials'); 25 | $loginPage->login('erau', 'password_0'); 26 | $I->expectTo('see that user is logged'); 27 | $I->see('Logout (erau)', 'form button[type=submit]'); 28 | $I->dontSeeLink('Login'); 29 | $I->dontSeeLink('Signup'); 30 | /** Uncomment if using WebDriver 31 | * $I->click('Logout (erau)'); 32 | * $I->dontSeeLink('Logout (erau)'); 33 | * $I->seeLink('Login'); 34 | */ 35 | -------------------------------------------------------------------------------- /tests/codeception/frontend/acceptance/SignupCest.php: -------------------------------------------------------------------------------- 1 | 'tester.email@example.com', 27 | 'username' => 'tester', 28 | ]); 29 | } 30 | 31 | /** 32 | * This method is called when test fails. 33 | * @param \Codeception\Event\FailEvent $event 34 | */ 35 | public function _fail($event) 36 | { 37 | } 38 | 39 | /** 40 | * @param \codeception_frontend\AcceptanceTester $I 41 | * @param \Codeception\Scenario $scenario 42 | */ 43 | public function testUserSignup($I, $scenario) 44 | { 45 | $I->wantTo('ensure that signup works'); 46 | 47 | $signupPage = SignupPage::openBy($I); 48 | $I->see('Signup', 'h1'); 49 | $I->see('Please fill out the following fields to signup:'); 50 | 51 | $I->amGoingTo('submit signup form with no data'); 52 | 53 | $signupPage->submit([]); 54 | 55 | $I->expectTo('see validation errors'); 56 | $I->see('Username cannot be blank.', '.help-block'); 57 | $I->see('Email cannot be blank.', '.help-block'); 58 | $I->see('Password cannot be blank.', '.help-block'); 59 | 60 | $I->amGoingTo('submit signup form with not correct email'); 61 | $signupPage->submit([ 62 | 'username' => 'tester', 63 | 'email' => 'tester.email', 64 | 'password' => 'tester_password', 65 | ]); 66 | 67 | $I->expectTo('see that email address is wrong'); 68 | $I->dontSee('Username cannot be blank.', '.help-block'); 69 | $I->dontSee('Password cannot be blank.', '.help-block'); 70 | $I->see('Email is not a valid email address.', '.help-block'); 71 | 72 | $I->amGoingTo('submit signup form with correct email'); 73 | $signupPage->submit([ 74 | 'username' => 'tester', 75 | 'email' => 'tester.email@example.com', 76 | 'password' => 'tester_password', 77 | ]); 78 | 79 | $I->expectTo('see that user logged in'); 80 | $I->see('Logout (tester)', 'form button[type=submit]'); 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /tests/codeception/frontend/acceptance/_bootstrap.php: -------------------------------------------------------------------------------- 1 | wantTo('ensure that about works'); 9 | AboutPage::openBy($I); 10 | $I->see('About', 'h1'); 11 | -------------------------------------------------------------------------------- /tests/codeception/frontend/functional/ContactCept.php: -------------------------------------------------------------------------------- 1 | wantTo('ensure that contact works'); 9 | 10 | $contactPage = ContactPage::openBy($I); 11 | 12 | $I->see('Contact', 'h1'); 13 | 14 | $I->amGoingTo('submit contact form with no data'); 15 | $contactPage->submit([]); 16 | $I->expectTo('see validations errors'); 17 | $I->see('Contact', 'h1'); 18 | $I->see('Name cannot be blank', '.help-block'); 19 | $I->see('Email cannot be blank', '.help-block'); 20 | $I->see('Subject cannot be blank', '.help-block'); 21 | $I->see('Body cannot be blank', '.help-block'); 22 | $I->see('The verification code is incorrect', '.help-block'); 23 | 24 | $I->amGoingTo('submit contact form with not correct email'); 25 | $contactPage->submit([ 26 | 'name' => 'tester', 27 | 'email' => 'tester.email', 28 | 'subject' => 'test subject', 29 | 'body' => 'test content', 30 | 'verifyCode' => 'testme', 31 | ]); 32 | $I->expectTo('see that email address is wrong'); 33 | $I->dontSee('Name cannot be blank', '.help-block'); 34 | $I->see('Email is not a valid email address.', '.help-block'); 35 | $I->dontSee('Subject cannot be blank', '.help-block'); 36 | $I->dontSee('Body cannot be blank', '.help-block'); 37 | $I->dontSee('The verification code is incorrect', '.help-block'); 38 | 39 | $I->amGoingTo('submit contact form with correct data'); 40 | $contactPage->submit([ 41 | 'name' => 'tester', 42 | 'email' => 'tester@example.com', 43 | 'subject' => 'test subject', 44 | 'body' => 'test content', 45 | 'verifyCode' => 'testme', 46 | ]); 47 | $I->see('Thank you for contacting us. We will respond to you as soon as possible.'); 48 | -------------------------------------------------------------------------------- /tests/codeception/frontend/functional/HomeCept.php: -------------------------------------------------------------------------------- 1 | wantTo('ensure that home page works'); 8 | $I->amOnPage(Yii::$app->homeUrl); 9 | $I->see('My Company'); 10 | $I->seeLink('About'); 11 | $I->click('About'); 12 | $I->see('This is the About page.'); 13 | -------------------------------------------------------------------------------- /tests/codeception/frontend/functional/LoginCept.php: -------------------------------------------------------------------------------- 1 | wantTo('ensure login page works'); 9 | 10 | $loginPage = LoginPage::openBy($I); 11 | 12 | $I->amGoingTo('submit login form with no data'); 13 | $loginPage->login('', ''); 14 | $I->expectTo('see validations errors'); 15 | $I->see('Username cannot be blank.', '.help-block'); 16 | $I->see('Password cannot be blank.', '.help-block'); 17 | 18 | $I->amGoingTo('try to login with wrong credentials'); 19 | $I->expectTo('see validations errors'); 20 | $loginPage->login('admin', 'wrong'); 21 | $I->expectTo('see validations errors'); 22 | $I->see('Incorrect username or password.', '.help-block'); 23 | 24 | $I->amGoingTo('try to login with correct credentials'); 25 | $loginPage->login('erau', 'password_0'); 26 | $I->expectTo('see that user is logged'); 27 | $I->see('Logout (erau)', 'form button[type=submit]'); 28 | $I->dontSeeLink('Login'); 29 | $I->dontSeeLink('Signup'); 30 | -------------------------------------------------------------------------------- /tests/codeception/frontend/functional/SignupCest.php: -------------------------------------------------------------------------------- 1 | loadFixtures(); 27 | } 28 | 29 | /** 30 | * This method is called when test fails. 31 | * @param \codeception_frontend\FunctionalTester $I 32 | */ 33 | public function _failed($I) 34 | { 35 | 36 | } 37 | 38 | /** 39 | * 40 | * @param \codeception_frontend\FunctionalTester $I 41 | * @param \Codeception\Scenario $scenario 42 | */ 43 | public function testUserSignup($I, $scenario) 44 | { 45 | $I->wantTo('ensure that signup works'); 46 | 47 | $signupPage = SignupPage::openBy($I); 48 | $I->see('Signup', 'h1'); 49 | $I->see('Please fill out the following fields to signup:'); 50 | 51 | $I->amGoingTo('submit signup form with no data'); 52 | 53 | $signupPage->submit([]); 54 | 55 | $I->expectTo('see validation errors'); 56 | $I->see('Username cannot be blank.', '.help-block'); 57 | $I->see('Email cannot be blank.', '.help-block'); 58 | $I->see('Password cannot be blank.', '.help-block'); 59 | 60 | $I->amGoingTo('submit signup form with not correct email'); 61 | $signupPage->submit([ 62 | 'username' => 'tester', 63 | 'email' => 'tester.email', 64 | 'password' => 'tester_password', 65 | ]); 66 | 67 | $I->expectTo('see that email address is wrong'); 68 | $I->dontSee('Username cannot be blank.', '.help-block'); 69 | $I->dontSee('Password cannot be blank.', '.help-block'); 70 | $I->see('Email is not a valid email address.', '.help-block'); 71 | 72 | $I->amGoingTo('submit signup form with correct email'); 73 | $signupPage->submit([ 74 | 'username' => 'tester', 75 | 'email' => 'tester.email@example.com', 76 | 'password' => 'tester_password', 77 | ]); 78 | 79 | $I->expectTo('see that user is created'); 80 | $I->seeRecord('common\models\User', [ 81 | 'username' => 'tester', 82 | 'email' => 'tester.email@example.com', 83 | ]); 84 | 85 | $I->expectTo('see that user logged in'); 86 | $I->see('Logout (tester)', 'form button[type=submit]'); 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /tests/codeception/frontend/functional/_bootstrap.php: -------------------------------------------------------------------------------- 1 | 'okirlin', 6 | 'auth_key' => 'iwTNae9t34OmnK6l4vT4IeaTk-YWI2Rv', 7 | 'password_hash' => '$2y$13$CXT0Rkle1EMJ/c1l5bylL.EylfmQ39O5JlHJVFpNn618OUS1HwaIi', 8 | 'password_reset_token' => 't5GU9NwpuGYSfb7FEZMAxqtuz2PkEvv_' . time(), 9 | 'created_at' => '1391885313', 10 | 'updated_at' => '1391885313', 11 | 'email' => 'brady.renner@rutherford.com', 12 | ], 13 | [ 14 | 'username' => 'troy.becker', 15 | 'auth_key' => 'EdKfXrx88weFMV0vIxuTMWKgfK2tS3Lp', 16 | 'password_hash' => '$2y$13$g5nv41Px7VBqhS3hVsVN2.MKfgT3jFdkXEsMC4rQJLfaMa7VaJqL2', 17 | 'password_reset_token' => '4BSNyiZNAuxjs5Mty990c47sVrgllIi_' . time(), 18 | 'created_at' => '1391885313', 19 | 'updated_at' => '1391885313', 20 | 'email' => 'nicolas.dianna@hotmail.com', 21 | 'status' => '0', 22 | ], 23 | ]; 24 | -------------------------------------------------------------------------------- /tests/codeception/frontend/unit/models/ContactFormTest.php: -------------------------------------------------------------------------------- 1 | mailer->fileTransportCallback = function ($mailer, $message) { 18 | return 'testing_message.eml'; 19 | }; 20 | } 21 | 22 | protected function tearDown() 23 | { 24 | unlink($this->getMessageFile()); 25 | parent::tearDown(); 26 | } 27 | 28 | public function testContact() 29 | { 30 | $model = new ContactForm(); 31 | 32 | $model->attributes = [ 33 | 'name' => 'Tester', 34 | 'email' => 'tester@example.com', 35 | 'subject' => 'very important letter subject', 36 | 'body' => 'body of current message', 37 | ]; 38 | 39 | $model->sendEmail('admin@example.com'); 40 | 41 | $this->specify('email should be send', function () { 42 | expect('email file should exist', file_exists($this->getMessageFile()))->true(); 43 | }); 44 | 45 | $this->specify('message should contain correct data', function () use ($model) { 46 | $emailMessage = file_get_contents($this->getMessageFile()); 47 | 48 | expect('email should contain user name', $emailMessage)->contains($model->name); 49 | expect('email should contain sender email', $emailMessage)->contains($model->email); 50 | expect('email should contain subject', $emailMessage)->contains($model->subject); 51 | expect('email should contain body', $emailMessage)->contains($model->body); 52 | }); 53 | } 54 | 55 | private function getMessageFile() 56 | { 57 | return Yii::getAlias(Yii::$app->mailer->fileTransportPath) . '/testing_message.eml'; 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /tests/codeception/frontend/unit/models/PasswordResetRequestFormTest.php: -------------------------------------------------------------------------------- 1 | mailer->fileTransportCallback = function ($mailer, $message) { 21 | return 'testing_message.eml'; 22 | }; 23 | } 24 | 25 | protected function tearDown() 26 | { 27 | @unlink($this->getMessageFile()); 28 | 29 | parent::tearDown(); 30 | } 31 | 32 | public function testSendEmailWrongUser() 33 | { 34 | $this->specify('no user with such email, message should not be sent', function () { 35 | 36 | $model = new PasswordResetRequestForm(); 37 | $model->email = 'not-existing-email@example.com'; 38 | 39 | expect('email not sent', $model->sendEmail())->false(); 40 | 41 | }); 42 | 43 | $this->specify('user is not active, message should not be sent', function () { 44 | 45 | $model = new PasswordResetRequestForm(); 46 | $model->email = $this->user[1]['email']; 47 | 48 | expect('email not sent', $model->sendEmail())->false(); 49 | 50 | }); 51 | } 52 | 53 | public function testSendEmailCorrectUser() 54 | { 55 | $model = new PasswordResetRequestForm(); 56 | $model->email = $this->user[0]['email']; 57 | $user = User::findOne(['password_reset_token' => $this->user[0]['password_reset_token']]); 58 | 59 | expect('email sent', $model->sendEmail())->true(); 60 | expect('user has valid token', $user->password_reset_token)->notNull(); 61 | 62 | $this->specify('message has correct format', function () use ($model) { 63 | 64 | expect('message file exists', file_exists($this->getMessageFile()))->true(); 65 | 66 | $message = file_get_contents($this->getMessageFile()); 67 | expect('message "from" is correct', $message)->contains(Yii::$app->params['supportEmail']); 68 | expect('message "to" is correct', $message)->contains($model->email); 69 | 70 | }); 71 | } 72 | 73 | public function fixtures() 74 | { 75 | return [ 76 | 'user' => [ 77 | 'class' => UserFixture::className(), 78 | 'dataFile' => '@tests/codeception/frontend/unit/fixtures/data/models/user.php' 79 | ], 80 | ]; 81 | } 82 | 83 | private function getMessageFile() 84 | { 85 | return Yii::getAlias(Yii::$app->mailer->fileTransportPath) . '/testing_message.eml'; 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /tests/codeception/frontend/unit/models/ResetPasswordFormTest.php: -------------------------------------------------------------------------------- 1 | user[0]['password_reset_token']); 31 | expect('password should be resetted', $form->resetPassword())->true(); 32 | } 33 | 34 | public function fixtures() 35 | { 36 | return [ 37 | 'user' => [ 38 | 'class' => UserFixture::className(), 39 | 'dataFile' => '@tests/codeception/frontend/unit/fixtures/data/models/user.php' 40 | ], 41 | ]; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /tests/codeception/frontend/unit/models/SignupFormTest.php: -------------------------------------------------------------------------------- 1 | 'some_username', 19 | 'email' => 'some_email@example.com', 20 | 'password' => 'some_password', 21 | ]); 22 | 23 | $user = $model->signup(); 24 | 25 | $this->assertInstanceOf('common\models\User', $user, 'user should be valid'); 26 | 27 | expect('username should be correct', $user->username)->equals('some_username'); 28 | expect('email should be correct', $user->email)->equals('some_email@example.com'); 29 | expect('password should be correct', $user->validatePassword('some_password'))->true(); 30 | } 31 | 32 | public function testNotCorrectSignup() 33 | { 34 | $model = new SignupForm([ 35 | 'username' => 'troy.becker', 36 | 'email' => 'nicolas.dianna@hotmail.com', 37 | 'password' => 'some_password', 38 | ]); 39 | 40 | expect('username and email are in use, user should not be created', $model->signup())->null(); 41 | } 42 | 43 | public function fixtures() 44 | { 45 | return [ 46 | 'user' => [ 47 | 'class' => UserFixture::className(), 48 | 'dataFile' => '@tests/codeception/frontend/unit/fixtures/data/models/user.php', 49 | ], 50 | ]; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /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 (c) 2008 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 | --------------------------------------------------------------------------------