yii composer install
This commit is contained in:
parent
e766ab1edf
commit
9c1fafe366
27
.gitignore
vendored
27
.gitignore
vendored
@ -1,2 +1,27 @@
|
||||
# phpstorm project files
|
||||
.idea
|
||||
*.secret
|
||||
|
||||
# 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
|
||||
|
32
LICENSE.md
Normal file
32
LICENSE.md
Normal file
@ -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.
|
102
README.md
Normal file
102
README.md
Normal file
@ -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' => '<secret random string goes here>',
|
||||
],
|
||||
```
|
||||
|
||||
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.
|
29
assets/AppAsset.php
Normal file
29
assets/AppAsset.php
Normal file
@ -0,0 +1,29 @@
|
||||
<?php
|
||||
/**
|
||||
* @link http://www.yiiframework.com/
|
||||
* @copyright Copyright (c) 2008 Yii Software LLC
|
||||
* @license http://www.yiiframework.com/license/
|
||||
*/
|
||||
|
||||
namespace app\assets;
|
||||
|
||||
use yii\web\AssetBundle;
|
||||
|
||||
/**
|
||||
* @author Qiang Xue <qiang.xue@gmail.com>
|
||||
* @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',
|
||||
];
|
||||
}
|
30
commands/HelloController.php
Normal file
30
commands/HelloController.php
Normal file
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
/**
|
||||
* @link http://www.yiiframework.com/
|
||||
* @copyright Copyright (c) 2008 Yii Software LLC
|
||||
* @license http://www.yiiframework.com/license/
|
||||
*/
|
||||
|
||||
namespace app\commands;
|
||||
|
||||
use yii\console\Controller;
|
||||
|
||||
/**
|
||||
* This command echoes the first argument that you have entered.
|
||||
*
|
||||
* This command is provided as an example for you to learn how to create console commands.
|
||||
*
|
||||
* @author Qiang Xue <qiang.xue@gmail.com>
|
||||
* @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";
|
||||
}
|
||||
}
|
54
composer.json
Normal file
54
composer.json
Normal file
@ -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"
|
||||
}
|
||||
}
|
||||
}
|
913
composer.lock
generated
Normal file
913
composer.lock
generated
Normal file
@ -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": []
|
||||
}
|
45
config/console.php
Normal file
45
config/console.php
Normal file
@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
Yii::setAlias('@tests', dirname(__DIR__) . '/tests/codeception');
|
||||
|
||||
$params = require(__DIR__ . '/params.php');
|
||||
$db = require(__DIR__ . '/db.php');
|
||||
|
||||
$config = [
|
||||
'id' => '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;
|
9
config/db.php
Normal file
9
config/db.php
Normal file
@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
'class' => 'yii\db\Connection',
|
||||
'dsn' => 'mysql:host=localhost;dbname=yii2basic',
|
||||
'username' => 'root',
|
||||
'password' => '',
|
||||
'charset' => 'utf8',
|
||||
];
|
5
config/params.php
Normal file
5
config/params.php
Normal file
@ -0,0 +1,5 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
'adminEmail' => 'admin@example.com',
|
||||
];
|
66
config/web.php
Normal file
66
config/web.php
Normal file
@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
$params = require(__DIR__ . '/params.php');
|
||||
|
||||
$config = [
|
||||
'id' => '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;
|
94
controllers/SiteController.php
Normal file
94
controllers/SiteController.php
Normal file
@ -0,0 +1,94 @@
|
||||
<?php
|
||||
|
||||
namespace app\controllers;
|
||||
|
||||
use Yii;
|
||||
use yii\filters\AccessControl;
|
||||
use yii\web\Controller;
|
||||
use yii\filters\VerbFilter;
|
||||
use app\models\LoginForm;
|
||||
use app\models\ContactForm;
|
||||
|
||||
class SiteController extends Controller
|
||||
{
|
||||
public function behaviors()
|
||||
{
|
||||
return [
|
||||
'access' => [
|
||||
'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');
|
||||
}
|
||||
}
|
22
mail/layouts/html.php
Normal file
22
mail/layouts/html.php
Normal file
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
use yii\helpers\Html;
|
||||
|
||||
/* @var $this \yii\web\View view component instance */
|
||||
/* @var $message \yii\mail\MessageInterface the message being composed */
|
||||
/* @var $content string main view render result */
|
||||
?>
|
||||
<?php $this->beginPage() ?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=<?= Yii::$app->charset ?>" />
|
||||
<title><?= Html::encode($this->title) ?></title>
|
||||
<?php $this->head() ?>
|
||||
</head>
|
||||
<body>
|
||||
<?php $this->beginBody() ?>
|
||||
<?= $content ?>
|
||||
<?php $this->endBody() ?>
|
||||
</body>
|
||||
</html>
|
||||
<?php $this->endPage() ?>
|
64
models/ContactForm.php
Normal file
64
models/ContactForm.php
Normal file
@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
namespace app\models;
|
||||
|
||||
use Yii;
|
||||
use yii\base\Model;
|
||||
|
||||
/**
|
||||
* ContactForm is the model behind the contact form.
|
||||
*/
|
||||
class ContactForm extends Model
|
||||
{
|
||||
public $name;
|
||||
public $email;
|
||||
public $subject;
|
||||
public $body;
|
||||
public $verifyCode;
|
||||
|
||||
|
||||
/**
|
||||
* @return array the validation rules.
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
// name, email, subject and body are required
|
||||
[['name', 'email', 'subject', 'body'], 'required'],
|
||||
// email has to be a valid email address
|
||||
['email', 'email'],
|
||||
// verifyCode needs to be entered correctly
|
||||
['verifyCode', 'captcha'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array customized attribute labels
|
||||
*/
|
||||
public function attributeLabels()
|
||||
{
|
||||
return [
|
||||
'verifyCode' => '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;
|
||||
}
|
||||
}
|
81
models/LoginForm.php
Normal file
81
models/LoginForm.php
Normal file
@ -0,0 +1,81 @@
|
||||
<?php
|
||||
|
||||
namespace app\models;
|
||||
|
||||
use Yii;
|
||||
use yii\base\Model;
|
||||
|
||||
/**
|
||||
* LoginForm is the model behind the login form.
|
||||
*
|
||||
* @property User|null $user This property is read-only.
|
||||
*
|
||||
*/
|
||||
class LoginForm extends Model
|
||||
{
|
||||
public $username;
|
||||
public $password;
|
||||
public $rememberMe = true;
|
||||
|
||||
private $_user = false;
|
||||
|
||||
|
||||
/**
|
||||
* @return array the validation rules.
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
// username and password are both required
|
||||
[['username', 'password'], 'required'],
|
||||
// rememberMe must be a boolean value
|
||||
['rememberMe', 'boolean'],
|
||||
// password is validated by validatePassword()
|
||||
['password', 'validatePassword'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the password.
|
||||
* This method serves as the inline validation for password.
|
||||
*
|
||||
* @param string $attribute the attribute currently being validated
|
||||
* @param array $params the additional name-value pairs given in the rule
|
||||
*/
|
||||
public function validatePassword($attribute, $params)
|
||||
{
|
||||
if (!$this->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;
|
||||
}
|
||||
}
|
104
models/User.php
Normal file
104
models/User.php
Normal file
@ -0,0 +1,104 @@
|
||||
<?php
|
||||
|
||||
namespace app\models;
|
||||
|
||||
class User extends \yii\base\Object implements \yii\web\IdentityInterface
|
||||
{
|
||||
public $id;
|
||||
public $username;
|
||||
public $password;
|
||||
public $authKey;
|
||||
public $accessToken;
|
||||
|
||||
private static $users = [
|
||||
'100' => [
|
||||
'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;
|
||||
}
|
||||
}
|
137
requirements.php
Normal file
137
requirements.php
Normal file
@ -0,0 +1,137 @@
|
||||
<?php
|
||||
/**
|
||||
* Application requirement checker script.
|
||||
*
|
||||
* In order to run this script use the following console command:
|
||||
* php requirements.php
|
||||
*
|
||||
* In order to run this script from the web, you should copy it to the web root.
|
||||
* If you are using Linux you can create a hard link instead, using the following command:
|
||||
* ln requirements.php ../requirements.php
|
||||
*/
|
||||
|
||||
// you may need to adjust this path to the correct Yii framework path
|
||||
$frameworkPath = dirname(__FILE__) . '/vendor/yiisoft/yii2';
|
||||
|
||||
if (!is_dir($frameworkPath)) {
|
||||
echo '<h1>Error</h1>';
|
||||
echo '<p><strong>The path to yii framework seems to be incorrect.</strong></p>';
|
||||
echo '<p>You need to install Yii framework via composer or adjust the framework path in file <abbr title="' . __FILE__ . '">' . basename(__FILE__) . '</abbr>.</p>';
|
||||
echo '<p>Please refer to the <abbr title="' . dirname(__FILE__) . '/README.md">README</abbr> on how to install Yii.</p>';
|
||||
}
|
||||
|
||||
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' => '<a href="http://www.yiiframework.com/doc-2.0/yii-caching-memcache.html">MemCache</a>',
|
||||
'memo' => extension_loaded('memcached') ? 'To use memcached set <a href="http://www.yiiframework.com/doc-2.0/yii-caching-memcache.html#$useMemcached-detail">MemCache::useMemcached</a> to <code>true</code>.' : ''
|
||||
),
|
||||
// CAPTCHA:
|
||||
array(
|
||||
'name' => 'GD PHP extension with FreeType support',
|
||||
'mandatory' => false,
|
||||
'condition' => $gdOK,
|
||||
'by' => '<a href="http://www.yiiframework.com/doc-2.0/yii-captcha-captcha.html">Captcha</a>',
|
||||
'memo' => $gdMemo,
|
||||
),
|
||||
array(
|
||||
'name' => 'ImageMagick PHP extension with PNG support',
|
||||
'mandatory' => false,
|
||||
'condition' => $imagickOK,
|
||||
'by' => '<a href="http://www.yiiframework.com/doc-2.0/yii-captcha-captcha.html">Captcha</a>',
|
||||
'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' => '<a href="http://www.yiiframework.com/doc-2.0/yii-caching-apccache.html">ApcCache</a>',
|
||||
);
|
||||
}
|
||||
|
||||
$requirementsChecker->checkYii()->check($requirements)->render();
|
2
runtime/.gitignore
vendored
Normal file
2
runtime/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
*
|
||||
!.gitignore
|
127
tests/README.md
Normal file
127
tests/README.md
Normal file
@ -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 <directory>
|
||||
```
|
||||
|
||||
Then add `<directory>/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.
|
36
tests/codeception.yml
Normal file
36
tests/codeception.yml
Normal file
@ -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
|
4
tests/codeception/.gitignore
vendored
Normal file
4
tests/codeception/.gitignore
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
# these files are auto generated by codeception build
|
||||
/unit/UnitTester.php
|
||||
/functional/FunctionalTester.php
|
||||
/acceptance/AcceptanceTester.php
|
16
tests/codeception/_bootstrap.php
Normal file
16
tests/codeception/_bootstrap.php
Normal file
@ -0,0 +1,16 @@
|
||||
<?php
|
||||
defined('YII_DEBUG') or define('YII_DEBUG', true);
|
||||
defined('YII_ENV') or define('YII_ENV', 'test');
|
||||
|
||||
defined('YII_TEST_ENTRY_URL') or define('YII_TEST_ENTRY_URL', parse_url(\Codeception\Configuration::config()['config']['test_entry_url'], PHP_URL_PATH));
|
||||
defined('YII_TEST_ENTRY_FILE') or define('YII_TEST_ENTRY_FILE', dirname(dirname(__DIR__)) . '/web/index-test.php');
|
||||
|
||||
require_once(__DIR__ . '/../../vendor/autoload.php');
|
||||
require_once(__DIR__ . '/../../vendor/yiisoft/yii2/Yii.php');
|
||||
|
||||
$_SERVER['SCRIPT_FILENAME'] = YII_TEST_ENTRY_FILE;
|
||||
$_SERVER['SCRIPT_NAME'] = YII_TEST_ENTRY_URL;
|
||||
$_SERVER['SERVER_NAME'] = parse_url(\Codeception\Configuration::config()['config']['test_entry_url'], PHP_URL_HOST);
|
||||
$_SERVER['SERVER_PORT'] = parse_url(\Codeception\Configuration::config()['config']['test_entry_url'], PHP_URL_PORT) ?: '80';
|
||||
|
||||
Yii::setAlias('@tests', dirname(__DIR__));
|
2
tests/codeception/_output/.gitignore
vendored
Normal file
2
tests/codeception/_output/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
*
|
||||
!.gitignore
|
14
tests/codeception/_pages/AboutPage.php
Normal file
14
tests/codeception/_pages/AboutPage.php
Normal file
@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace tests\codeception\_pages;
|
||||
|
||||
use yii\codeception\BasePage;
|
||||
|
||||
/**
|
||||
* Represents about page
|
||||
* @property \AcceptanceTester|\FunctionalTester $actor
|
||||
*/
|
||||
class AboutPage extends BasePage
|
||||
{
|
||||
public $route = 'site/about';
|
||||
}
|
26
tests/codeception/_pages/ContactPage.php
Normal file
26
tests/codeception/_pages/ContactPage.php
Normal file
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace tests\codeception\_pages;
|
||||
|
||||
use yii\codeception\BasePage;
|
||||
|
||||
/**
|
||||
* Represents contact page
|
||||
* @property \AcceptanceTester|\FunctionalTester $actor
|
||||
*/
|
||||
class ContactPage extends BasePage
|
||||
{
|
||||
public $route = 'site/contact';
|
||||
|
||||
/**
|
||||
* @param array $contactData
|
||||
*/
|
||||
public function submit(array $contactData)
|
||||
{
|
||||
foreach ($contactData as $field => $value) {
|
||||
$inputType = $field === 'body' ? 'textarea' : 'input';
|
||||
$this->actor->fillField($inputType . '[name="ContactForm[' . $field . ']"]', $value);
|
||||
}
|
||||
$this->actor->click('contact-button');
|
||||
}
|
||||
}
|
25
tests/codeception/_pages/LoginPage.php
Normal file
25
tests/codeception/_pages/LoginPage.php
Normal file
@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace tests\codeception\_pages;
|
||||
|
||||
use yii\codeception\BasePage;
|
||||
|
||||
/**
|
||||
* Represents login page
|
||||
* @property \AcceptanceTester|\FunctionalTester $actor
|
||||
*/
|
||||
class LoginPage extends BasePage
|
||||
{
|
||||
public $route = 'site/login';
|
||||
|
||||
/**
|
||||
* @param string $username
|
||||
* @param string $password
|
||||
*/
|
||||
public function login($username, $password)
|
||||
{
|
||||
$this->actor->fillField('input[name="LoginForm[username]"]', $username);
|
||||
$this->actor->fillField('input[name="LoginForm[password]"]', $password);
|
||||
$this->actor->click('login-button');
|
||||
}
|
||||
}
|
27
tests/codeception/acceptance.suite.yml
Normal file
27
tests/codeception/acceptance.suite.yml
Normal file
@ -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
|
10
tests/codeception/acceptance/AboutCept.php
Normal file
10
tests/codeception/acceptance/AboutCept.php
Normal file
@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
use tests\codeception\_pages\AboutPage;
|
||||
|
||||
/* @var $scenario Codeception\Scenario */
|
||||
|
||||
$I = new AcceptanceTester($scenario);
|
||||
$I->wantTo('ensure that about works');
|
||||
AboutPage::openBy($I);
|
||||
$I->see('About', 'h1');
|
57
tests/codeception/acceptance/ContactCept.php
Normal file
57
tests/codeception/acceptance/ContactCept.php
Normal file
@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
use tests\codeception\_pages\ContactPage;
|
||||
|
||||
/* @var $scenario Codeception\Scenario */
|
||||
|
||||
$I = new AcceptanceTester($scenario);
|
||||
$I->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.');
|
11
tests/codeception/acceptance/HomeCept.php
Normal file
11
tests/codeception/acceptance/HomeCept.php
Normal file
@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
/* @var $scenario Codeception\Scenario */
|
||||
|
||||
$I = new AcceptanceTester($scenario);
|
||||
$I->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.');
|
37
tests/codeception/acceptance/LoginCept.php
Normal file
37
tests/codeception/acceptance/LoginCept.php
Normal file
@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
use tests\codeception\_pages\LoginPage;
|
||||
|
||||
/* @var $scenario Codeception\Scenario */
|
||||
|
||||
$I = new AcceptanceTester($scenario);
|
||||
$I->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)');
|
2
tests/codeception/acceptance/_bootstrap.php
Normal file
2
tests/codeception/acceptance/_bootstrap.php
Normal file
@ -0,0 +1,2 @@
|
||||
<?php
|
||||
new yii\web\Application(require(dirname(__DIR__) . '/config/acceptance.php'));
|
10
tests/codeception/bin/_bootstrap.php
Normal file
10
tests/codeception/bin/_bootstrap.php
Normal file
@ -0,0 +1,10 @@
|
||||
<?php
|
||||
defined('YII_DEBUG') or define('YII_DEBUG', true);
|
||||
defined('YII_ENV') or define('YII_ENV', 'test');
|
||||
|
||||
defined('YII_APP_BASE_PATH') or define('YII_APP_BASE_PATH', dirname(dirname(dirname(__DIR__))));
|
||||
|
||||
require(YII_APP_BASE_PATH . '/vendor/autoload.php');
|
||||
require(YII_APP_BASE_PATH . '/vendor/yiisoft/yii2/Yii.php');
|
||||
|
||||
Yii::setAlias('@tests', dirname(dirname(__DIR__)));
|
20
tests/codeception/bin/yii
Normal file
20
tests/codeception/bin/yii
Normal file
@ -0,0 +1,20 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
/**
|
||||
* Yii console bootstrap file.
|
||||
*
|
||||
* @link http://www.yiiframework.com/
|
||||
* @copyright Copyright (c) 2008 Yii Software LLC
|
||||
* @license http://www.yiiframework.com/license/
|
||||
*/
|
||||
|
||||
require_once __DIR__ . '/_bootstrap.php';
|
||||
|
||||
$config = yii\helpers\ArrayHelper::merge(
|
||||
require(YII_APP_BASE_PATH . '/config/console.php'),
|
||||
require(__DIR__ . '/../config/config.php')
|
||||
);
|
||||
|
||||
$application = new yii\console\Application($config);
|
||||
$exitCode = $application->run();
|
||||
exit($exitCode);
|
20
tests/codeception/bin/yii.bat
Normal file
20
tests/codeception/bin/yii.bat
Normal file
@ -0,0 +1,20 @@
|
||||
@echo off
|
||||
|
||||
rem -------------------------------------------------------------
|
||||
rem Yii command line bootstrap script for Windows.
|
||||
rem
|
||||
rem @author Qiang Xue <qiang.xue@gmail.com>
|
||||
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
|
11
tests/codeception/config/acceptance.php
Normal file
11
tests/codeception/config/acceptance.php
Normal file
@ -0,0 +1,11 @@
|
||||
<?php
|
||||
/**
|
||||
* Application configuration for acceptance tests
|
||||
*/
|
||||
return yii\helpers\ArrayHelper::merge(
|
||||
require(__DIR__ . '/../../../config/web.php'),
|
||||
require(__DIR__ . '/config.php'),
|
||||
[
|
||||
|
||||
]
|
||||
);
|
26
tests/codeception/config/config.php
Normal file
26
tests/codeception/config/config.php
Normal file
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
/**
|
||||
* Application configuration shared by all test types
|
||||
*/
|
||||
return [
|
||||
'language' => '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,
|
||||
],
|
||||
],
|
||||
];
|
25
tests/codeception/config/functional.php
Normal file
25
tests/codeception/config/functional.php
Normal file
@ -0,0 +1,25 @@
|
||||
<?php
|
||||
$_SERVER['SCRIPT_FILENAME'] = YII_TEST_ENTRY_FILE;
|
||||
$_SERVER['SCRIPT_NAME'] = YII_TEST_ENTRY_URL;
|
||||
|
||||
/**
|
||||
* Application configuration for functional tests
|
||||
*/
|
||||
return yii\helpers\ArrayHelper::merge(
|
||||
require(__DIR__ . '/../../../config/web.php'),
|
||||
require(__DIR__ . '/config.php'),
|
||||
[
|
||||
'components' => [
|
||||
'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',
|
||||
],
|
||||
*/
|
||||
],
|
||||
],
|
||||
]
|
||||
);
|
11
tests/codeception/config/unit.php
Normal file
11
tests/codeception/config/unit.php
Normal file
@ -0,0 +1,11 @@
|
||||
<?php
|
||||
/**
|
||||
* Application configuration for unit tests
|
||||
*/
|
||||
return yii\helpers\ArrayHelper::merge(
|
||||
require(__DIR__ . '/../../../config/web.php'),
|
||||
require(__DIR__ . '/config.php'),
|
||||
[
|
||||
|
||||
]
|
||||
);
|
2
tests/codeception/fixtures/.gitignore
vendored
Normal file
2
tests/codeception/fixtures/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
*
|
||||
!.gitignore
|
16
tests/codeception/functional.suite.yml
Normal file
16
tests/codeception/functional.suite.yml
Normal file
@ -0,0 +1,16 @@
|
||||
# Codeception Test Suite Configuration
|
||||
|
||||
# suite for functional (integration) tests.
|
||||
# emulate web requests and make application process them.
|
||||
# (tip: better to use with frameworks).
|
||||
|
||||
# RUN `build` COMMAND AFTER ADDING/REMOVING MODULES.
|
||||
#basic/web/index.php
|
||||
class_name: FunctionalTester
|
||||
modules:
|
||||
enabled:
|
||||
- Filesystem
|
||||
- Yii2
|
||||
config:
|
||||
Yii2:
|
||||
configFile: 'codeception/config/functional.php'
|
10
tests/codeception/functional/AboutCept.php
Normal file
10
tests/codeception/functional/AboutCept.php
Normal file
@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
use tests\codeception\_pages\AboutPage;
|
||||
|
||||
/* @var $scenario Codeception\Scenario */
|
||||
|
||||
$I = new FunctionalTester($scenario);
|
||||
$I->wantTo('ensure that about works');
|
||||
AboutPage::openBy($I);
|
||||
$I->see('About', 'h1');
|
48
tests/codeception/functional/ContactCept.php
Normal file
48
tests/codeception/functional/ContactCept.php
Normal file
@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
use tests\codeception\_pages\ContactPage;
|
||||
|
||||
/* @var $scenario Codeception\Scenario */
|
||||
|
||||
$I = new FunctionalTester($scenario);
|
||||
$I->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.');
|
11
tests/codeception/functional/HomeCept.php
Normal file
11
tests/codeception/functional/HomeCept.php
Normal file
@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
/* @var $scenario Codeception\Scenario */
|
||||
|
||||
$I = new FunctionalTester($scenario);
|
||||
$I->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.');
|
28
tests/codeception/functional/LoginCept.php
Normal file
28
tests/codeception/functional/LoginCept.php
Normal file
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
use tests\codeception\_pages\LoginPage;
|
||||
|
||||
/* @var $scenario Codeception\Scenario */
|
||||
|
||||
$I = new FunctionalTester($scenario);
|
||||
$I->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)');
|
2
tests/codeception/functional/_bootstrap.php
Normal file
2
tests/codeception/functional/_bootstrap.php
Normal file
@ -0,0 +1,2 @@
|
||||
<?php
|
||||
new yii\web\Application(require(dirname(__DIR__) . '/config/functional.php'));
|
2
tests/codeception/templates/.gitignore
vendored
Normal file
2
tests/codeception/templates/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
*
|
||||
!.gitignore
|
6
tests/codeception/unit.suite.yml
Normal file
6
tests/codeception/unit.suite.yml
Normal file
@ -0,0 +1,6 @@
|
||||
# Codeception Test Suite Configuration
|
||||
|
||||
# suite for unit (internal) tests.
|
||||
# RUN `build` COMMAND AFTER ADDING/REMOVING MODULES.
|
||||
|
||||
class_name: UnitTester
|
3
tests/codeception/unit/_bootstrap.php
Normal file
3
tests/codeception/unit/_bootstrap.php
Normal file
@ -0,0 +1,3 @@
|
||||
<?php
|
||||
|
||||
// add unit testing specific bootstrap code here
|
0
tests/codeception/unit/fixtures/.gitkeep
Normal file
0
tests/codeception/unit/fixtures/.gitkeep
Normal file
0
tests/codeception/unit/fixtures/data/.gitkeep
Normal file
0
tests/codeception/unit/fixtures/data/.gitkeep
Normal file
60
tests/codeception/unit/models/ContactFormTest.php
Normal file
60
tests/codeception/unit/models/ContactFormTest.php
Normal file
@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
namespace tests\codeception\unit\models;
|
||||
|
||||
use Yii;
|
||||
use yii\codeception\TestCase;
|
||||
use Codeception\Specify;
|
||||
|
||||
class ContactFormTest extends TestCase
|
||||
{
|
||||
use Specify;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
Yii::$app->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';
|
||||
}
|
||||
|
||||
}
|
61
tests/codeception/unit/models/LoginFormTest.php
Normal file
61
tests/codeception/unit/models/LoginFormTest.php
Normal file
@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
namespace tests\codeception\unit\models;
|
||||
|
||||
use Yii;
|
||||
use yii\codeception\TestCase;
|
||||
use app\models\LoginForm;
|
||||
use Codeception\Specify;
|
||||
|
||||
class LoginFormTest extends TestCase
|
||||
{
|
||||
use Specify;
|
||||
|
||||
protected function tearDown()
|
||||
{
|
||||
Yii::$app->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();
|
||||
});
|
||||
}
|
||||
|
||||
}
|
17
tests/codeception/unit/models/UserTest.php
Normal file
17
tests/codeception/unit/models/UserTest.php
Normal file
@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace tests\codeception\unit\models;
|
||||
|
||||
use yii\codeception\TestCase;
|
||||
|
||||
class UserTest extends TestCase
|
||||
{
|
||||
protected function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
// uncomment the following to load fixtures for user table
|
||||
//$this->loadFixtures(['user']);
|
||||
}
|
||||
|
||||
// TODO add test methods here
|
||||
}
|
0
tests/codeception/unit/templates/fixtures/.gitkeep
Normal file
0
tests/codeception/unit/templates/fixtures/.gitkeep
Normal file
78
views/layouts/main.php
Normal file
78
views/layouts/main.php
Normal file
@ -0,0 +1,78 @@
|
||||
<?php
|
||||
|
||||
/* @var $this \yii\web\View */
|
||||
/* @var $content string */
|
||||
|
||||
use yii\helpers\Html;
|
||||
use yii\bootstrap\Nav;
|
||||
use yii\bootstrap\NavBar;
|
||||
use yii\widgets\Breadcrumbs;
|
||||
use app\assets\AppAsset;
|
||||
|
||||
AppAsset::register($this);
|
||||
?>
|
||||
<?php $this->beginPage() ?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="<?= Yii::$app->language ?>">
|
||||
<head>
|
||||
<meta charset="<?= Yii::$app->charset ?>">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<?= Html::csrfMetaTags() ?>
|
||||
<title><?= Html::encode($this->title) ?></title>
|
||||
<?php $this->head() ?>
|
||||
</head>
|
||||
<body>
|
||||
<?php $this->beginBody() ?>
|
||||
|
||||
<div class="wrap">
|
||||
<?php
|
||||
NavBar::begin([
|
||||
'brandLabel' => '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']]
|
||||
) : (
|
||||
'<li>'
|
||||
. Html::beginForm(['/site/logout'], 'post', ['class' => 'navbar-form'])
|
||||
. Html::submitButton(
|
||||
'Logout (' . Yii::$app->user->identity->username . ')',
|
||||
['class' => 'btn btn-link']
|
||||
)
|
||||
. Html::endForm()
|
||||
. '</li>'
|
||||
)
|
||||
],
|
||||
]);
|
||||
NavBar::end();
|
||||
?>
|
||||
|
||||
<div class="container">
|
||||
<?= Breadcrumbs::widget([
|
||||
'links' => isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : [],
|
||||
]) ?>
|
||||
<?= $content ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<footer class="footer">
|
||||
<div class="container">
|
||||
<p class="pull-left">© My Company <?= date('Y') ?></p>
|
||||
|
||||
<p class="pull-right"><?= Yii::powered() ?></p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
<?php $this->endBody() ?>
|
||||
</body>
|
||||
</html>
|
||||
<?php $this->endPage() ?>
|
18
views/site/about.php
Normal file
18
views/site/about.php
Normal file
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
|
||||
use yii\helpers\Html;
|
||||
|
||||
$this->title = 'About';
|
||||
$this->params['breadcrumbs'][] = $this->title;
|
||||
?>
|
||||
<div class="site-about">
|
||||
<h1><?= Html::encode($this->title) ?></h1>
|
||||
|
||||
<p>
|
||||
This is the About page. You may modify the following file to customize its content:
|
||||
</p>
|
||||
|
||||
<code><?= __FILE__ ?></code>
|
||||
</div>
|
68
views/site/contact.php
Normal file
68
views/site/contact.php
Normal file
@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $form yii\bootstrap\ActiveForm */
|
||||
/* @var $model app\models\ContactForm */
|
||||
|
||||
use yii\helpers\Html;
|
||||
use yii\bootstrap\ActiveForm;
|
||||
use yii\captcha\Captcha;
|
||||
|
||||
$this->title = 'Contact';
|
||||
$this->params['breadcrumbs'][] = $this->title;
|
||||
?>
|
||||
<div class="site-contact">
|
||||
<h1><?= Html::encode($this->title) ?></h1>
|
||||
|
||||
<?php if (Yii::$app->session->hasFlash('contactFormSubmitted')): ?>
|
||||
|
||||
<div class="alert alert-success">
|
||||
Thank you for contacting us. We will respond to you as soon as possible.
|
||||
</div>
|
||||
|
||||
<p>
|
||||
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.
|
||||
<?php if (Yii::$app->mailer->useFileTransport): ?>
|
||||
Because the application is in development mode, the email is not sent but saved as
|
||||
a file under <code><?= Yii::getAlias(Yii::$app->mailer->fileTransportPath) ?></code>.
|
||||
Please configure the <code>useFileTransport</code> property of the <code>mail</code>
|
||||
application component to be false to enable email sending.
|
||||
<?php endif; ?>
|
||||
</p>
|
||||
|
||||
<?php else: ?>
|
||||
|
||||
<p>
|
||||
If you have business inquiries or other questions, please fill out the following form to contact us.
|
||||
Thank you.
|
||||
</p>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-lg-5">
|
||||
|
||||
<?php $form = ActiveForm::begin(['id' => 'contact-form']); ?>
|
||||
|
||||
<?= $form->field($model, 'name')->textInput(['autofocus' => true]) ?>
|
||||
|
||||
<?= $form->field($model, 'email') ?>
|
||||
|
||||
<?= $form->field($model, 'subject') ?>
|
||||
|
||||
<?= $form->field($model, 'body')->textArea(['rows' => 6]) ?>
|
||||
|
||||
<?= $form->field($model, 'verifyCode')->widget(Captcha::className(), [
|
||||
'template' => '<div class="row"><div class="col-lg-3">{image}</div><div class="col-lg-6">{input}</div></div>',
|
||||
]) ?>
|
||||
|
||||
<div class="form-group">
|
||||
<?= Html::submitButton('Submit', ['class' => 'btn btn-primary', 'name' => 'contact-button']) ?>
|
||||
</div>
|
||||
|
||||
<?php ActiveForm::end(); ?>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php endif; ?>
|
||||
</div>
|
27
views/site/error.php
Normal file
27
views/site/error.php
Normal file
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $name string */
|
||||
/* @var $message string */
|
||||
/* @var $exception Exception */
|
||||
|
||||
use yii\helpers\Html;
|
||||
|
||||
$this->title = $name;
|
||||
?>
|
||||
<div class="site-error">
|
||||
|
||||
<h1><?= Html::encode($this->title) ?></h1>
|
||||
|
||||
<div class="alert alert-danger">
|
||||
<?= nl2br(Html::encode($message)) ?>
|
||||
</div>
|
||||
|
||||
<p>
|
||||
The above error occurred while the Web server was processing your request.
|
||||
</p>
|
||||
<p>
|
||||
Please contact us if you think this is a server error. Thank you.
|
||||
</p>
|
||||
|
||||
</div>
|
53
views/site/index.php
Normal file
53
views/site/index.php
Normal file
@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
|
||||
$this->title = 'My Yii Application';
|
||||
?>
|
||||
<div class="site-index">
|
||||
|
||||
<div class="jumbotron">
|
||||
<h1>Congratulations!</h1>
|
||||
|
||||
<p class="lead">You have successfully created your Yii-powered application.</p>
|
||||
|
||||
<p><a class="btn btn-lg btn-success" href="http://www.yiiframework.com">Get started with Yii</a></p>
|
||||
</div>
|
||||
|
||||
<div class="body-content">
|
||||
|
||||
<div class="row">
|
||||
<div class="col-lg-4">
|
||||
<h2>Heading</h2>
|
||||
|
||||
<p>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.</p>
|
||||
|
||||
<p><a class="btn btn-default" href="http://www.yiiframework.com/doc/">Yii Documentation »</a></p>
|
||||
</div>
|
||||
<div class="col-lg-4">
|
||||
<h2>Heading</h2>
|
||||
|
||||
<p>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.</p>
|
||||
|
||||
<p><a class="btn btn-default" href="http://www.yiiframework.com/forum/">Yii Forum »</a></p>
|
||||
</div>
|
||||
<div class="col-lg-4">
|
||||
<h2>Heading</h2>
|
||||
|
||||
<p>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.</p>
|
||||
|
||||
<p><a class="btn btn-default" href="http://www.yiiframework.com/extensions/">Yii Extensions »</a></p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
47
views/site/login.php
Normal file
47
views/site/login.php
Normal file
@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $form yii\bootstrap\ActiveForm */
|
||||
/* @var $model app\models\LoginForm */
|
||||
|
||||
use yii\helpers\Html;
|
||||
use yii\bootstrap\ActiveForm;
|
||||
|
||||
$this->title = 'Login';
|
||||
$this->params['breadcrumbs'][] = $this->title;
|
||||
?>
|
||||
<div class="site-login">
|
||||
<h1><?= Html::encode($this->title) ?></h1>
|
||||
|
||||
<p>Please fill out the following fields to login:</p>
|
||||
|
||||
<?php $form = ActiveForm::begin([
|
||||
'id' => 'login-form',
|
||||
'options' => ['class' => 'form-horizontal'],
|
||||
'fieldConfig' => [
|
||||
'template' => "{label}\n<div class=\"col-lg-3\">{input}</div>\n<div class=\"col-lg-8\">{error}</div>",
|
||||
'labelOptions' => ['class' => 'col-lg-1 control-label'],
|
||||
],
|
||||
]); ?>
|
||||
|
||||
<?= $form->field($model, 'username')->textInput(['autofocus' => true]) ?>
|
||||
|
||||
<?= $form->field($model, 'password')->passwordInput() ?>
|
||||
|
||||
<?= $form->field($model, 'rememberMe')->checkbox([
|
||||
'template' => "<div class=\"col-lg-offset-1 col-lg-3\">{input} {label}</div>\n<div class=\"col-lg-8\">{error}</div>",
|
||||
]) ?>
|
||||
|
||||
<div class="form-group">
|
||||
<div class="col-lg-offset-1 col-lg-11">
|
||||
<?= Html::submitButton('Login', ['class' => 'btn btn-primary', 'name' => 'login-button']) ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php ActiveForm::end(); ?>
|
||||
|
||||
<div class="col-lg-offset-1" style="color:#999;">
|
||||
You may login with <strong>admin/admin</strong> or <strong>demo/demo</strong>.<br>
|
||||
To modify the username/password, please check out the code <code>app\models\User::$users</code>.
|
||||
</div>
|
||||
</div>
|
2
web/assets/.gitignore
vendored
Normal file
2
web/assets/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
*
|
||||
!.gitignore
|
91
web/css/site.css
Normal file
91
web/css/site.css
Normal file
@ -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;
|
||||
}
|
BIN
web/favicon.ico
Normal file
BIN
web/favicon.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 318 B |
16
web/index-test.php
Normal file
16
web/index-test.php
Normal file
@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
// NOTE: Make sure this file is not accessible when deployed to production
|
||||
if (!in_array(@$_SERVER['REMOTE_ADDR'], ['127.0.0.1', '::1'])) {
|
||||
die('You are not allowed to access this file.');
|
||||
}
|
||||
|
||||
defined('YII_DEBUG') or define('YII_DEBUG', true);
|
||||
defined('YII_ENV') or define('YII_ENV', 'test');
|
||||
|
||||
require(__DIR__ . '/../vendor/autoload.php');
|
||||
require(__DIR__ . '/../vendor/yiisoft/yii2/Yii.php');
|
||||
|
||||
$config = require(__DIR__ . '/../tests/codeception/config/acceptance.php');
|
||||
|
||||
(new yii\web\Application($config))->run();
|
16
web/index.php
Normal file
16
web/index.php
Normal file
@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
// NOTE: Make sure this file is not accessible when deployed to production
|
||||
if (!in_array(@$_SERVER['REMOTE_ADDR'], ['127.0.0.1', '::1'])) {
|
||||
die('You are not allowed to access this file.');
|
||||
}
|
||||
|
||||
defined('YII_DEBUG') or define('YII_DEBUG', true);
|
||||
defined('YII_ENV') or define('YII_ENV', 'test');
|
||||
|
||||
require(__DIR__ . '/../vendor/autoload.php');
|
||||
require(__DIR__ . '/../vendor/yiisoft/yii2/Yii.php');
|
||||
|
||||
$config = require(__DIR__ . '/../tests/codeception/config/acceptance.php');
|
||||
|
||||
(new yii\web\Application($config))->run();
|
12
web/index_prod.php
Normal file
12
web/index_prod.php
Normal file
@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
// comment out the following two lines when deployed to production
|
||||
defined('YII_DEBUG') or define('YII_DEBUG', false);
|
||||
defined('YII_ENV') or define('YII_ENV', 'prod');
|
||||
|
||||
require(__DIR__ . '/../vendor/autoload.php');
|
||||
require(__DIR__ . '/../vendor/yiisoft/yii2/Yii.php');
|
||||
|
||||
$config = require(__DIR__ . '/../config/web.php');
|
||||
|
||||
(new yii\web\Application($config))->run();
|
2
web/robots.txt
Normal file
2
web/robots.txt
Normal file
@ -0,0 +1,2 @@
|
||||
User-agent: *
|
||||
Disallow:
|
21
yii
Normal file
21
yii
Normal file
@ -0,0 +1,21 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
/**
|
||||
* Yii console bootstrap file.
|
||||
*
|
||||
* @link http://www.yiiframework.com/
|
||||
* @copyright Copyright (c) 2008 Yii Software LLC
|
||||
* @license http://www.yiiframework.com/license/
|
||||
*/
|
||||
|
||||
defined('YII_DEBUG') or define('YII_DEBUG', true);
|
||||
defined('YII_ENV') or define('YII_ENV', 'dev');
|
||||
|
||||
require(__DIR__ . '/vendor/autoload.php');
|
||||
require(__DIR__ . '/vendor/yiisoft/yii2/Yii.php');
|
||||
|
||||
$config = require(__DIR__ . '/config/console.php');
|
||||
|
||||
$application = new yii\console\Application($config);
|
||||
$exitCode = $application->run();
|
||||
exit($exitCode);
|
20
yii.bat
Normal file
20
yii.bat
Normal file
@ -0,0 +1,20 @@
|
||||
@echo off
|
||||
|
||||
rem -------------------------------------------------------------
|
||||
rem Yii command line bootstrap script for Windows.
|
||||
rem
|
||||
rem @author Qiang Xue <qiang.xue@gmail.com>
|
||||
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
|
Loading…
Reference in New Issue
Block a user