From 9c1fafe366464a7cf1757a65a427c361c560659c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20Schw=C3=B6rer?= Date: Sun, 1 May 2016 00:27:44 +0200 Subject: [PATCH] yii composer install --- .bowerrc | 3 + .gitignore | 27 +- LICENSE.md | 32 + README.md | 102 ++ assets/AppAsset.php | 29 + commands/HelloController.php | 30 + composer.json | 54 ++ composer.lock | 913 ++++++++++++++++++ config/console.php | 45 + config/db.php | 9 + config/params.php | 5 + config/web.php | 66 ++ controllers/SiteController.php | 94 ++ mail/layouts/html.php | 22 + models/ContactForm.php | 64 ++ models/LoginForm.php | 81 ++ models/User.php | 104 ++ requirements.php | 137 +++ runtime/.gitignore | 2 + tests/README.md | 127 +++ tests/codeception.yml | 36 + tests/codeception/.gitignore | 4 + tests/codeception/_bootstrap.php | 16 + tests/codeception/_output/.gitignore | 2 + tests/codeception/_pages/AboutPage.php | 14 + tests/codeception/_pages/ContactPage.php | 26 + tests/codeception/_pages/LoginPage.php | 25 + tests/codeception/acceptance.suite.yml | 27 + tests/codeception/acceptance/AboutCept.php | 10 + tests/codeception/acceptance/ContactCept.php | 57 ++ tests/codeception/acceptance/HomeCept.php | 11 + tests/codeception/acceptance/LoginCept.php | 37 + tests/codeception/acceptance/_bootstrap.php | 2 + tests/codeception/bin/_bootstrap.php | 10 + tests/codeception/bin/yii | 20 + tests/codeception/bin/yii.bat | 20 + tests/codeception/config/acceptance.php | 11 + tests/codeception/config/config.php | 26 + tests/codeception/config/functional.php | 25 + tests/codeception/config/unit.php | 11 + tests/codeception/fixtures/.gitignore | 2 + tests/codeception/functional.suite.yml | 16 + tests/codeception/functional/AboutCept.php | 10 + tests/codeception/functional/ContactCept.php | 48 + tests/codeception/functional/HomeCept.php | 11 + tests/codeception/functional/LoginCept.php | 28 + tests/codeception/functional/_bootstrap.php | 2 + tests/codeception/templates/.gitignore | 2 + tests/codeception/unit.suite.yml | 6 + tests/codeception/unit/_bootstrap.php | 3 + tests/codeception/unit/fixtures/.gitkeep | 0 tests/codeception/unit/fixtures/data/.gitkeep | 0 .../unit/models/ContactFormTest.php | 60 ++ .../codeception/unit/models/LoginFormTest.php | 61 ++ tests/codeception/unit/models/UserTest.php | 17 + .../unit/templates/fixtures/.gitkeep | 0 views/layouts/main.php | 78 ++ views/site/about.php | 18 + views/site/contact.php | 68 ++ views/site/error.php | 27 + views/site/index.php | 53 + views/site/login.php | 47 + web/assets/.gitignore | 2 + web/css/site.css | 91 ++ web/favicon.ico | Bin 0 -> 318 bytes web/index-test.php | 16 + web/index.php | 16 + web/index_prod.php | 12 + web/robots.txt | 2 + yii | 21 + yii.bat | 20 + 71 files changed, 3072 insertions(+), 1 deletion(-) create mode 100644 .bowerrc create mode 100644 LICENSE.md create mode 100644 README.md create mode 100644 assets/AppAsset.php create mode 100644 commands/HelloController.php create mode 100644 composer.json create mode 100644 composer.lock create mode 100644 config/console.php create mode 100644 config/db.php create mode 100644 config/params.php create mode 100644 config/web.php create mode 100644 controllers/SiteController.php create mode 100644 mail/layouts/html.php create mode 100644 models/ContactForm.php create mode 100644 models/LoginForm.php create mode 100644 models/User.php create mode 100644 requirements.php create mode 100644 runtime/.gitignore create mode 100644 tests/README.md create mode 100644 tests/codeception.yml create mode 100644 tests/codeception/.gitignore create mode 100644 tests/codeception/_bootstrap.php create mode 100644 tests/codeception/_output/.gitignore create mode 100644 tests/codeception/_pages/AboutPage.php create mode 100644 tests/codeception/_pages/ContactPage.php create mode 100644 tests/codeception/_pages/LoginPage.php create mode 100644 tests/codeception/acceptance.suite.yml create mode 100644 tests/codeception/acceptance/AboutCept.php create mode 100644 tests/codeception/acceptance/ContactCept.php create mode 100644 tests/codeception/acceptance/HomeCept.php create mode 100644 tests/codeception/acceptance/LoginCept.php create mode 100644 tests/codeception/acceptance/_bootstrap.php create mode 100644 tests/codeception/bin/_bootstrap.php create mode 100644 tests/codeception/bin/yii create mode 100644 tests/codeception/bin/yii.bat create mode 100644 tests/codeception/config/acceptance.php create mode 100644 tests/codeception/config/config.php create mode 100644 tests/codeception/config/functional.php create mode 100644 tests/codeception/config/unit.php create mode 100644 tests/codeception/fixtures/.gitignore create mode 100644 tests/codeception/functional.suite.yml create mode 100644 tests/codeception/functional/AboutCept.php create mode 100644 tests/codeception/functional/ContactCept.php create mode 100644 tests/codeception/functional/HomeCept.php create mode 100644 tests/codeception/functional/LoginCept.php create mode 100644 tests/codeception/functional/_bootstrap.php create mode 100644 tests/codeception/templates/.gitignore create mode 100644 tests/codeception/unit.suite.yml create mode 100644 tests/codeception/unit/_bootstrap.php create mode 100644 tests/codeception/unit/fixtures/.gitkeep create mode 100644 tests/codeception/unit/fixtures/data/.gitkeep create mode 100644 tests/codeception/unit/models/ContactFormTest.php create mode 100644 tests/codeception/unit/models/LoginFormTest.php create mode 100644 tests/codeception/unit/models/UserTest.php create mode 100644 tests/codeception/unit/templates/fixtures/.gitkeep create mode 100644 views/layouts/main.php create mode 100644 views/site/about.php create mode 100644 views/site/contact.php create mode 100644 views/site/error.php create mode 100644 views/site/index.php create mode 100644 views/site/login.php create mode 100644 web/assets/.gitignore create mode 100644 web/css/site.css create mode 100644 web/favicon.ico create mode 100644 web/index-test.php create mode 100644 web/index.php create mode 100644 web/index_prod.php create mode 100644 web/robots.txt create mode 100644 yii create mode 100644 yii.bat diff --git a/.bowerrc b/.bowerrc new file mode 100644 index 0000000..1669168 --- /dev/null +++ b/.bowerrc @@ -0,0 +1,3 @@ +{ + "directory" : "vendor/bower" +} diff --git a/.gitignore b/.gitignore index 1049d5c..45bf7bf 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,27 @@ +# phpstorm project files .idea -*.secret \ No newline at end of file + +# netbeans project files +nbproject + +# zend studio for eclipse project files +.buildpath +.project +.settings + +# windows thumbnail cache +Thumbs.db + +# composer vendor dir +/vendor + +# composer itself is not needed +composer.phar + +# Mac DS_Store Files +.DS_Store + +# phpunit itself is not needed +phpunit.phar +# local phpunit config +/phpunit.xml diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..e98f03d --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,32 @@ +The Yii framework is free software. It is released under the terms of +the following BSD License. + +Copyright © 2008 by Yii Software LLC (http://www.yiisoft.com) +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + * Neither the name of Yii Software LLC nor the names of its + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..598f963 --- /dev/null +++ b/README.md @@ -0,0 +1,102 @@ +Yii 2 Basic Project Template +============================ + +Yii 2 Basic Project Template is a skeleton [Yii 2](http://www.yiiframework.com/) application best for +rapidly creating small projects. + +The template contains the basic features including user login/logout and a contact page. +It includes all commonly used configurations that would allow you to focus on adding new +features to your application. + +[![Latest Stable Version](https://poser.pugx.org/yiisoft/yii2-app-basic/v/stable.png)](https://packagist.org/packages/yiisoft/yii2-app-basic) +[![Total Downloads](https://poser.pugx.org/yiisoft/yii2-app-basic/downloads.png)](https://packagist.org/packages/yiisoft/yii2-app-basic) +[![Build Status](https://travis-ci.org/yiisoft/yii2-app-basic.svg?branch=master)](https://travis-ci.org/yiisoft/yii2-app-basic) + +DIRECTORY STRUCTURE +------------------- + + assets/ contains assets definition + commands/ contains console commands (controllers) + config/ contains application configurations + controllers/ contains Web controller classes + mail/ contains view files for e-mails + models/ contains model classes + runtime/ contains files generated during runtime + tests/ contains various tests for the basic application + vendor/ contains dependent 3rd-party packages + views/ contains view files for the Web application + web/ contains the entry script and Web resources + + + +REQUIREMENTS +------------ + +The minimum requirement by this project template that your Web server supports PHP 5.4.0. + + +INSTALLATION +------------ + +### Install from an Archive File + +Extract the archive file downloaded from [yiiframework.com](http://www.yiiframework.com/download/) to +a directory named `basic` that is directly under the Web root. + +Set cookie validation key in `config/web.php` file to some random secret string: + +```php +'request' => [ + // !!! insert a secret key in the following (if it is empty) - this is required by cookie validation + 'cookieValidationKey' => '', +], +``` + +You can then access the application through the following URL: + +~~~ +http://localhost/basic/web/ +~~~ + + +### Install via Composer + +If you do not have [Composer](http://getcomposer.org/), you may install it by following the instructions +at [getcomposer.org](http://getcomposer.org/doc/00-intro.md#installation-nix). + +You can then install this project template using the following command: + +~~~ +php composer.phar global require "fxp/composer-asset-plugin:~1.1.1" +php composer.phar create-project --prefer-dist --stability=dev yiisoft/yii2-app-basic basic +~~~ + +Now you should be able to access the application through the following URL, assuming `basic` is the directory +directly under the Web root. + +~~~ +http://localhost/basic/web/ +~~~ + + +CONFIGURATION +------------- + +### Database + +Edit the file `config/db.php` with real data, for example: + +```php +return [ + 'class' => 'yii\db\Connection', + 'dsn' => 'mysql:host=localhost;dbname=yii2basic', + 'username' => 'root', + 'password' => '1234', + 'charset' => 'utf8', +]; +``` + +**NOTES:** +- Yii won't create the database for you, this has to be done manually before you can access it. +- Check and edit the other files in the `config/` directory to customize your application as required. +- Refer to the README in the `tests` directory for information specific to basic application tests. diff --git a/assets/AppAsset.php b/assets/AppAsset.php new file mode 100644 index 0000000..0e495a8 --- /dev/null +++ b/assets/AppAsset.php @@ -0,0 +1,29 @@ + + * @since 2.0 + */ +class AppAsset extends AssetBundle +{ + public $basePath = '@webroot'; + public $baseUrl = '@web'; + public $css = [ + 'css/site.css', + ]; + public $js = [ + ]; + public $depends = [ + 'yii\web\YiiAsset', + 'yii\bootstrap\BootstrapAsset', + ]; +} diff --git a/commands/HelloController.php b/commands/HelloController.php new file mode 100644 index 0000000..86ab8b8 --- /dev/null +++ b/commands/HelloController.php @@ -0,0 +1,30 @@ + + * @since 2.0 + */ +class HelloController extends Controller +{ + /** + * This command echoes what you have entered as the message. + * @param string $message the message to be echoed. + */ + public function actionIndex($message = 'hello world') + { + echo $message . "\n"; + } +} diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..1631da6 --- /dev/null +++ b/composer.json @@ -0,0 +1,54 @@ +{ + "name": "yiisoft/yii2-app-basic", + "description": "Yii 2 Basic Project Template", + "keywords": ["yii2", "framework", "basic", "project template"], + "homepage": "http://www.yiiframework.com/", + "type": "project", + "license": "BSD-3-Clause", + "support": { + "issues": "https://github.com/yiisoft/yii2/issues?state=open", + "forum": "http://www.yiiframework.com/forum/", + "wiki": "http://www.yiiframework.com/wiki/", + "irc": "irc://irc.freenode.net/yii", + "source": "https://github.com/yiisoft/yii2" + }, + "minimum-stability": "stable", + "require": { + "php": ">=5.4.0", + "yiisoft/yii2": ">=2.0.5", + "yiisoft/yii2-bootstrap": "*", + "yiisoft/yii2-swiftmailer": "*" + }, + "require-dev": { + "yiisoft/yii2-codeception": "*", + "yiisoft/yii2-debug": "*", + "yiisoft/yii2-gii": "*", + "yiisoft/yii2-faker": "*" + }, + "config": { + "process-timeout": 1800 + }, + "scripts": { + "post-create-project-cmd": [ + "yii\\composer\\Installer::postCreateProject" + ] + }, + "extra": { + "yii\\composer\\Installer::postCreateProject": { + "setPermission": [ + { + "runtime": "0777", + "web/assets": "0777", + "yii": "0755" + } + ], + "generateCookieValidationKey": [ + "config/web.php" + ] + }, + "asset-installer-paths": { + "npm-asset-library": "vendor/npm", + "bower-asset-library": "vendor/bower" + } + } +} diff --git a/composer.lock b/composer.lock new file mode 100644 index 0000000..33b2a48 --- /dev/null +++ b/composer.lock @@ -0,0 +1,913 @@ +{ + "_readme": [ + "This file locks the dependencies of your project to a known state", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", + "This file is @generated automatically" + ], + "hash": "479407875c975e7dbee0aefcb85e62d5", + "content-hash": "5c27dd23827e5c153817a7f3f5d227c6", + "packages": [ + { + "name": "bower-asset/bootstrap", + "version": "v3.3.5", + "source": { + "type": "git", + "url": "https://github.com/twbs/bootstrap.git", + "reference": "16b48259a62f576e52c903c476bd42b90ab22482" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/twbs/bootstrap/zipball/16b48259a62f576e52c903c476bd42b90ab22482", + "reference": "16b48259a62f576e52c903c476bd42b90ab22482", + "shasum": "" + }, + "require": { + "bower-asset/jquery": ">=1.9.1" + }, + "type": "bower-asset-library", + "extra": { + "bower-asset-main": [ + "less/bootstrap.less", + "dist/js/bootstrap.js" + ], + "bower-asset-ignore": [ + "/.*", + "_config.yml", + "CNAME", + "composer.json", + "CONTRIBUTING.md", + "docs", + "js/tests", + "test-infra" + ] + }, + "license": [ + "MIT" + ], + "description": "The most popular front-end framework for developing responsive, mobile first projects on the web.", + "keywords": [ + "css", + "framework", + "front-end", + "js", + "less", + "mobile-first", + "responsive", + "web" + ] + }, + { + "name": "bower-asset/jquery", + "version": "2.2.3", + "source": { + "type": "git", + "url": "https://github.com/jquery/jquery-dist.git", + "reference": "af22a351b2ea5801ffb1695abb3bb34d5bed9198" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/jquery/jquery-dist/zipball/af22a351b2ea5801ffb1695abb3bb34d5bed9198", + "reference": "af22a351b2ea5801ffb1695abb3bb34d5bed9198", + "shasum": "" + }, + "type": "bower-asset-library", + "extra": { + "bower-asset-main": "dist/jquery.js", + "bower-asset-ignore": [ + "package.json" + ] + }, + "license": [ + "MIT" + ], + "keywords": [ + "browser", + "javascript", + "jquery", + "library" + ] + }, + { + "name": "bower-asset/jquery.inputmask", + "version": "3.2.7", + "source": { + "type": "git", + "url": "https://github.com/RobinHerbots/jquery.inputmask.git", + "reference": "5a72c563b502b8e05958a524cdfffafe9987be38" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/RobinHerbots/jquery.inputmask/zipball/5a72c563b502b8e05958a524cdfffafe9987be38", + "reference": "5a72c563b502b8e05958a524cdfffafe9987be38", + "shasum": "" + }, + "require": { + "bower-asset/jquery": ">=1.7" + }, + "type": "bower-asset-library", + "extra": { + "bower-asset-main": [ + "./dist/inputmask/inputmask.js" + ], + "bower-asset-ignore": [ + "**/*", + "!dist/*", + "!dist/inputmask/*", + "!dist/min/*", + "!dist/min/inputmask/*", + "!extra/bindings/*", + "!extra/dependencyLibs/*", + "!extra/phone-codes/*" + ] + }, + "license": [ + "http://opensource.org/licenses/mit-license.php" + ], + "description": "jquery.inputmask is a jquery plugin which create an input mask.", + "keywords": [ + "form", + "input", + "inputmask", + "jquery", + "mask", + "plugins" + ] + }, + { + "name": "bower-asset/punycode", + "version": "v1.3.2", + "source": { + "type": "git", + "url": "https://github.com/bestiejs/punycode.js.git", + "reference": "38c8d3131a82567bfef18da09f7f4db68c84f8a3" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/bestiejs/punycode.js/zipball/38c8d3131a82567bfef18da09f7f4db68c84f8a3", + "reference": "38c8d3131a82567bfef18da09f7f4db68c84f8a3", + "shasum": "" + }, + "type": "bower-asset-library", + "extra": { + "bower-asset-main": "punycode.js", + "bower-asset-ignore": [ + "coverage", + "tests", + ".*", + "component.json", + "Gruntfile.js", + "node_modules", + "package.json" + ] + } + }, + { + "name": "bower-asset/yii2-pjax", + "version": "v2.0.6", + "source": { + "type": "git", + "url": "https://github.com/yiisoft/jquery-pjax.git", + "reference": "60728da6ade5879e807a49ce59ef9a72039b8978" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/yiisoft/jquery-pjax/zipball/60728da6ade5879e807a49ce59ef9a72039b8978", + "reference": "60728da6ade5879e807a49ce59ef9a72039b8978", + "shasum": "" + }, + "require": { + "bower-asset/jquery": ">=1.8" + }, + "type": "bower-asset-library", + "extra": { + "bower-asset-main": "./jquery.pjax.js", + "bower-asset-ignore": [ + ".travis.yml", + "Gemfile", + "Gemfile.lock", + "CONTRIBUTING.md", + "vendor/", + "script/", + "test/" + ] + }, + "license": [ + "MIT" + ] + }, + { + "name": "cebe/markdown", + "version": "1.1.0", + "source": { + "type": "git", + "url": "https://github.com/cebe/markdown.git", + "reference": "54a2c49de31cc44e864ebf0500a35ef21d0010b2" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/cebe/markdown/zipball/54a2c49de31cc44e864ebf0500a35ef21d0010b2", + "reference": "54a2c49de31cc44e864ebf0500a35ef21d0010b2", + "shasum": "" + }, + "require": { + "lib-pcre": "*", + "php": ">=5.4.0" + }, + "require-dev": { + "cebe/indent": "*", + "facebook/xhprof": "*@dev", + "phpunit/phpunit": "4.1.*" + }, + "bin": [ + "bin/markdown" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.1.x-dev" + } + }, + "autoload": { + "psr-4": { + "cebe\\markdown\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Carsten Brandt", + "email": "mail@cebe.cc", + "homepage": "http://cebe.cc/", + "role": "Creator" + } + ], + "description": "A super fast, highly extensible markdown parser for PHP", + "homepage": "https://github.com/cebe/markdown#readme", + "keywords": [ + "extensible", + "fast", + "gfm", + "markdown", + "markdown-extra" + ], + "time": "2015-03-06 05:28:07" + }, + { + "name": "ezyang/htmlpurifier", + "version": "v4.7.0", + "source": { + "type": "git", + "url": "https://github.com/ezyang/htmlpurifier.git", + "reference": "ae1828d955112356f7677c465f94f7deb7d27a40" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/ezyang/htmlpurifier/zipball/ae1828d955112356f7677c465f94f7deb7d27a40", + "reference": "ae1828d955112356f7677c465f94f7deb7d27a40", + "shasum": "" + }, + "require": { + "php": ">=5.2" + }, + "type": "library", + "autoload": { + "psr-0": { + "HTMLPurifier": "library/" + }, + "files": [ + "library/HTMLPurifier.composer.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "LGPL" + ], + "authors": [ + { + "name": "Edward Z. Yang", + "email": "admin@htmlpurifier.org", + "homepage": "http://ezyang.com" + } + ], + "description": "Standards compliant HTML filter written in PHP", + "homepage": "http://htmlpurifier.org/", + "keywords": [ + "html" + ], + "time": "2015-08-05 01:03:42" + }, + { + "name": "swiftmailer/swiftmailer", + "version": "v5.4.1", + "source": { + "type": "git", + "url": "https://github.com/swiftmailer/swiftmailer.git", + "reference": "0697e6aa65c83edf97bb0f23d8763f94e3f11421" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/swiftmailer/swiftmailer/zipball/0697e6aa65c83edf97bb0f23d8763f94e3f11421", + "reference": "0697e6aa65c83edf97bb0f23d8763f94e3f11421", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "mockery/mockery": "~0.9.1,<0.9.4" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "5.4-dev" + } + }, + "autoload": { + "files": [ + "lib/swift_required.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Chris Corbyn" + }, + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + } + ], + "description": "Swiftmailer, free feature-rich PHP mailer", + "homepage": "http://swiftmailer.org", + "keywords": [ + "email", + "mail", + "mailer" + ], + "time": "2015-06-06 14:19:39" + }, + { + "name": "yiisoft/yii2", + "version": "2.0.8", + "source": { + "type": "git", + "url": "https://github.com/yiisoft/yii2-framework.git", + "reference": "53992b136b993e32ca7b6f399cf42b143f8685a6" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/yiisoft/yii2-framework/zipball/53992b136b993e32ca7b6f399cf42b143f8685a6", + "reference": "53992b136b993e32ca7b6f399cf42b143f8685a6", + "shasum": "" + }, + "require": { + "bower-asset/jquery": "2.2.*@stable | 2.1.*@stable | 1.11.*@stable", + "bower-asset/jquery.inputmask": "~3.2.2", + "bower-asset/punycode": "1.3.*", + "bower-asset/yii2-pjax": "~2.0.1", + "cebe/markdown": "~1.0.0 | ~1.1.0", + "ext-ctype": "*", + "ext-mbstring": "*", + "ezyang/htmlpurifier": "~4.6", + "lib-pcre": "*", + "php": ">=5.4.0", + "yiisoft/yii2-composer": "~2.0.4" + }, + "bin": [ + "yii" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "yii\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Qiang Xue", + "email": "qiang.xue@gmail.com", + "homepage": "http://www.yiiframework.com/", + "role": "Founder and project lead" + }, + { + "name": "Alexander Makarov", + "email": "sam@rmcreative.ru", + "homepage": "http://rmcreative.ru/", + "role": "Core framework development" + }, + { + "name": "Maurizio Domba", + "homepage": "http://mdomba.info/", + "role": "Core framework development" + }, + { + "name": "Carsten Brandt", + "email": "mail@cebe.cc", + "homepage": "http://cebe.cc/", + "role": "Core framework development" + }, + { + "name": "Timur Ruziev", + "email": "resurtm@gmail.com", + "homepage": "http://resurtm.com/", + "role": "Core framework development" + }, + { + "name": "Paul Klimov", + "email": "klimov.paul@gmail.com", + "role": "Core framework development" + }, + { + "name": "Dmitry Naumenko", + "email": "d.naumenko.a@gmail.com", + "role": "Core framework development" + } + ], + "description": "Yii PHP Framework Version 2", + "homepage": "http://www.yiiframework.com/", + "keywords": [ + "framework", + "yii2" + ], + "time": "2016-04-28 14:50:20" + }, + { + "name": "yiisoft/yii2-bootstrap", + "version": "2.0.6", + "source": { + "type": "git", + "url": "https://github.com/yiisoft/yii2-bootstrap.git", + "reference": "3fd2b8c950cce79d60e9702d6bcb24eb3c80f6c5" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/yiisoft/yii2-bootstrap/zipball/3fd2b8c950cce79d60e9702d6bcb24eb3c80f6c5", + "reference": "3fd2b8c950cce79d60e9702d6bcb24eb3c80f6c5", + "shasum": "" + }, + "require": { + "bower-asset/bootstrap": "3.3.* | 3.2.* | 3.1.*", + "yiisoft/yii2": ">=2.0.6" + }, + "type": "yii2-extension", + "extra": { + "branch-alias": { + "dev-master": "2.0.x-dev" + }, + "asset-installer-paths": { + "npm-asset-library": "vendor/npm", + "bower-asset-library": "vendor/bower" + } + }, + "autoload": { + "psr-4": { + "yii\\bootstrap\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Qiang Xue", + "email": "qiang.xue@gmail.com" + } + ], + "description": "The Twitter Bootstrap extension for the Yii framework", + "keywords": [ + "bootstrap", + "yii2" + ], + "time": "2016-03-17 03:29:28" + }, + { + "name": "yiisoft/yii2-composer", + "version": "2.0.4", + "source": { + "type": "git", + "url": "https://github.com/yiisoft/yii2-composer.git", + "reference": "7452fd908a5023b8bb5ea1b123a174ca080de464" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/yiisoft/yii2-composer/zipball/7452fd908a5023b8bb5ea1b123a174ca080de464", + "reference": "7452fd908a5023b8bb5ea1b123a174ca080de464", + "shasum": "" + }, + "require": { + "composer-plugin-api": "^1.0" + }, + "type": "composer-plugin", + "extra": { + "class": "yii\\composer\\Plugin", + "branch-alias": { + "dev-master": "2.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "yii\\composer\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Qiang Xue", + "email": "qiang.xue@gmail.com" + } + ], + "description": "The composer plugin for Yii extension installer", + "keywords": [ + "composer", + "extension installer", + "yii2" + ], + "time": "2016-02-06 00:49:24" + }, + { + "name": "yiisoft/yii2-swiftmailer", + "version": "2.0.5", + "source": { + "type": "git", + "url": "https://github.com/yiisoft/yii2-swiftmailer.git", + "reference": "e2c6315caff30a9271a7afad4d684627721dc69a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/yiisoft/yii2-swiftmailer/zipball/e2c6315caff30a9271a7afad4d684627721dc69a", + "reference": "e2c6315caff30a9271a7afad4d684627721dc69a", + "shasum": "" + }, + "require": { + "swiftmailer/swiftmailer": "~5.0", + "yiisoft/yii2": ">=2.0.4" + }, + "type": "yii2-extension", + "extra": { + "branch-alias": { + "dev-master": "2.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "yii\\swiftmailer\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Paul Klimov", + "email": "klimov.paul@gmail.com" + } + ], + "description": "The SwiftMailer integration for the Yii framework", + "keywords": [ + "email", + "mail", + "mailer", + "swift", + "swiftmailer", + "yii2" + ], + "time": "2016-03-17 03:58:49" + } + ], + "packages-dev": [ + { + "name": "bower-asset/typeahead.js", + "version": "v0.11.1", + "source": { + "type": "git", + "url": "https://github.com/twitter/typeahead.js.git", + "reference": "588440f66559714280628a4f9799f0c4eb880a4a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/twitter/typeahead.js/zipball/588440f66559714280628a4f9799f0c4eb880a4a", + "reference": "588440f66559714280628a4f9799f0c4eb880a4a", + "shasum": "" + }, + "require": { + "bower-asset/jquery": ">=1.7" + }, + "require-dev": { + "bower-asset/jasmine-ajax": "~1.3.1", + "bower-asset/jasmine-jquery": "~1.5.2", + "bower-asset/jquery": "~1.7" + }, + "type": "bower-asset-library", + "extra": { + "bower-asset-main": "dist/typeahead.bundle.js" + } + }, + { + "name": "fzaninotto/faker", + "version": "v1.6.0", + "source": { + "type": "git", + "url": "https://github.com/fzaninotto/Faker.git", + "reference": "44f9a286a04b80c76a4e5fb7aad8bb539b920123" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/fzaninotto/Faker/zipball/44f9a286a04b80c76a4e5fb7aad8bb539b920123", + "reference": "44f9a286a04b80c76a4e5fb7aad8bb539b920123", + "shasum": "" + }, + "require": { + "php": "^5.3.3|^7.0" + }, + "require-dev": { + "ext-intl": "*", + "phpunit/phpunit": "~4.0", + "squizlabs/php_codesniffer": "~1.5" + }, + "type": "library", + "extra": { + "branch-alias": [] + }, + "autoload": { + "psr-4": { + "Faker\\": "src/Faker/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "François Zaninotto" + } + ], + "description": "Faker is a PHP library that generates fake data for you.", + "keywords": [ + "data", + "faker", + "fixtures" + ], + "time": "2016-04-29 12:21:54" + }, + { + "name": "phpspec/php-diff", + "version": "v1.1.0", + "source": { + "type": "git", + "url": "https://github.com/phpspec/php-diff.git", + "reference": "0464787bfa7cd13576c5a1e318709768798bec6a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpspec/php-diff/zipball/0464787bfa7cd13576c5a1e318709768798bec6a", + "reference": "0464787bfa7cd13576c5a1e318709768798bec6a", + "shasum": "" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-0": { + "Diff": "lib/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Chris Boulton", + "homepage": "http://github.com/chrisboulton" + } + ], + "description": "A comprehensive library for generating differences between two hashable objects (strings or arrays).", + "time": "2016-04-07 12:29:16" + }, + { + "name": "yiisoft/yii2-codeception", + "version": "2.0.5", + "source": { + "type": "git", + "url": "https://github.com/yiisoft/yii2-codeception.git", + "reference": "c916a36d09fc128b05a374e7922bc56854334d56" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/yiisoft/yii2-codeception/zipball/c916a36d09fc128b05a374e7922bc56854334d56", + "reference": "c916a36d09fc128b05a374e7922bc56854334d56", + "shasum": "" + }, + "require": { + "yiisoft/yii2": ">=2.0.4" + }, + "type": "yii2-extension", + "extra": { + "branch-alias": { + "dev-master": "2.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "yii\\codeception\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Mark Jebri", + "email": "mark.github@yandex.ru" + } + ], + "description": "The Codeception integration for the Yii framework", + "keywords": [ + "codeception", + "yii2" + ], + "time": "2016-03-17 03:41:26" + }, + { + "name": "yiisoft/yii2-debug", + "version": "2.0.6", + "source": { + "type": "git", + "url": "https://github.com/yiisoft/yii2-debug.git", + "reference": "55ed2e853ed8050a34415f63a4da84f88a56f895" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/yiisoft/yii2-debug/zipball/55ed2e853ed8050a34415f63a4da84f88a56f895", + "reference": "55ed2e853ed8050a34415f63a4da84f88a56f895", + "shasum": "" + }, + "require": { + "yiisoft/yii2": ">=2.0.4", + "yiisoft/yii2-bootstrap": "*" + }, + "type": "yii2-extension", + "extra": { + "branch-alias": { + "dev-master": "2.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "yii\\debug\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Qiang Xue", + "email": "qiang.xue@gmail.com" + } + ], + "description": "The debugger extension for the Yii framework", + "keywords": [ + "debug", + "debugger", + "yii2" + ], + "time": "2016-03-17 03:50:19" + }, + { + "name": "yiisoft/yii2-faker", + "version": "2.0.3", + "source": { + "type": "git", + "url": "https://github.com/yiisoft/yii2-faker.git", + "reference": "b88ca69ee226a3610b2c26c026c3203d7ac50f6c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/yiisoft/yii2-faker/zipball/b88ca69ee226a3610b2c26c026c3203d7ac50f6c", + "reference": "b88ca69ee226a3610b2c26c026c3203d7ac50f6c", + "shasum": "" + }, + "require": { + "fzaninotto/faker": "*", + "yiisoft/yii2": "*" + }, + "type": "yii2-extension", + "extra": { + "branch-alias": { + "dev-master": "2.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "yii\\faker\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Mark Jebri", + "email": "mark.github@yandex.ru" + } + ], + "description": "Fixture generator. The Faker integration for the Yii framework.", + "keywords": [ + "Fixture", + "faker", + "yii2" + ], + "time": "2015-03-01 06:22:44" + }, + { + "name": "yiisoft/yii2-gii", + "version": "2.0.5", + "source": { + "type": "git", + "url": "https://github.com/yiisoft/yii2-gii.git", + "reference": "1bd6df6804ca077ec022587905a0d43eb286f507" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/yiisoft/yii2-gii/zipball/1bd6df6804ca077ec022587905a0d43eb286f507", + "reference": "1bd6df6804ca077ec022587905a0d43eb286f507", + "shasum": "" + }, + "require": { + "bower-asset/typeahead.js": "0.10.* | ~0.11.0", + "phpspec/php-diff": ">=1.0.2", + "yiisoft/yii2": ">=2.0.4", + "yiisoft/yii2-bootstrap": "~2.0" + }, + "type": "yii2-extension", + "extra": { + "branch-alias": { + "dev-master": "2.0.x-dev" + }, + "asset-installer-paths": { + "npm-asset-library": "vendor/npm", + "bower-asset-library": "vendor/bower" + } + }, + "autoload": { + "psr-4": { + "yii\\gii\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Qiang Xue", + "email": "qiang.xue@gmail.com" + } + ], + "description": "The Gii extension for the Yii framework", + "keywords": [ + "code generator", + "gii", + "yii2" + ], + "time": "2016-03-18 14:09:46" + } + ], + "aliases": [], + "minimum-stability": "stable", + "stability-flags": [], + "prefer-stable": false, + "prefer-lowest": false, + "platform": { + "php": ">=5.4.0" + }, + "platform-dev": [] +} diff --git a/config/console.php b/config/console.php new file mode 100644 index 0000000..7306e27 --- /dev/null +++ b/config/console.php @@ -0,0 +1,45 @@ + 'basic-console', + 'basePath' => dirname(__DIR__), + 'bootstrap' => ['log'], + 'controllerNamespace' => 'app\commands', + 'components' => [ + 'cache' => [ + 'class' => 'yii\caching\FileCache', + ], + 'log' => [ + 'targets' => [ + [ + 'class' => 'yii\log\FileTarget', + 'levels' => ['error', 'warning'], + ], + ], + ], + 'db' => $db, + ], + 'params' => $params, + /* + 'controllerMap' => [ + 'fixture' => [ // Fixture generation command line. + 'class' => 'yii\faker\FixtureController', + ], + ], + */ +]; + +if (YII_ENV_DEV) { + // configuration adjustments for 'dev' environment + $config['bootstrap'][] = 'gii'; + $config['modules']['gii'] = [ + 'class' => 'yii\gii\Module', + ]; +} + +return $config; diff --git a/config/db.php b/config/db.php new file mode 100644 index 0000000..c4c1252 --- /dev/null +++ b/config/db.php @@ -0,0 +1,9 @@ + 'yii\db\Connection', + 'dsn' => 'mysql:host=localhost;dbname=yii2basic', + 'username' => 'root', + 'password' => '', + 'charset' => 'utf8', +]; diff --git a/config/params.php b/config/params.php new file mode 100644 index 0000000..6ebf279 --- /dev/null +++ b/config/params.php @@ -0,0 +1,5 @@ + 'admin@example.com', +]; diff --git a/config/web.php b/config/web.php new file mode 100644 index 0000000..bb460d2 --- /dev/null +++ b/config/web.php @@ -0,0 +1,66 @@ + 'basic', + 'basePath' => dirname(__DIR__), + 'bootstrap' => ['log'], + 'components' => [ + 'request' => [ + // !!! insert a secret key in the following (if it is empty) - this is required by cookie validation + 'cookieValidationKey' => '-u5gSyUrdsqUaaa34qHDype3Hwmca1gA', + ], + 'cache' => [ + 'class' => 'yii\caching\FileCache', + ], + 'user' => [ + 'identityClass' => 'app\models\User', + 'enableAutoLogin' => true, + ], + 'errorHandler' => [ + 'errorAction' => 'site/error', + ], + 'mailer' => [ + 'class' => 'yii\swiftmailer\Mailer', + // send all mails to a file by default. You have to set + // 'useFileTransport' to false and configure a transport + // for the mailer to send real emails. + 'useFileTransport' => true, + ], + 'log' => [ + 'traceLevel' => YII_DEBUG ? 3 : 0, + 'targets' => [ + [ + 'class' => 'yii\log\FileTarget', + 'levels' => ['error', 'warning'], + ], + ], + ], + 'db' => require(__DIR__ . '/db.php'), + /* + 'urlManager' => [ + 'enablePrettyUrl' => true, + 'showScriptName' => false, + 'rules' => [ + ], + ], + */ + ], + 'params' => $params, +]; + +if (YII_ENV_DEV) { + // configuration adjustments for 'dev' environment + $config['bootstrap'][] = 'debug'; + $config['modules']['debug'] = [ + 'class' => 'yii\debug\Module', + ]; + + $config['bootstrap'][] = 'gii'; + $config['modules']['gii'] = [ + 'class' => 'yii\gii\Module', + ]; +} + +return $config; diff --git a/controllers/SiteController.php b/controllers/SiteController.php new file mode 100644 index 0000000..df1a0d3 --- /dev/null +++ b/controllers/SiteController.php @@ -0,0 +1,94 @@ + [ + 'class' => AccessControl::className(), + 'only' => ['logout'], + 'rules' => [ + [ + 'actions' => ['logout'], + 'allow' => true, + 'roles' => ['@'], + ], + ], + ], + 'verbs' => [ + 'class' => VerbFilter::className(), + 'actions' => [ + 'logout' => ['post'], + ], + ], + ]; + } + + public function actions() + { + return [ + 'error' => [ + 'class' => 'yii\web\ErrorAction', + ], + 'captcha' => [ + 'class' => 'yii\captcha\CaptchaAction', + 'fixedVerifyCode' => YII_ENV_TEST ? 'testme' : null, + ], + ]; + } + + public function actionIndex() + { + return $this->render('index'); + } + + public function actionLogin() + { + if (!Yii::$app->user->isGuest) { + return $this->goHome(); + } + + $model = new LoginForm(); + if ($model->load(Yii::$app->request->post()) && $model->login()) { + return $this->goBack(); + } + return $this->render('login', [ + 'model' => $model, + ]); + } + + public function actionLogout() + { + Yii::$app->user->logout(); + + return $this->goHome(); + } + + public function actionContact() + { + $model = new ContactForm(); + if ($model->load(Yii::$app->request->post()) && $model->contact(Yii::$app->params['adminEmail'])) { + Yii::$app->session->setFlash('contactFormSubmitted'); + + return $this->refresh(); + } + return $this->render('contact', [ + 'model' => $model, + ]); + } + + public function actionAbout() + { + return $this->render('about'); + } +} diff --git a/mail/layouts/html.php b/mail/layouts/html.php new file mode 100644 index 0000000..bddbc61 --- /dev/null +++ b/mail/layouts/html.php @@ -0,0 +1,22 @@ + +beginPage() ?> + + + + + <?= Html::encode($this->title) ?> + head() ?> + + + beginBody() ?> + + endBody() ?> + + +endPage() ?> diff --git a/models/ContactForm.php b/models/ContactForm.php new file mode 100644 index 0000000..37f48b3 --- /dev/null +++ b/models/ContactForm.php @@ -0,0 +1,64 @@ + 'Verification Code', + ]; + } + + /** + * Sends an email to the specified email address using the information collected by this model. + * @param string $email the target email address + * @return boolean whether the model passes validation + */ + public function contact($email) + { + if ($this->validate()) { + Yii::$app->mailer->compose() + ->setTo($email) + ->setFrom([$this->email => $this->name]) + ->setSubject($this->subject) + ->setTextBody($this->body) + ->send(); + + return true; + } + return false; + } +} diff --git a/models/LoginForm.php b/models/LoginForm.php new file mode 100644 index 0000000..7ef5c99 --- /dev/null +++ b/models/LoginForm.php @@ -0,0 +1,81 @@ +hasErrors()) { + $user = $this->getUser(); + + if (!$user || !$user->validatePassword($this->password)) { + $this->addError($attribute, 'Incorrect username or password.'); + } + } + } + + /** + * Logs in a user using the provided username and password. + * @return boolean whether the user is logged in successfully + */ + public function login() + { + if ($this->validate()) { + return Yii::$app->user->login($this->getUser(), $this->rememberMe ? 3600*24*30 : 0); + } + return false; + } + + /** + * Finds user by [[username]] + * + * @return User|null + */ + public function getUser() + { + if ($this->_user === false) { + $this->_user = User::findByUsername($this->username); + } + + return $this->_user; + } +} diff --git a/models/User.php b/models/User.php new file mode 100644 index 0000000..163a64f --- /dev/null +++ b/models/User.php @@ -0,0 +1,104 @@ + [ + 'id' => '100', + 'username' => 'admin', + 'password' => 'admin', + 'authKey' => 'test100key', + 'accessToken' => '100-token', + ], + '101' => [ + 'id' => '101', + 'username' => 'demo', + 'password' => 'demo', + 'authKey' => 'test101key', + 'accessToken' => '101-token', + ], + ]; + + + /** + * @inheritdoc + */ + public static function findIdentity($id) + { + return isset(self::$users[$id]) ? new static(self::$users[$id]) : null; + } + + /** + * @inheritdoc + */ + public static function findIdentityByAccessToken($token, $type = null) + { + foreach (self::$users as $user) { + if ($user['accessToken'] === $token) { + return new static($user); + } + } + + return null; + } + + /** + * Finds user by username + * + * @param string $username + * @return static|null + */ + public static function findByUsername($username) + { + foreach (self::$users as $user) { + if (strcasecmp($user['username'], $username) === 0) { + return new static($user); + } + } + + return null; + } + + /** + * @inheritdoc + */ + public function getId() + { + return $this->id; + } + + /** + * @inheritdoc + */ + public function getAuthKey() + { + return $this->authKey; + } + + /** + * @inheritdoc + */ + public function validateAuthKey($authKey) + { + return $this->authKey === $authKey; + } + + /** + * Validates password + * + * @param string $password password to validate + * @return boolean if password provided is valid for current user + */ + public function validatePassword($password) + { + return $this->password === $password; + } +} diff --git a/requirements.php b/requirements.php new file mode 100644 index 0000000..ee3184f --- /dev/null +++ b/requirements.php @@ -0,0 +1,137 @@ +Error'; + echo '

The path to yii framework seems to be incorrect.

'; + echo '

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

'; + echo '

Please refer to the README on how to install Yii.

'; +} + +require_once($frameworkPath . '/requirements/YiiRequirementChecker.php'); +$requirementsChecker = new YiiRequirementChecker(); + +$gdMemo = $imagickMemo = 'Either GD PHP extension with FreeType support or ImageMagick PHP extension with PNG support is required for image CAPTCHA.'; +$gdOK = $imagickOK = false; + +if (extension_loaded('imagick')) { + $imagick = new Imagick(); + $imagickFormats = $imagick->queryFormats('PNG'); + if (in_array('PNG', $imagickFormats)) { + $imagickOK = true; + } else { + $imagickMemo = 'Imagick extension should be installed with PNG support in order to be used for image CAPTCHA.'; + } +} + +if (extension_loaded('gd')) { + $gdInfo = gd_info(); + if (!empty($gdInfo['FreeType Support'])) { + $gdOK = true; + } else { + $gdMemo = 'GD extension should be installed with FreeType support in order to be used for image CAPTCHA.'; + } +} + +/** + * Adjust requirements according to your application specifics. + */ +$requirements = array( + // Database : + array( + 'name' => 'PDO extension', + 'mandatory' => true, + 'condition' => extension_loaded('pdo'), + 'by' => 'All DB-related classes', + ), + array( + 'name' => 'PDO SQLite extension', + 'mandatory' => false, + 'condition' => extension_loaded('pdo_sqlite'), + 'by' => 'All DB-related classes', + 'memo' => 'Required for SQLite database.', + ), + array( + 'name' => 'PDO MySQL extension', + 'mandatory' => false, + 'condition' => extension_loaded('pdo_mysql'), + 'by' => 'All DB-related classes', + 'memo' => 'Required for MySQL database.', + ), + array( + 'name' => 'PDO PostgreSQL extension', + 'mandatory' => false, + 'condition' => extension_loaded('pdo_pgsql'), + 'by' => 'All DB-related classes', + 'memo' => 'Required for PostgreSQL database.', + ), + // Cache : + array( + 'name' => 'Memcache extension', + 'mandatory' => false, + 'condition' => extension_loaded('memcache') || extension_loaded('memcached'), + 'by' => 'MemCache', + 'memo' => extension_loaded('memcached') ? 'To use memcached set MemCache::useMemcached to true.' : '' + ), + // CAPTCHA: + array( + 'name' => 'GD PHP extension with FreeType support', + 'mandatory' => false, + 'condition' => $gdOK, + 'by' => 'Captcha', + 'memo' => $gdMemo, + ), + array( + 'name' => 'ImageMagick PHP extension with PNG support', + 'mandatory' => false, + 'condition' => $imagickOK, + 'by' => 'Captcha', + 'memo' => $imagickMemo, + ), + // PHP ini : + 'phpExposePhp' => array( + 'name' => 'Expose PHP', + 'mandatory' => false, + 'condition' => $requirementsChecker->checkPhpIniOff("expose_php"), + 'by' => 'Security reasons', + 'memo' => '"expose_php" should be disabled at php.ini', + ), + 'phpAllowUrlInclude' => array( + 'name' => 'PHP allow url include', + 'mandatory' => false, + 'condition' => $requirementsChecker->checkPhpIniOff("allow_url_include"), + 'by' => 'Security reasons', + 'memo' => '"allow_url_include" should be disabled at php.ini', + ), + 'phpSmtp' => array( + 'name' => 'PHP mail SMTP', + 'mandatory' => false, + 'condition' => strlen(ini_get('SMTP')) > 0, + 'by' => 'Email sending', + 'memo' => 'PHP mail SMTP server required', + ), +); + +// OPcache check +if (!version_compare(phpversion(), '5.5', '>=')) { + $requirements[] = array( + 'name' => 'APC extension', + 'mandatory' => false, + 'condition' => extension_loaded('apc'), + 'by' => 'ApcCache', + ); +} + +$requirementsChecker->checkYii()->check($requirements)->render(); diff --git a/runtime/.gitignore b/runtime/.gitignore new file mode 100644 index 0000000..c96a04f --- /dev/null +++ b/runtime/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore \ No newline at end of file diff --git a/tests/README.md b/tests/README.md new file mode 100644 index 0000000..fd80fe5 --- /dev/null +++ b/tests/README.md @@ -0,0 +1,127 @@ +This directory contains various tests for the basic application. + +Tests in `codeception` directory are developed with [Codeception PHP Testing Framework](http://codeception.com/). + +After creating the basic application, follow these steps to prepare for the tests: + +1. Install Codeception if it's not yet installed: + + ``` + composer global require "codeception/codeception=2.0.*" + composer global require "codeception/specify=*" + composer global require "codeception/verify=*" + ``` + + If you've never used Composer for global packages run `composer global status`. It should output: + + ``` + Changed current directory to + ``` + + Then add `/vendor/bin` to you `PATH` environment variable. Now we're able to use `codecept` from command + line globally. + +2. Install faker extension by running the following from template root directory where `composer.json` is: + + ``` + composer require --dev "yiisoft/yii2-faker:*" + ``` + +3. Create `yii2_basic_tests` database and update it by applying migrations (you may skip this step if you do not have created any migrations yet): + + ``` + codeception/bin/yii migrate + ``` + + The command needs to be run in the `tests` directory. + The database configuration can be found at `tests/codeception/config/config.php`. + +4. Build the test suites: + + ``` + codecept build + ``` + +5. In order to be able to run acceptance tests you need to start a webserver. The simplest way is to use PHP built in +webserver. In the `web` directory execute the following: + + ``` + php -S localhost:8080 + ``` + +6. Now you can run the tests with the following commands: + + ``` + # run all available tests + codecept run + # run acceptance tests + codecept run acceptance + # run functional tests + codecept run functional + # run unit tests + codecept run unit + ``` + +Fixtures Default Configuration +------------------------------ +The `fixture` commands refer to the following `ActiveFixture` configuration by default: + +- Fixtures path: `@tests/unit/fixtures` +- Fixtures data path: `@tests/unit/fixtures/data` +- Template files path: `@tests/unit/templates/fixtures` +- Namespace: `tests\unit\fixtures` + +Where `@tests` refers to `@app/tests/codeception`. + +Code coverage support +--------------------- + +By default, code coverage is disabled in `codeception.yml` configuration file, you should uncomment needed rows to be able +to collect code coverage. You can run your tests and collect coverage with the following command: + +``` +#collect coverage for all tests +codecept run --coverage-html --coverage-xml + +#collect coverage only for unit tests +codecept run unit --coverage-html --coverage-xml + +#collect coverage for unit and functional tests +codecept run functional,unit --coverage-html --coverage-xml +``` + +You can see code coverage output under the `tests/_output` directory. + +###Remote code coverage + +When you run your tests not in the same process where code coverage is collected, then you should uncomment `remote` option and its +related options, to be able to collect code coverage correctly. To setup remote code coverage you should follow [instructions](http://codeception.com/docs/11-Codecoverage) +from codeception site. + +1. install `Codeception c3` remote support `composer require "codeception/c3:*"`; + +2. copy `c3.php` file under your `web` directory; + +3. include `c3.php` file in your `index-test.php` file before application run, so it can catch needed requests. + +4. edit `c3.php` to update config file path (~ line 55) with `$config_file = realpath(__DIR__ . '/../tests/codeception.yml');` + +Configuration options that are used by remote code coverage: + +- c3_url: url pointing to entry script that includes `c3.php` file, so `Codeception` will be able to produce code coverage; +- remote: whether to enable remote code coverage or not; +- remote_config: path to the `codeception.yml` configuration file, from the directory where `c3.php` file is located. This is needed + so that `Codeception` can create itself instance and collect code coverage correctly. + +By default `c3_url` and `remote_config` setup correctly, you only need to copy and include `c3.php` file in your `index-test.php` + +After that you should be able to collect code coverage from tests that run through `PhpBrowser` or `WebDriver` with same command +as for other tests: + +``` +#collect coverage from remote +codecept run acceptance --coverage-html --coverage-xml +``` + +Please refer to [Codeception tutorial](http://codeception.com/docs/01-Introduction) for +more details about writing and running acceptance, functional and unit tests. diff --git a/tests/codeception.yml b/tests/codeception.yml new file mode 100644 index 0000000..b71ba31 --- /dev/null +++ b/tests/codeception.yml @@ -0,0 +1,36 @@ +actor: Tester +#coverage: +# #c3_url: http://localhost:8080/index-test.php/ +# enabled: true +# #remote: true +# #remote_config: '../tests/codeception.yml' +# white_list: +# include: +# - ../models/* +# - ../controllers/* +# - ../commands/* +# - ../mail/* +# blacklist: +# include: +# - ../assets/* +# - ../config/* +# - ../runtime/* +# - ../vendor/* +# - ../views/* +# - ../web/* +# - ../tests/* +paths: + tests: codeception + log: codeception/_output + data: codeception/_data + helpers: codeception/_support +settings: + bootstrap: _bootstrap.php + suite_class: \PHPUnit_Framework_TestSuite + memory_limit: 1024M + log: true + colors: true +config: + # the entry script URL (with host info) for functional and acceptance tests + # PLEASE ADJUST IT TO THE ACTUAL ENTRY SCRIPT URL + test_entry_url: http://localhost:8080/index-test.php \ No newline at end of file diff --git a/tests/codeception/.gitignore b/tests/codeception/.gitignore new file mode 100644 index 0000000..985dbb4 --- /dev/null +++ b/tests/codeception/.gitignore @@ -0,0 +1,4 @@ +# these files are auto generated by codeception build +/unit/UnitTester.php +/functional/FunctionalTester.php +/acceptance/AcceptanceTester.php diff --git a/tests/codeception/_bootstrap.php b/tests/codeception/_bootstrap.php new file mode 100644 index 0000000..755029e --- /dev/null +++ b/tests/codeception/_bootstrap.php @@ -0,0 +1,16 @@ + $value) { + $inputType = $field === 'body' ? 'textarea' : 'input'; + $this->actor->fillField($inputType . '[name="ContactForm[' . $field . ']"]', $value); + } + $this->actor->click('contact-button'); + } +} diff --git a/tests/codeception/_pages/LoginPage.php b/tests/codeception/_pages/LoginPage.php new file mode 100644 index 0000000..c3a2ef2 --- /dev/null +++ b/tests/codeception/_pages/LoginPage.php @@ -0,0 +1,25 @@ +actor->fillField('input[name="LoginForm[username]"]', $username); + $this->actor->fillField('input[name="LoginForm[password]"]', $password); + $this->actor->click('login-button'); + } +} diff --git a/tests/codeception/acceptance.suite.yml b/tests/codeception/acceptance.suite.yml new file mode 100644 index 0000000..1781b00 --- /dev/null +++ b/tests/codeception/acceptance.suite.yml @@ -0,0 +1,27 @@ +# Codeception Test Suite Configuration + +# suite for acceptance tests. +# perform tests in browser using the Selenium-like tools. +# powered by Mink (http://mink.behat.org). +# (tip: that's what your customer will see). +# (tip: test your ajax and javascript by one of Mink drivers). + +# RUN `build` COMMAND AFTER ADDING/REMOVING MODULES. + +class_name: AcceptanceTester +modules: + enabled: + - PhpBrowser +# you can use WebDriver instead of PhpBrowser to test javascript and ajax. +# This will require you to install selenium. See http://codeception.com/docs/04-AcceptanceTests#Selenium +# "restart" option is used by the WebDriver to start each time per test-file new session and cookies, +# it is useful if you want to login in your app in each test. +# - WebDriver + config: + PhpBrowser: +# PLEASE ADJUST IT TO THE ACTUAL ENTRY POINT WITHOUT PATH INFO + url: http://localhost:8080 +# WebDriver: +# url: http://localhost:8080 +# browser: firefox +# restart: true diff --git a/tests/codeception/acceptance/AboutCept.php b/tests/codeception/acceptance/AboutCept.php new file mode 100644 index 0000000..88a5506 --- /dev/null +++ b/tests/codeception/acceptance/AboutCept.php @@ -0,0 +1,10 @@ +wantTo('ensure that about works'); +AboutPage::openBy($I); +$I->see('About', 'h1'); diff --git a/tests/codeception/acceptance/ContactCept.php b/tests/codeception/acceptance/ContactCept.php new file mode 100644 index 0000000..f848443 --- /dev/null +++ b/tests/codeception/acceptance/ContactCept.php @@ -0,0 +1,57 @@ +wantTo('ensure that contact works'); + +$contactPage = ContactPage::openBy($I); + +$I->see('Contact', 'h1'); + +$I->amGoingTo('submit contact form with no data'); +$contactPage->submit([]); +if (method_exists($I, 'wait')) { + $I->wait(3); // only for selenium +} +$I->expectTo('see validations errors'); +$I->see('Contact', 'h1'); +$I->see('Name cannot be blank'); +$I->see('Email cannot be blank'); +$I->see('Subject cannot be blank'); +$I->see('Body cannot be blank'); +$I->see('The verification code is incorrect'); + +$I->amGoingTo('submit contact form with not correct email'); +$contactPage->submit([ + 'name' => 'tester', + 'email' => 'tester.email', + 'subject' => 'test subject', + 'body' => 'test content', + 'verifyCode' => 'testme', +]); +if (method_exists($I, 'wait')) { + $I->wait(3); // only for selenium +} +$I->expectTo('see that email address is wrong'); +$I->dontSee('Name cannot be blank', '.help-inline'); +$I->see('Email is not a valid email address.'); +$I->dontSee('Subject cannot be blank', '.help-inline'); +$I->dontSee('Body cannot be blank', '.help-inline'); +$I->dontSee('The verification code is incorrect', '.help-inline'); + +$I->amGoingTo('submit contact form with correct data'); +$contactPage->submit([ + 'name' => 'tester', + 'email' => 'tester@example.com', + 'subject' => 'test subject', + 'body' => 'test content', + 'verifyCode' => 'testme', +]); +if (method_exists($I, 'wait')) { + $I->wait(3); // only for selenium +} +$I->dontSeeElement('#contact-form'); +$I->see('Thank you for contacting us. We will respond to you as soon as possible.'); diff --git a/tests/codeception/acceptance/HomeCept.php b/tests/codeception/acceptance/HomeCept.php new file mode 100644 index 0000000..1f93535 --- /dev/null +++ b/tests/codeception/acceptance/HomeCept.php @@ -0,0 +1,11 @@ +wantTo('ensure that home page works'); +$I->amOnPage(Yii::$app->homeUrl); +$I->see('My Company'); +$I->seeLink('About'); +$I->click('About'); +$I->see('This is the About page.'); diff --git a/tests/codeception/acceptance/LoginCept.php b/tests/codeception/acceptance/LoginCept.php new file mode 100644 index 0000000..90d0635 --- /dev/null +++ b/tests/codeception/acceptance/LoginCept.php @@ -0,0 +1,37 @@ +wantTo('ensure that login works'); + +$loginPage = LoginPage::openBy($I); + +$I->see('Login', 'h1'); + +$I->amGoingTo('try to login with empty credentials'); +$loginPage->login('', ''); +if (method_exists($I, 'wait')) { + $I->wait(3); // only for selenium +} +$I->expectTo('see validations errors'); +$I->see('Username cannot be blank.'); +$I->see('Password cannot be blank.'); + +$I->amGoingTo('try to login with wrong credentials'); +$loginPage->login('admin', 'wrong'); +if (method_exists($I, 'wait')) { + $I->wait(3); // only for selenium +} +$I->expectTo('see validations errors'); +$I->see('Incorrect username or password.'); + +$I->amGoingTo('try to login with correct credentials'); +$loginPage->login('admin', 'admin'); +if (method_exists($I, 'wait')) { + $I->wait(3); // only for selenium +} +$I->expectTo('see user info'); +$I->see('Logout (admin)'); diff --git a/tests/codeception/acceptance/_bootstrap.php b/tests/codeception/acceptance/_bootstrap.php new file mode 100644 index 0000000..36f9f1d --- /dev/null +++ b/tests/codeception/acceptance/_bootstrap.php @@ -0,0 +1,2 @@ +run(); +exit($exitCode); diff --git a/tests/codeception/bin/yii.bat b/tests/codeception/bin/yii.bat new file mode 100644 index 0000000..d516b3a --- /dev/null +++ b/tests/codeception/bin/yii.bat @@ -0,0 +1,20 @@ +@echo off + +rem ------------------------------------------------------------- +rem Yii command line bootstrap script for Windows. +rem +rem @author Qiang Xue +rem @link http://www.yiiframework.com/ +rem @copyright Copyright (c) 2008 Yii Software LLC +rem @license http://www.yiiframework.com/license/ +rem ------------------------------------------------------------- + +@setlocal + +set YII_PATH=%~dp0 + +if "%PHP_COMMAND%" == "" set PHP_COMMAND=php.exe + +"%PHP_COMMAND%" "%YII_PATH%yii" %* + +@endlocal diff --git a/tests/codeception/config/acceptance.php b/tests/codeception/config/acceptance.php new file mode 100644 index 0000000..c688575 --- /dev/null +++ b/tests/codeception/config/acceptance.php @@ -0,0 +1,11 @@ + 'en-US', + 'controllerMap' => [ + 'fixture' => [ + 'class' => 'yii\faker\FixtureController', + 'fixtureDataPath' => '@tests/codeception/fixtures', + 'templatePath' => '@tests/codeception/templates', + 'namespace' => 'tests\codeception\fixtures', + ], + ], + 'components' => [ + 'db' => [ + 'dsn' => 'mysql:host=localhost;dbname=yii2_basic_tests', + ], + 'mailer' => [ + 'useFileTransport' => true, + ], + 'urlManager' => [ + 'showScriptName' => true, + ], + ], +]; diff --git a/tests/codeception/config/functional.php b/tests/codeception/config/functional.php new file mode 100644 index 0000000..6d22bd9 --- /dev/null +++ b/tests/codeception/config/functional.php @@ -0,0 +1,25 @@ + [ + 'request' => [ + // it's not recommended to run functional tests with CSRF validation enabled + 'enableCsrfValidation' => false, + // but if you absolutely need it set cookie domain to localhost + /* + 'csrfCookie' => [ + 'domain' => 'localhost', + ], + */ + ], + ], + ] +); diff --git a/tests/codeception/config/unit.php b/tests/codeception/config/unit.php new file mode 100644 index 0000000..5bab5ea --- /dev/null +++ b/tests/codeception/config/unit.php @@ -0,0 +1,11 @@ +wantTo('ensure that about works'); +AboutPage::openBy($I); +$I->see('About', 'h1'); diff --git a/tests/codeception/functional/ContactCept.php b/tests/codeception/functional/ContactCept.php new file mode 100644 index 0000000..b17a757 --- /dev/null +++ b/tests/codeception/functional/ContactCept.php @@ -0,0 +1,48 @@ +wantTo('ensure that contact works'); + +$contactPage = ContactPage::openBy($I); + +$I->see('Contact', 'h1'); + +$I->amGoingTo('submit contact form with no data'); +$contactPage->submit([]); +$I->expectTo('see validations errors'); +$I->see('Contact', 'h1'); +$I->see('Name cannot be blank'); +$I->see('Email cannot be blank'); +$I->see('Subject cannot be blank'); +$I->see('Body cannot be blank'); +$I->see('The verification code is incorrect'); + +$I->amGoingTo('submit contact form with not correct email'); +$contactPage->submit([ + 'name' => 'tester', + 'email' => 'tester.email', + 'subject' => 'test subject', + 'body' => 'test content', + 'verifyCode' => 'testme', +]); +$I->expectTo('see that email address is wrong'); +$I->dontSee('Name cannot be blank', '.help-inline'); +$I->see('Email is not a valid email address.'); +$I->dontSee('Subject cannot be blank', '.help-inline'); +$I->dontSee('Body cannot be blank', '.help-inline'); +$I->dontSee('The verification code is incorrect', '.help-inline'); + +$I->amGoingTo('submit contact form with correct data'); +$contactPage->submit([ + 'name' => 'tester', + 'email' => 'tester@example.com', + 'subject' => 'test subject', + 'body' => 'test content', + 'verifyCode' => 'testme', +]); +$I->dontSeeElement('#contact-form'); +$I->see('Thank you for contacting us. We will respond to you as soon as possible.'); diff --git a/tests/codeception/functional/HomeCept.php b/tests/codeception/functional/HomeCept.php new file mode 100644 index 0000000..94efb09 --- /dev/null +++ b/tests/codeception/functional/HomeCept.php @@ -0,0 +1,11 @@ +wantTo('ensure that home page works'); +$I->amOnPage(Yii::$app->homeUrl); +$I->see('My Company'); +$I->seeLink('About'); +$I->click('About'); +$I->see('This is the About page.'); diff --git a/tests/codeception/functional/LoginCept.php b/tests/codeception/functional/LoginCept.php new file mode 100644 index 0000000..66e7609 --- /dev/null +++ b/tests/codeception/functional/LoginCept.php @@ -0,0 +1,28 @@ +wantTo('ensure that login works'); + +$loginPage = LoginPage::openBy($I); + +$I->see('Login', 'h1'); + +$I->amGoingTo('try to login with empty credentials'); +$loginPage->login('', ''); +$I->expectTo('see validations errors'); +$I->see('Username cannot be blank.'); +$I->see('Password cannot be blank.'); + +$I->amGoingTo('try to login with wrong credentials'); +$loginPage->login('admin', 'wrong'); +$I->expectTo('see validations errors'); +$I->see('Incorrect username or password.'); + +$I->amGoingTo('try to login with correct credentials'); +$loginPage->login('admin', 'admin'); +$I->expectTo('see user info'); +$I->see('Logout (admin)'); diff --git a/tests/codeception/functional/_bootstrap.php b/tests/codeception/functional/_bootstrap.php new file mode 100644 index 0000000..8aac091 --- /dev/null +++ b/tests/codeception/functional/_bootstrap.php @@ -0,0 +1,2 @@ +mailer->fileTransportCallback = function ($mailer, $message) { + return 'testing_message.eml'; + }; + } + + protected function tearDown() + { + unlink($this->getMessageFile()); + parent::tearDown(); + } + + public function testContact() + { + $model = $this->getMock('app\models\ContactForm', ['validate']); + $model->expects($this->once())->method('validate')->will($this->returnValue(true)); + + $model->attributes = [ + 'name' => 'Tester', + 'email' => 'tester@example.com', + 'subject' => 'very important letter subject', + 'body' => 'body of current message', + ]; + + $model->contact('admin@example.com'); + + $this->specify('email should be send', function () { + expect('email file should exist', file_exists($this->getMessageFile()))->true(); + }); + + $this->specify('message should contain correct data', function () use ($model) { + $emailMessage = file_get_contents($this->getMessageFile()); + + expect('email should contain user name', $emailMessage)->contains($model->name); + expect('email should contain sender email', $emailMessage)->contains($model->email); + expect('email should contain subject', $emailMessage)->contains($model->subject); + expect('email should contain body', $emailMessage)->contains($model->body); + }); + } + + private function getMessageFile() + { + return Yii::getAlias(Yii::$app->mailer->fileTransportPath) . '/testing_message.eml'; + } + +} diff --git a/tests/codeception/unit/models/LoginFormTest.php b/tests/codeception/unit/models/LoginFormTest.php new file mode 100644 index 0000000..c7f971a --- /dev/null +++ b/tests/codeception/unit/models/LoginFormTest.php @@ -0,0 +1,61 @@ +user->logout(); + parent::tearDown(); + } + + public function testLoginNoUser() + { + $model = new LoginForm([ + 'username' => 'not_existing_username', + 'password' => 'not_existing_password', + ]); + + $this->specify('user should not be able to login, when there is no identity', function () use ($model) { + expect('model should not login user', $model->login())->false(); + expect('user should not be logged in', Yii::$app->user->isGuest)->true(); + }); + } + + public function testLoginWrongPassword() + { + $model = new LoginForm([ + 'username' => 'demo', + 'password' => 'wrong_password', + ]); + + $this->specify('user should not be able to login with wrong password', function () use ($model) { + expect('model should not login user', $model->login())->false(); + expect('error message should be set', $model->errors)->hasKey('password'); + expect('user should not be logged in', Yii::$app->user->isGuest)->true(); + }); + } + + public function testLoginCorrect() + { + $model = new LoginForm([ + 'username' => 'demo', + 'password' => 'demo', + ]); + + $this->specify('user should be able to login with correct credentials', function () use ($model) { + expect('model should login user', $model->login())->true(); + expect('error message should not be set', $model->errors)->hasntKey('password'); + expect('user should be logged in', Yii::$app->user->isGuest)->false(); + }); + } + +} diff --git a/tests/codeception/unit/models/UserTest.php b/tests/codeception/unit/models/UserTest.php new file mode 100644 index 0000000..f4f4f4b --- /dev/null +++ b/tests/codeception/unit/models/UserTest.php @@ -0,0 +1,17 @@ +loadFixtures(['user']); + } + + // TODO add test methods here +} diff --git a/tests/codeception/unit/templates/fixtures/.gitkeep b/tests/codeception/unit/templates/fixtures/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/views/layouts/main.php b/views/layouts/main.php new file mode 100644 index 0000000..2974d6d --- /dev/null +++ b/views/layouts/main.php @@ -0,0 +1,78 @@ + +beginPage() ?> + + + + + + + <?= Html::encode($this->title) ?> + head() ?> + + +beginBody() ?> + +
+ 'My Company', + 'brandUrl' => Yii::$app->homeUrl, + 'options' => [ + 'class' => 'navbar-inverse navbar-fixed-top', + ], + ]); + echo Nav::widget([ + 'options' => ['class' => 'navbar-nav navbar-right'], + 'items' => [ + ['label' => 'Home', 'url' => ['/site/index']], + ['label' => 'About', 'url' => ['/site/about']], + ['label' => 'Contact', 'url' => ['/site/contact']], + Yii::$app->user->isGuest ? ( + ['label' => 'Login', 'url' => ['/site/login']] + ) : ( + '
  • ' + . Html::beginForm(['/site/logout'], 'post', ['class' => 'navbar-form']) + . Html::submitButton( + 'Logout (' . Yii::$app->user->identity->username . ')', + ['class' => 'btn btn-link'] + ) + . Html::endForm() + . '
  • ' + ) + ], + ]); + NavBar::end(); + ?> + +
    + isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : [], + ]) ?> + +
    +
    + +
    +
    +

    © My Company

    + +

    +
    +
    + +endBody() ?> + + +endPage() ?> diff --git a/views/site/about.php b/views/site/about.php new file mode 100644 index 0000000..68d5cf3 --- /dev/null +++ b/views/site/about.php @@ -0,0 +1,18 @@ +title = 'About'; +$this->params['breadcrumbs'][] = $this->title; +?> +
    +

    title) ?>

    + +

    + This is the About page. You may modify the following file to customize its content: +

    + + +
    diff --git a/views/site/contact.php b/views/site/contact.php new file mode 100644 index 0000000..b988409 --- /dev/null +++ b/views/site/contact.php @@ -0,0 +1,68 @@ +title = 'Contact'; +$this->params['breadcrumbs'][] = $this->title; +?> +
    +

    title) ?>

    + + session->hasFlash('contactFormSubmitted')): ?> + +
    + Thank you for contacting us. We will respond to you as soon as possible. +
    + +

    + Note that if you turn on the Yii debugger, you should be able + to view the mail message on the mail panel of the debugger. + mailer->useFileTransport): ?> + Because the application is in development mode, the email is not sent but saved as + a file under mailer->fileTransportPath) ?>. + Please configure the useFileTransport property of the mail + application component to be false to enable email sending. + +

    + + + +

    + If you have business inquiries or other questions, please fill out the following form to contact us. + Thank you. +

    + +
    +
    + + 'contact-form']); ?> + + field($model, 'name')->textInput(['autofocus' => true]) ?> + + field($model, 'email') ?> + + field($model, 'subject') ?> + + field($model, 'body')->textArea(['rows' => 6]) ?> + + field($model, 'verifyCode')->widget(Captcha::className(), [ + 'template' => '
    {image}
    {input}
    ', + ]) ?> + +
    + 'btn btn-primary', 'name' => 'contact-button']) ?> +
    + + + +
    +
    + + +
    diff --git a/views/site/error.php b/views/site/error.php new file mode 100644 index 0000000..0ba2574 --- /dev/null +++ b/views/site/error.php @@ -0,0 +1,27 @@ +title = $name; +?> +
    + +

    title) ?>

    + +
    + +
    + +

    + The above error occurred while the Web server was processing your request. +

    +

    + Please contact us if you think this is a server error. Thank you. +

    + +
    diff --git a/views/site/index.php b/views/site/index.php new file mode 100644 index 0000000..f780610 --- /dev/null +++ b/views/site/index.php @@ -0,0 +1,53 @@ +title = 'My Yii Application'; +?> +
    + +
    +

    Congratulations!

    + +

    You have successfully created your Yii-powered application.

    + +

    Get started with Yii

    +
    + +
    + +
    +
    +

    Heading

    + +

    Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et + dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip + ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu + fugiat nulla pariatur.

    + +

    Yii Documentation »

    +
    +
    +

    Heading

    + +

    Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et + dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip + ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu + fugiat nulla pariatur.

    + +

    Yii Forum »

    +
    +
    +

    Heading

    + +

    Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et + dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip + ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu + fugiat nulla pariatur.

    + +

    Yii Extensions »

    +
    +
    + +
    +
    diff --git a/views/site/login.php b/views/site/login.php new file mode 100644 index 0000000..498f46f --- /dev/null +++ b/views/site/login.php @@ -0,0 +1,47 @@ +title = 'Login'; +$this->params['breadcrumbs'][] = $this->title; +?> + diff --git a/web/assets/.gitignore b/web/assets/.gitignore new file mode 100644 index 0000000..d6b7ef3 --- /dev/null +++ b/web/assets/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore diff --git a/web/css/site.css b/web/css/site.css new file mode 100644 index 0000000..698be70 --- /dev/null +++ b/web/css/site.css @@ -0,0 +1,91 @@ +html, +body { + height: 100%; +} + +.wrap { + min-height: 100%; + height: auto; + margin: 0 auto -60px; + padding: 0 0 60px; +} + +.wrap > .container { + padding: 70px 15px 20px; +} + +.footer { + height: 60px; + background-color: #f5f5f5; + border-top: 1px solid #ddd; + padding-top: 20px; +} + +.jumbotron { + text-align: center; + background-color: transparent; +} + +.jumbotron .btn { + font-size: 21px; + padding: 14px 24px; +} + +.not-set { + color: #c55; + font-style: italic; +} + +/* add sorting icons to gridview sort links */ +a.asc:after, a.desc:after { + position: relative; + top: 1px; + display: inline-block; + font-family: 'Glyphicons Halflings'; + font-style: normal; + font-weight: normal; + line-height: 1; + padding-left: 5px; +} + +a.asc:after { + content: /*"\e113"*/ "\e151"; +} + +a.desc:after { + content: /*"\e114"*/ "\e152"; +} + +.sort-numerical a.asc:after { + content: "\e153"; +} + +.sort-numerical a.desc:after { + content: "\e154"; +} + +.sort-ordinal a.asc:after { + content: "\e155"; +} + +.sort-ordinal a.desc:after { + content: "\e156"; +} + +.grid-view th { + white-space: nowrap; +} + +.hint-block { + display: block; + margin-top: 5px; + color: #999; +} + +.error-summary { + color: #a94442; + background: #fdf7f7; + border-left: 3px solid #eed3d7; + padding: 10px 20px; + margin: 0 0 15px 0; +} diff --git a/web/favicon.ico b/web/favicon.ico new file mode 100644 index 0000000000000000000000000000000000000000..580ed732e86556ec57f3f3395a210246d679c076 GIT binary patch literal 318 zcmZQzU<5(|0RbS%!l1#(z#zuJz@P!d0zj+)#2|4HXaJKC0wf0lAEr2iX{M9K3=BR0 y!E90pK{x=K$Oz&POT#sS8N$ZKhC)h8ip0_|-T#43{vnSYgXBQCu@O54$pHYIza?e> literal 0 HcmV?d00001 diff --git a/web/index-test.php b/web/index-test.php new file mode 100644 index 0000000..32b4ce3 --- /dev/null +++ b/web/index-test.php @@ -0,0 +1,16 @@ +run(); diff --git a/web/index.php b/web/index.php new file mode 100644 index 0000000..32b4ce3 --- /dev/null +++ b/web/index.php @@ -0,0 +1,16 @@ +run(); diff --git a/web/index_prod.php b/web/index_prod.php new file mode 100644 index 0000000..7a8e1a5 --- /dev/null +++ b/web/index_prod.php @@ -0,0 +1,12 @@ +run(); diff --git a/web/robots.txt b/web/robots.txt new file mode 100644 index 0000000..6f27bb6 --- /dev/null +++ b/web/robots.txt @@ -0,0 +1,2 @@ +User-agent: * +Disallow: \ No newline at end of file diff --git a/yii b/yii new file mode 100644 index 0000000..fc7090f --- /dev/null +++ b/yii @@ -0,0 +1,21 @@ +#!/usr/bin/env php +run(); +exit($exitCode); diff --git a/yii.bat b/yii.bat new file mode 100644 index 0000000..d516b3a --- /dev/null +++ b/yii.bat @@ -0,0 +1,20 @@ +@echo off + +rem ------------------------------------------------------------- +rem Yii command line bootstrap script for Windows. +rem +rem @author Qiang Xue +rem @link http://www.yiiframework.com/ +rem @copyright Copyright (c) 2008 Yii Software LLC +rem @license http://www.yiiframework.com/license/ +rem ------------------------------------------------------------- + +@setlocal + +set YII_PATH=%~dp0 + +if "%PHP_COMMAND%" == "" set PHP_COMMAND=php.exe + +"%PHP_COMMAND%" "%YII_PATH%yii" %* + +@endlocal