Browse Source
* 'master' of github.com:yiisoft/yii2: (1471 commits)
Remove PHP 5.3 Travis build rule. Related to #35.
Remove use ($this). Related to 9e1b498fb5
.
PHP 5.4 supports $this with closures.
Fixes #999.
Just simple support PostgreSQL in QueryBuilder
debug panel : changed .json to .php
debug panel : change json_encode/decode to serialise/unserialise to prevent non-UTF characters error
typo fix
Fixes #930: Added i18n docs about configuring message source
commented private property
Fixed typos
fixes #995
More on GII buttons
Fixed option merging in Console::prompt()
changed default button style
typo fix.
Refactored getModule and hasModule.
Added intl check to tests, better error reporting, credited Aura.Intl for the most complex test pattern
Better MessageFormatter tests
GII sub-modules support - see #871
...
tags/2.0.0-beta
sensorario
11 years ago
1016 changed files with 122131 additions and 51881 deletions
@ -0,0 +1,4 @@ |
|||||||
|
service_name: travis-ci |
||||||
|
src_dir: framework/yii |
||||||
|
coverage_clover: tests/unit/runtime/coveralls/clover.xml |
||||||
|
json_path: tests/unit/runtime/coveralls/coveralls-upload.json |
@ -0,0 +1,23 @@ |
|||||||
|
# Autodetect text files |
||||||
|
* text=auto |
||||||
|
|
||||||
|
# ...Unless the name matches the following overriding patterns |
||||||
|
|
||||||
|
# Definitively text files |
||||||
|
*.php text |
||||||
|
*.css text |
||||||
|
*.js text |
||||||
|
*.txt text |
||||||
|
*.md text |
||||||
|
*.xml text |
||||||
|
*.json text |
||||||
|
*.bat text |
||||||
|
*.sql text |
||||||
|
*.xml text |
||||||
|
*.yml text |
||||||
|
|
||||||
|
# Ensure those won't be messed up with |
||||||
|
*.png binary |
||||||
|
*.jpg binary |
||||||
|
*.gif binary |
||||||
|
*.ttf binary |
@ -1,14 +1,24 @@ |
|||||||
language: php |
language: php |
||||||
|
|
||||||
php: |
php: |
||||||
- 5.3 |
|
||||||
- 5.4 |
- 5.4 |
||||||
- 5.5 |
- 5.5 |
||||||
|
|
||||||
env: |
services: |
||||||
- DB=mysql |
- redis-server |
||||||
|
- memcached |
||||||
|
|
||||||
before_script: |
before_script: |
||||||
- sh -c "if [ '$DB' = 'mysql' ]; then mysql -e 'create database IF NOT EXISTS yiitest;'; fi" |
- composer self-update && composer --version |
||||||
|
- composer require satooshi/php-coveralls 0.6.* |
||||||
|
- mysql -e 'CREATE DATABASE yiitest;'; |
||||||
|
- psql -U postgres -c 'CREATE DATABASE yiitest;'; |
||||||
|
- tests/unit/data/travis/apc-setup.sh |
||||||
|
- tests/unit/data/travis/memcache-setup.sh |
||||||
|
- tests/unit/data/travis/cubrid-setup.sh |
||||||
|
|
||||||
script: phpunit |
script: |
||||||
|
- phpunit --coverage-clover tests/unit/runtime/coveralls/clover.xml --verbose --exclude-group mssql,oci,wincache,xcache,zenddata |
||||||
|
|
||||||
|
after_script: |
||||||
|
- php vendor/bin/coveralls |
||||||
|
@ -0,0 +1,32 @@ |
|||||||
|
The Yii framework is free software. It is released under the terms of |
||||||
|
the following BSD License. |
||||||
|
|
||||||
|
Copyright © 2008-2013 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. |
@ -0,0 +1,60 @@ |
|||||||
|
Yii 2.0 Public Preview |
||||||
|
====================== |
||||||
|
|
||||||
|
Thank you for choosing Yii - a high-performance component-based PHP framework. |
||||||
|
|
||||||
|
If you are looking for a production-ready PHP framework, please use |
||||||
|
[Yii v1.1](https://github.com/yiisoft/yii). |
||||||
|
|
||||||
|
Yii 2.0 is still under heavy development. We may make significant changes |
||||||
|
without prior notices. **Yii 2.0 is not ready for production use yet.** |
||||||
|
|
||||||
|
[![Latest Stable Version](https://poser.pugx.org/yiisoft/yii2/v/stable.png)](https://packagist.org/packages/yiisoft/yii2) |
||||||
|
[![Total Downloads](https://poser.pugx.org/yiisoft/yii2/downloads.png)](https://packagist.org/packages/yiisoft/yii2) |
||||||
|
[![Build Status](https://secure.travis-ci.org/yiisoft/yii2.png)](http://travis-ci.org/yiisoft/yii2) |
||||||
|
[![Dependency Status](https://www.versioneye.com/php/yiisoft:yii2/dev-master/badge.png)](https://www.versioneye.com/php/yiisoft:yii2/dev-master) |
||||||
|
|
||||||
|
|
||||||
|
DIRECTORY STRUCTURE |
||||||
|
------------------- |
||||||
|
|
||||||
|
apps/ ready-to-use Web apps built on Yii 2 |
||||||
|
advanced/ advanced app template with complex features |
||||||
|
basic/ a simple app supporting user login and contact page |
||||||
|
benchmark/ app demonstrating the minimal overhead introduced by the framework |
||||||
|
build/ internally used build tools |
||||||
|
docs/ documentation |
||||||
|
extensions/ extensions |
||||||
|
framework/ framework files |
||||||
|
yii/ framework source files |
||||||
|
tests/ tests of the core framework code |
||||||
|
|
||||||
|
|
||||||
|
REQUIREMENTS |
||||||
|
------------ |
||||||
|
|
||||||
|
The minimum requirement by Yii is that your Web server supports PHP 5.3.?. |
||||||
|
|
||||||
|
|
||||||
|
DOCUMENTATION |
||||||
|
------------- |
||||||
|
|
||||||
|
For 1.1 users, you may refer to [Upgrading from Yii 1.1](docs/guide/upgrade-from-v1.md) |
||||||
|
to have a general idea of what has changed in 2.0. |
||||||
|
|
||||||
|
[Definitive Guide draft](docs/guide/index.md) is available. It's not complete yet but main parts are already OK. |
||||||
|
|
||||||
|
|
||||||
|
HOW TO PARTICIPATE |
||||||
|
------------------ |
||||||
|
|
||||||
|
**Your participation to Yii 2 development is very welcome!** |
||||||
|
|
||||||
|
You may participate in the following ways: |
||||||
|
|
||||||
|
* [Report issues](https://github.com/yiisoft/yii2/issues) |
||||||
|
* [Give us feedback or start a design discussion](http://www.yiiframework.com/forum/index.php/forum/42-design-discussions-for-yii-20/) |
||||||
|
* Fix issues, develop features, write/polish documentation |
||||||
|
- Before you start, please adopt an existing issue (labelled with "ready for adoption") or start a new one to avoid duplicated efforts. |
||||||
|
- Please submit a merge request after you finish development. |
||||||
|
|
@ -0,0 +1,32 @@ |
|||||||
|
The Yii framework is free software. It is released under the terms of |
||||||
|
the following BSD License. |
||||||
|
|
||||||
|
Copyright © 2008-2013 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. |
@ -0,0 +1,118 @@ |
|||||||
|
Yii 2 Advanced Application Template |
||||||
|
=================================== |
||||||
|
|
||||||
|
**NOTE** Yii 2 and the relevant applications and extensions are still under heavy |
||||||
|
development. We may make significant changes without prior notices. Please do not |
||||||
|
use them for production. Please consider using [Yii v1.1](https://github.com/yiisoft/yii) |
||||||
|
if you have a project to be deployed for production soon. |
||||||
|
|
||||||
|
|
||||||
|
Thank you for using Yii 2 Advanced Application Template - an application template |
||||||
|
that works out-of-box and can be easily customized to fit for your needs. |
||||||
|
|
||||||
|
Yii 2 Advanced Application Template is best suitable for large projects requiring frontend and backend separation, |
||||||
|
deployment in different environments, configuration nesting etc. |
||||||
|
|
||||||
|
|
||||||
|
DIRECTORY STRUCTURE |
||||||
|
------------------- |
||||||
|
|
||||||
|
``` |
||||||
|
common |
||||||
|
config/ contains shared configurations |
||||||
|
models/ contains model classes used in both backend and frontend |
||||||
|
console |
||||||
|
config/ contains console configurations |
||||||
|
controllers/ contains console controllers (commands) |
||||||
|
migrations/ contains database migrations |
||||||
|
models/ contains console-specific model classes |
||||||
|
runtime/ contains files generated during runtime |
||||||
|
backend |
||||||
|
assets/ contains application assets such as JavaScript and CSS |
||||||
|
config/ contains backend configurations |
||||||
|
controllers/ contains Web controller classes |
||||||
|
models/ contains backend-specific model classes |
||||||
|
runtime/ contains files generated during runtime |
||||||
|
views/ contains view files for the Web application |
||||||
|
web/ contains the entry script and Web resources |
||||||
|
frontend |
||||||
|
assets/ contains application assets such as JavaScript and CSS |
||||||
|
config/ contains frontend configurations |
||||||
|
controllers/ contains Web controller classes |
||||||
|
models/ contains frontend-specific model classes |
||||||
|
runtime/ contains files generated during runtime |
||||||
|
views/ contains view files for the Web application |
||||||
|
web/ contains the entry script and Web resources |
||||||
|
vendor/ contains dependent 3rd-party packages |
||||||
|
environments/ contains environment-based overrides |
||||||
|
``` |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
REQUIREMENTS |
||||||
|
------------ |
||||||
|
|
||||||
|
The minimum requirement by Yii is that your Web server supports PHP 5.3.?. |
||||||
|
|
||||||
|
In order for captcha to work you need either GD2 extension or ImageMagick PHP extension. |
||||||
|
|
||||||
|
INSTALLATION |
||||||
|
------------ |
||||||
|
|
||||||
|
### Install via Composer |
||||||
|
|
||||||
|
If you do not have [Composer](http://getcomposer.org/), you may download it from |
||||||
|
[http://getcomposer.org/](http://getcomposer.org/) or run the following command on Linux/Unix/MacOS: |
||||||
|
|
||||||
|
~~~ |
||||||
|
curl -s http://getcomposer.org/installer | php |
||||||
|
~~~ |
||||||
|
|
||||||
|
You can then install the application using the following command: |
||||||
|
|
||||||
|
~~~ |
||||||
|
php composer.phar create-project --stability=dev yiisoft/yii2-app-advanced yii-advanced |
||||||
|
~~~ |
||||||
|
|
||||||
|
Note that in order to install some dependencies you must have `php_openssl` extension enabled. |
||||||
|
|
||||||
|
|
||||||
|
### Install from an Archive File |
||||||
|
|
||||||
|
This is not currently available. We will provide it when Yii 2 is formally released. |
||||||
|
|
||||||
|
|
||||||
|
### Install from development repository |
||||||
|
|
||||||
|
If you've cloned the [Yii 2 framework main development repository](https://github.com/yiisoft/yii2) you |
||||||
|
can bootstrap your application with: |
||||||
|
|
||||||
|
~~~ |
||||||
|
cd yii2/apps/advanced |
||||||
|
php composer.phar create-project |
||||||
|
~~~ |
||||||
|
|
||||||
|
*Note: If the above command fails with `[RuntimeException] Not enough arguments.` run |
||||||
|
`php composer.phar self-update` to obtain an updated version of composer which supports creating projects |
||||||
|
from local packages.* |
||||||
|
|
||||||
|
|
||||||
|
GETTING STARTED |
||||||
|
--------------- |
||||||
|
|
||||||
|
After you install the application, you have to conduct the following steps to initialize |
||||||
|
the installed application. You only need to do these once for all. |
||||||
|
|
||||||
|
1. Execute the `init` command and select `dev` as environment. Alternatively you can execute it as `init --env=Development` |
||||||
|
or `init --env=Production`. |
||||||
|
2. Create a new database. It is assumed that MySQL InnoDB is used. If not, adjust `console/migrations/m130524_201442_init.php`. |
||||||
|
3. In `common/config/params.php` set your database details in `components.db` values. |
||||||
|
4. Apply migrations with `yii migrate`. |
||||||
|
|
||||||
|
Now you should be able to access: |
||||||
|
|
||||||
|
- the frontend using the URL `http://localhost/yii-advanced/frontend/web/` |
||||||
|
- the backend using the URL `http://localhost/yii-advanced/backend/web/` |
||||||
|
|
||||||
|
assuming `yii-advanced` is directly under the document root of your Web server. |
||||||
|
|
@ -0,0 +1,2 @@ |
|||||||
|
main-local.php |
||||||
|
params-local.php |
@ -0,0 +1,29 @@ |
|||||||
|
<?php |
||||||
|
/** |
||||||
|
* @link http://www.yiiframework.com/ |
||||||
|
* @copyright Copyright (c) 2008 Yii Software LLC |
||||||
|
* @license http://www.yiiframework.com/license/ |
||||||
|
*/ |
||||||
|
|
||||||
|
namespace backend\config; |
||||||
|
|
||||||
|
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 = array( |
||||||
|
'css/site.css', |
||||||
|
); |
||||||
|
public $js = array( |
||||||
|
); |
||||||
|
public $depends = array( |
||||||
|
'yii\web\YiiAsset', |
||||||
|
'yii\bootstrap\BootstrapAsset', |
||||||
|
); |
||||||
|
} |
@ -0,0 +1,42 @@ |
|||||||
|
<?php |
||||||
|
$rootDir = __DIR__ . '/../..'; |
||||||
|
|
||||||
|
$params = array_merge( |
||||||
|
require($rootDir . '/common/config/params.php'), |
||||||
|
require($rootDir . '/common/config/params-local.php'), |
||||||
|
require(__DIR__ . '/params.php'), |
||||||
|
require(__DIR__ . '/params-local.php') |
||||||
|
); |
||||||
|
|
||||||
|
return array( |
||||||
|
'id' => 'app-backend', |
||||||
|
'basePath' => dirname(__DIR__), |
||||||
|
'vendorPath' => dirname(dirname(__DIR__)) . '/vendor', |
||||||
|
'preload' => array('log'), |
||||||
|
'controllerNamespace' => 'backend\controllers', |
||||||
|
'modules' => array( |
||||||
|
), |
||||||
|
'components' => array( |
||||||
|
'request' => array( |
||||||
|
'enableCsrfValidation' => true, |
||||||
|
), |
||||||
|
'db' => $params['components.db'], |
||||||
|
'cache' => $params['components.cache'], |
||||||
|
'user' => array( |
||||||
|
'identityClass' => 'common\models\User', |
||||||
|
), |
||||||
|
'log' => array( |
||||||
|
'traceLevel' => YII_DEBUG ? 3 : 0, |
||||||
|
'targets' => array( |
||||||
|
array( |
||||||
|
'class' => 'yii\log\FileTarget', |
||||||
|
'levels' => array('error', 'warning'), |
||||||
|
), |
||||||
|
), |
||||||
|
), |
||||||
|
'errorHandler' => array( |
||||||
|
'errorAction' => 'site/error', |
||||||
|
), |
||||||
|
), |
||||||
|
'params' => $params, |
||||||
|
); |
@ -0,0 +1,4 @@ |
|||||||
|
<?php |
||||||
|
return array( |
||||||
|
'adminEmail' => 'admin@example.com', |
||||||
|
); |
@ -0,0 +1,63 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
namespace backend\controllers; |
||||||
|
|
||||||
|
use Yii; |
||||||
|
use yii\web\Controller; |
||||||
|
use common\models\LoginForm; |
||||||
|
|
||||||
|
class SiteController extends Controller |
||||||
|
{ |
||||||
|
public function behaviors() |
||||||
|
{ |
||||||
|
return array( |
||||||
|
'access' => array( |
||||||
|
'class' => \yii\web\AccessControl::className(), |
||||||
|
'rules' => array( |
||||||
|
array( |
||||||
|
'actions' => array('login'), |
||||||
|
'allow' => true, |
||||||
|
'roles' => array('?'), |
||||||
|
), |
||||||
|
array( |
||||||
|
'actions' => array('logout', 'index'), |
||||||
|
'allow' => true, |
||||||
|
'roles' => array('@'), |
||||||
|
), |
||||||
|
), |
||||||
|
), |
||||||
|
); |
||||||
|
} |
||||||
|
|
||||||
|
public function actions() |
||||||
|
{ |
||||||
|
return array( |
||||||
|
'error' => array( |
||||||
|
'class' => 'yii\web\ErrorAction', |
||||||
|
), |
||||||
|
); |
||||||
|
} |
||||||
|
|
||||||
|
public function actionIndex() |
||||||
|
{ |
||||||
|
return $this->render('index'); |
||||||
|
} |
||||||
|
|
||||||
|
public function actionLogin() |
||||||
|
{ |
||||||
|
$model = new LoginForm(); |
||||||
|
if ($model->load($_POST) && $model->login()) { |
||||||
|
return $this->goHome(); |
||||||
|
} else { |
||||||
|
return $this->render('login', array( |
||||||
|
'model' => $model, |
||||||
|
)); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public function actionLogout() |
||||||
|
{ |
||||||
|
Yii::$app->user->logout(); |
||||||
|
return $this->goHome(); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,64 @@ |
|||||||
|
<?php |
||||||
|
use backend\config\AppAsset; |
||||||
|
use yii\helpers\Html; |
||||||
|
use yii\bootstrap\Nav; |
||||||
|
use yii\bootstrap\NavBar; |
||||||
|
use yii\widgets\Breadcrumbs; |
||||||
|
|
||||||
|
/** |
||||||
|
* @var $this \yii\base\View |
||||||
|
* @var $content string |
||||||
|
*/ |
||||||
|
AppAsset::register($this); |
||||||
|
?> |
||||||
|
<?php $this->beginPage(); ?> |
||||||
|
<!DOCTYPE html> |
||||||
|
<html lang="en"> |
||||||
|
<head> |
||||||
|
<meta charset="<?php echo Yii::$app->charset; ?>"/>
|
||||||
|
<title><?php echo Html::encode($this->title); ?></title>
|
||||||
|
<?php $this->head(); ?> |
||||||
|
</head> |
||||||
|
<body> |
||||||
|
<?php $this->beginBody(); ?> |
||||||
|
<?php |
||||||
|
NavBar::begin(array( |
||||||
|
'brandLabel' => 'My Company', |
||||||
|
'brandUrl' => Yii::$app->homeUrl, |
||||||
|
'options' => array( |
||||||
|
'class' => 'navbar-inverse navbar-fixed-top', |
||||||
|
), |
||||||
|
)); |
||||||
|
$menuItems = array( |
||||||
|
array('label' => 'Home', 'url' => array('/site/index')), |
||||||
|
); |
||||||
|
if (Yii::$app->user->isGuest) { |
||||||
|
$menuItems[] = array('label' => 'Login', 'url' => array('/site/login')); |
||||||
|
} else { |
||||||
|
$menuItems[] = array('label' => 'Logout (' . Yii::$app->user->identity->username .')' , 'url' => array('/site/logout')); |
||||||
|
} |
||||||
|
echo Nav::widget(array( |
||||||
|
'options' => array('class' => 'navbar-nav pull-right'), |
||||||
|
'items' => $menuItems, |
||||||
|
)); |
||||||
|
NavBar::end(); |
||||||
|
?> |
||||||
|
|
||||||
|
<div class="container"> |
||||||
|
<?php echo Breadcrumbs::widget(array( |
||||||
|
'links' => isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : array(), |
||||||
|
)); ?> |
||||||
|
<?php echo $content; ?> |
||||||
|
</div> |
||||||
|
|
||||||
|
<footer class="footer"> |
||||||
|
<div class="container"> |
||||||
|
<p class="pull-left">© My Company <?php echo date('Y'); ?></p>
|
||||||
|
<p class="pull-right"><?php echo Yii::powered(); ?></p>
|
||||||
|
</div> |
||||||
|
</footer> |
||||||
|
|
||||||
|
<?php $this->endBody(); ?> |
||||||
|
</body> |
||||||
|
</html> |
||||||
|
<?php $this->endPage(); ?> |
@ -0,0 +1,29 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
use yii\helpers\Html; |
||||||
|
|
||||||
|
/** |
||||||
|
* @var yii\base\View $this |
||||||
|
* @var string $name |
||||||
|
* @var string $message |
||||||
|
* @var Exception $exception |
||||||
|
*/ |
||||||
|
|
||||||
|
$this->title = $name; |
||||||
|
?> |
||||||
|
<div class="site-error"> |
||||||
|
|
||||||
|
<h1><?php echo Html::encode($this->title); ?></h1>
|
||||||
|
|
||||||
|
<div class="alert alert-danger"> |
||||||
|
<?php echo 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> |
@ -0,0 +1,53 @@ |
|||||||
|
<?php |
||||||
|
/** |
||||||
|
* @var yii\base\View $this |
||||||
|
*/ |
||||||
|
$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> |
@ -0,0 +1,30 @@ |
|||||||
|
<?php |
||||||
|
use yii\helpers\Html; |
||||||
|
use yii\widgets\ActiveForm; |
||||||
|
|
||||||
|
/** |
||||||
|
* @var yii\base\View $this |
||||||
|
* @var yii\widgets\ActiveForm $form |
||||||
|
* @var app\models\LoginForm $model |
||||||
|
*/ |
||||||
|
$this->title = 'Login'; |
||||||
|
$this->params['breadcrumbs'][] = $this->title; |
||||||
|
?> |
||||||
|
<div class="site-login"> |
||||||
|
<h1><?php echo Html::encode($this->title); ?></h1>
|
||||||
|
|
||||||
|
<p>Please fill out the following fields to login:</p> |
||||||
|
|
||||||
|
<div class="row"> |
||||||
|
<div class="col-lg-5"> |
||||||
|
<?php $form = ActiveForm::begin(array('id' => 'login-form')); ?> |
||||||
|
<?php echo $form->field($model, 'username'); ?> |
||||||
|
<?php echo $form->field($model, 'password')->passwordInput(); ?> |
||||||
|
<?php echo $form->field($model, 'rememberMe')->checkbox(); ?> |
||||||
|
<div class="form-group"> |
||||||
|
<?php echo Html::submitButton('Login', array('class' => 'btn btn-primary')); ?> |
||||||
|
</div> |
||||||
|
<?php ActiveForm::end(); ?> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
</div> |
@ -0,0 +1,2 @@ |
|||||||
|
* |
||||||
|
!.gitignore |
@ -0,0 +1,19 @@ |
|||||||
|
body { |
||||||
|
padding-top: 70px; |
||||||
|
} |
||||||
|
|
||||||
|
.footer { |
||||||
|
border-top: 1px solid #ddd; |
||||||
|
margin-top: 30px; |
||||||
|
padding-top: 15px; |
||||||
|
padding-bottom: 30px; |
||||||
|
} |
||||||
|
|
||||||
|
.jumbotron { |
||||||
|
text-align: center; |
||||||
|
background-color: transparent; |
||||||
|
} |
||||||
|
.jumbotron .btn { |
||||||
|
font-size: 21px; |
||||||
|
padding: 14px 24px; |
||||||
|
} |
@ -0,0 +1,22 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
Yii::setAlias('common', __DIR__ . '/../'); |
||||||
|
Yii::setAlias('frontend', __DIR__ . '/../../frontend'); |
||||||
|
Yii::setAlias('backend', __DIR__ . '/../../backend'); |
||||||
|
|
||||||
|
return array( |
||||||
|
'adminEmail' => 'admin@example.com', |
||||||
|
'supportEmail' => 'support@example.com', |
||||||
|
|
||||||
|
'components.cache' => array( |
||||||
|
'class' => 'yii\caching\FileCache', |
||||||
|
), |
||||||
|
|
||||||
|
'components.db' => array( |
||||||
|
'class' => 'yii\db\Connection', |
||||||
|
'dsn' => 'mysql:host=localhost;dbname=yii2advanced', |
||||||
|
'username' => 'root', |
||||||
|
'password' => '', |
||||||
|
'charset' => 'utf8', |
||||||
|
), |
||||||
|
); |
@ -0,0 +1,58 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
namespace common\models; |
||||||
|
|
||||||
|
use Yii; |
||||||
|
use yii\base\Model; |
||||||
|
|
||||||
|
/** |
||||||
|
* LoginForm is the model behind the login form. |
||||||
|
*/ |
||||||
|
class LoginForm extends Model |
||||||
|
{ |
||||||
|
public $username; |
||||||
|
public $password; |
||||||
|
public $rememberMe = true; |
||||||
|
|
||||||
|
/** |
||||||
|
* @return array the validation rules. |
||||||
|
*/ |
||||||
|
public function rules() |
||||||
|
{ |
||||||
|
return array( |
||||||
|
// username and password are both required |
||||||
|
array('username, password', 'required'), |
||||||
|
// password is validated by validatePassword() |
||||||
|
array('password', 'validatePassword'), |
||||||
|
// rememberMe must be a boolean value |
||||||
|
array('rememberMe', 'boolean'), |
||||||
|
); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Validates the password. |
||||||
|
* This method serves as the inline validation for password. |
||||||
|
*/ |
||||||
|
public function validatePassword() |
||||||
|
{ |
||||||
|
$user = User::findByUsername($this->username); |
||||||
|
if (!$user || !$user->validatePassword($this->password)) { |
||||||
|
$this->addError('password', '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()) { |
||||||
|
$user = User::findByUsername($this->username); |
||||||
|
Yii::$app->user->login($user, $this->rememberMe ? 3600*24*30 : 0); |
||||||
|
return true; |
||||||
|
} else { |
||||||
|
return false; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,144 @@ |
|||||||
|
<?php |
||||||
|
namespace common\models; |
||||||
|
|
||||||
|
use yii\db\ActiveRecord; |
||||||
|
use yii\helpers\Security; |
||||||
|
use yii\web\IdentityInterface; |
||||||
|
|
||||||
|
/** |
||||||
|
* Class User |
||||||
|
* @package common\models |
||||||
|
* |
||||||
|
* @property integer $id |
||||||
|
* @property string $username |
||||||
|
* @property string $password_hash |
||||||
|
* @property string $password_reset_token |
||||||
|
* @property string $email |
||||||
|
* @property string $auth_key |
||||||
|
* @property integer $role |
||||||
|
* @property integer $status |
||||||
|
* @property integer $create_time |
||||||
|
* @property integer $update_time |
||||||
|
*/ |
||||||
|
class User extends ActiveRecord implements IdentityInterface |
||||||
|
{ |
||||||
|
/** |
||||||
|
* @var string the raw password. Used to collect password input and isn't saved in database |
||||||
|
*/ |
||||||
|
public $password; |
||||||
|
|
||||||
|
const STATUS_DELETED = 0; |
||||||
|
const STATUS_ACTIVE = 10; |
||||||
|
|
||||||
|
const ROLE_USER = 10; |
||||||
|
|
||||||
|
public function behaviors() |
||||||
|
{ |
||||||
|
return array( |
||||||
|
'timestamp' => array( |
||||||
|
'class' => 'yii\behaviors\AutoTimestamp', |
||||||
|
'attributes' => array( |
||||||
|
ActiveRecord::EVENT_BEFORE_INSERT => array('create_time', 'update_time'), |
||||||
|
ActiveRecord::EVENT_BEFORE_UPDATE => 'update_time', |
||||||
|
), |
||||||
|
), |
||||||
|
); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Finds an identity by the given ID. |
||||||
|
* |
||||||
|
* @param string|integer $id the ID to be looked for |
||||||
|
* @return IdentityInterface|null the identity object that matches the given ID. |
||||||
|
*/ |
||||||
|
public static function findIdentity($id) |
||||||
|
{ |
||||||
|
return static::find($id); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Finds user by username |
||||||
|
* |
||||||
|
* @param string $username |
||||||
|
* @return null|User |
||||||
|
*/ |
||||||
|
public static function findByUsername($username) |
||||||
|
{ |
||||||
|
return static::find(array('username' => $username, 'status' => static::STATUS_ACTIVE)); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* @return int|string current user ID |
||||||
|
*/ |
||||||
|
public function getId() |
||||||
|
{ |
||||||
|
return $this->id; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* @return string current user auth key |
||||||
|
*/ |
||||||
|
public function getAuthKey() |
||||||
|
{ |
||||||
|
return $this->auth_key; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* @param string $authKey |
||||||
|
* @return boolean if auth key is valid for current user |
||||||
|
*/ |
||||||
|
public function validateAuthKey($authKey) |
||||||
|
{ |
||||||
|
return $this->getAuthKey() === $authKey; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* @param string $password password to validate |
||||||
|
* @return bool if password provided is valid for current user |
||||||
|
*/ |
||||||
|
public function validatePassword($password) |
||||||
|
{ |
||||||
|
return Security::validatePassword($password, $this->password_hash); |
||||||
|
} |
||||||
|
|
||||||
|
public function rules() |
||||||
|
{ |
||||||
|
return array( |
||||||
|
array('username', 'filter', 'filter' => 'trim'), |
||||||
|
array('username', 'required'), |
||||||
|
array('username', 'string', 'min' => 2, 'max' => 255), |
||||||
|
|
||||||
|
array('email', 'filter', 'filter' => 'trim'), |
||||||
|
array('email', 'required'), |
||||||
|
array('email', 'email'), |
||||||
|
array('email', 'unique', 'message' => 'This email address has already been taken.', 'on' => 'signup'), |
||||||
|
array('email', 'exist', 'message' => 'There is no user with such email.', 'on' => 'requestPasswordResetToken'), |
||||||
|
|
||||||
|
array('password', 'required'), |
||||||
|
array('password', 'string', 'min' => 6), |
||||||
|
); |
||||||
|
} |
||||||
|
|
||||||
|
public function scenarios() |
||||||
|
{ |
||||||
|
return array( |
||||||
|
'signup' => array('username', 'email', 'password'), |
||||||
|
'resetPassword' => array('password'), |
||||||
|
'requestPasswordResetToken' => array('email'), |
||||||
|
); |
||||||
|
} |
||||||
|
|
||||||
|
public function beforeSave($insert) |
||||||
|
{ |
||||||
|
if (parent::beforeSave($insert)) { |
||||||
|
if (($this->isNewRecord || $this->getScenario() === 'resetPassword') && !empty($this->password)) { |
||||||
|
$this->password_hash = Security::generatePasswordHash($this->password); |
||||||
|
} |
||||||
|
if ($this->isNewRecord) { |
||||||
|
$this->auth_key = Security::generateRandomKey(); |
||||||
|
} |
||||||
|
return true; |
||||||
|
} |
||||||
|
return false; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,39 @@ |
|||||||
|
{ |
||||||
|
"name": "yiisoft/yii2-app-advanced", |
||||||
|
"description": "Yii 2 Advanced Application Template", |
||||||
|
"keywords": ["yii", "framework", "advanced", "application 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": "dev", |
||||||
|
"require": { |
||||||
|
"php": ">=5.3.0", |
||||||
|
"yiisoft/yii2": "dev-master", |
||||||
|
"yiisoft/yii2-composer": "dev-master" |
||||||
|
}, |
||||||
|
"scripts": { |
||||||
|
"post-create-project-cmd": [ |
||||||
|
"yii\\composer\\InstallHandler::setPermissions", |
||||||
|
"./init" |
||||||
|
] |
||||||
|
}, |
||||||
|
"extra": { |
||||||
|
"yii-install-writable": [ |
||||||
|
"backend/runtime", |
||||||
|
"backend/web/assets", |
||||||
|
|
||||||
|
"console/runtime", |
||||||
|
"console/migrations", |
||||||
|
|
||||||
|
"frontend/runtime", |
||||||
|
"frontend/web/assets" |
||||||
|
] |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,2 @@ |
|||||||
|
main-local.php |
||||||
|
params-local.php |
@ -0,0 +1,31 @@ |
|||||||
|
<?php |
||||||
|
$rootDir = __DIR__ . '/../..'; |
||||||
|
|
||||||
|
$params = array_merge( |
||||||
|
require($rootDir . '/common/config/params.php'), |
||||||
|
require($rootDir . '/common/config/params-local.php'), |
||||||
|
require(__DIR__ . '/params.php'), |
||||||
|
require(__DIR__ . '/params-local.php') |
||||||
|
); |
||||||
|
|
||||||
|
return array( |
||||||
|
'id' => 'app-console', |
||||||
|
'basePath' => dirname(__DIR__), |
||||||
|
'vendorPath' => dirname(dirname(__DIR__)) . '/vendor', |
||||||
|
'controllerNamespace' => 'console\controllers', |
||||||
|
'modules' => array( |
||||||
|
), |
||||||
|
'components' => array( |
||||||
|
'db' => $params['components.db'], |
||||||
|
'cache' => $params['components.cache'], |
||||||
|
'log' => array( |
||||||
|
'targets' => array( |
||||||
|
array( |
||||||
|
'class' => 'yii\log\FileTarget', |
||||||
|
'levels' => array('error', 'warning'), |
||||||
|
), |
||||||
|
), |
||||||
|
), |
||||||
|
), |
||||||
|
'params' => $params, |
||||||
|
); |
@ -0,0 +1,4 @@ |
|||||||
|
<?php |
||||||
|
return array( |
||||||
|
'adminEmail' => 'admin@example.com', |
||||||
|
); |
@ -0,0 +1,31 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
use yii\db\Schema; |
||||||
|
|
||||||
|
class m130524_201442_init extends \yii\db\Migration |
||||||
|
{ |
||||||
|
public function up() |
||||||
|
{ |
||||||
|
// MySQL-specific table options. Adjust if you plan working with another DBMS |
||||||
|
$tableOptions = 'CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE=InnoDB'; |
||||||
|
|
||||||
|
$this->createTable('tbl_user', array( |
||||||
|
'id' => Schema::TYPE_PK, |
||||||
|
'username' => Schema::TYPE_STRING.' NOT NULL', |
||||||
|
'auth_key' => Schema::TYPE_STRING.'(32) NOT NULL', |
||||||
|
'password_hash' => Schema::TYPE_STRING.' NOT NULL', |
||||||
|
'password_reset_token' => Schema::TYPE_STRING.'(32)', |
||||||
|
'email' => Schema::TYPE_STRING.' NOT NULL', |
||||||
|
'role' => 'tinyint NOT NULL DEFAULT 10', |
||||||
|
|
||||||
|
'status' => 'tinyint NOT NULL DEFAULT 10', |
||||||
|
'create_time' => Schema::TYPE_INTEGER.' NOT NULL', |
||||||
|
'update_time' => Schema::TYPE_INTEGER.' NOT NULL', |
||||||
|
), $tableOptions); |
||||||
|
} |
||||||
|
|
||||||
|
public function down() |
||||||
|
{ |
||||||
|
$this->dropTable('tbl_user'); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,11 @@ |
|||||||
|
<?php |
||||||
|
return array( |
||||||
|
'preload' => array( |
||||||
|
//'debug', |
||||||
|
), |
||||||
|
'modules' => array( |
||||||
|
// 'debug' => array( |
||||||
|
// 'class' => 'yii\debug\Module', |
||||||
|
// ), |
||||||
|
), |
||||||
|
); |
@ -0,0 +1,3 @@ |
|||||||
|
<?php |
||||||
|
return array( |
||||||
|
); |
@ -0,0 +1,14 @@ |
|||||||
|
<?php |
||||||
|
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/Yii.php'); |
||||||
|
|
||||||
|
$config = yii\helpers\ArrayHelper::merge( |
||||||
|
require(__DIR__ . '/../config/main.php'), |
||||||
|
require(__DIR__ . '/../config/main-local.php') |
||||||
|
); |
||||||
|
|
||||||
|
$application = new yii\web\Application($config); |
||||||
|
$application->run(); |
@ -0,0 +1,3 @@ |
|||||||
|
<?php |
||||||
|
return array( |
||||||
|
); |
@ -0,0 +1,3 @@ |
|||||||
|
<?php |
||||||
|
return array( |
||||||
|
); |
@ -0,0 +1,3 @@ |
|||||||
|
<?php |
||||||
|
return array( |
||||||
|
); |
@ -0,0 +1,11 @@ |
|||||||
|
<?php |
||||||
|
return array( |
||||||
|
'preload' => array( |
||||||
|
//'debug', |
||||||
|
), |
||||||
|
'modules' => array( |
||||||
|
// 'debug' => array( |
||||||
|
// 'class' => 'yii\debug\Module', |
||||||
|
// ), |
||||||
|
), |
||||||
|
); |
@ -0,0 +1,3 @@ |
|||||||
|
<?php |
||||||
|
return array( |
||||||
|
); |
@ -0,0 +1,15 @@ |
|||||||
|
<?php |
||||||
|
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/Yii.php'); |
||||||
|
Yii::importNamespaces(require(__DIR__ . '/../../vendor/composer/autoload_namespaces.php')); |
||||||
|
|
||||||
|
$config = yii\helpers\ArrayHelper::merge( |
||||||
|
require(__DIR__ . '/../config/main.php'), |
||||||
|
require(__DIR__ . '/../config/main-local.php') |
||||||
|
); |
||||||
|
|
||||||
|
$application = new yii\web\Application($config); |
||||||
|
$application->run(); |
@ -0,0 +1,28 @@ |
|||||||
|
#!/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'); |
||||||
|
|
||||||
|
// fcgi doesn't have STDIN defined by default |
||||||
|
defined('STDIN') or define('STDIN', fopen('php://stdin', 'r')); |
||||||
|
|
||||||
|
require(__DIR__ . '/vendor/autoload.php'); |
||||||
|
require(__DIR__ . '/vendor/yiisoft/yii2/yii/Yii.php'); |
||||||
|
Yii::importNamespaces(require(__DIR__ . '/vendor/composer/autoload_namespaces.php')); |
||||||
|
|
||||||
|
$config = yii\helpers\ArrayHelper::merge( |
||||||
|
require(__DIR__ . '/console/config/main.php'), |
||||||
|
require(__DIR__ . '/console/config/main-local.php') |
||||||
|
); |
||||||
|
|
||||||
|
$application = new yii\console\Application($config); |
||||||
|
$exitCode = $application->run(); |
||||||
|
exit($exitCode); |
@ -0,0 +1,38 @@ |
|||||||
|
<?php |
||||||
|
/** |
||||||
|
* The manifest of files that are local to specific environment. |
||||||
|
* This file returns a list of environments that the application |
||||||
|
* may be installed under. The returned data must be in the following |
||||||
|
* format: |
||||||
|
* |
||||||
|
* ```php |
||||||
|
* return array( |
||||||
|
* 'environment name' => array( |
||||||
|
* 'path' => 'directory storing the local files', |
||||||
|
* 'writable' => array( |
||||||
|
* // list of directories that should be set writable |
||||||
|
* ), |
||||||
|
* ), |
||||||
|
* ); |
||||||
|
* ``` |
||||||
|
*/ |
||||||
|
return array( |
||||||
|
'Development' => array( |
||||||
|
'path' => 'dev', |
||||||
|
'writable' => array( |
||||||
|
// handled by composer.json already |
||||||
|
), |
||||||
|
'executable' => array( |
||||||
|
'yii', |
||||||
|
), |
||||||
|
), |
||||||
|
'Production' => array( |
||||||
|
'path' => 'prod', |
||||||
|
'writable' => array( |
||||||
|
// handled by composer.json already |
||||||
|
), |
||||||
|
'executable' => array( |
||||||
|
'yii', |
||||||
|
), |
||||||
|
), |
||||||
|
); |
@ -0,0 +1,3 @@ |
|||||||
|
<?php |
||||||
|
return array( |
||||||
|
); |
@ -0,0 +1,3 @@ |
|||||||
|
<?php |
||||||
|
return array( |
||||||
|
); |
@ -0,0 +1,14 @@ |
|||||||
|
<?php |
||||||
|
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/Yii.php'); |
||||||
|
|
||||||
|
$config = yii\helpers\ArrayHelper::merge( |
||||||
|
require(__DIR__ . '/../config/main.php'), |
||||||
|
require(__DIR__ . '/../config/main-local.php') |
||||||
|
); |
||||||
|
|
||||||
|
$application = new yii\web\Application($config); |
||||||
|
$application->run(); |
@ -0,0 +1,3 @@ |
|||||||
|
<?php |
||||||
|
return array( |
||||||
|
); |
@ -0,0 +1,3 @@ |
|||||||
|
<?php |
||||||
|
return array( |
||||||
|
); |
@ -0,0 +1,3 @@ |
|||||||
|
<?php |
||||||
|
return array( |
||||||
|
); |
@ -0,0 +1,3 @@ |
|||||||
|
<?php |
||||||
|
return array( |
||||||
|
); |
@ -0,0 +1,3 @@ |
|||||||
|
<?php |
||||||
|
return array( |
||||||
|
); |
@ -0,0 +1,15 @@ |
|||||||
|
<?php |
||||||
|
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/Yii.php'); |
||||||
|
Yii::importNamespaces(require(__DIR__ . '/../../vendor/composer/autoload_namespaces.php')); |
||||||
|
|
||||||
|
$config = yii\helpers\ArrayHelper::merge( |
||||||
|
require(__DIR__ . '/../config/main.php'), |
||||||
|
require(__DIR__ . '/../config/main-local.php') |
||||||
|
); |
||||||
|
|
||||||
|
$application = new yii\web\Application($config); |
||||||
|
$application->run(); |
@ -0,0 +1,28 @@ |
|||||||
|
#!/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', false); |
||||||
|
defined('YII_ENV') or define('YII_ENV', 'prod'); |
||||||
|
|
||||||
|
// fcgi doesn't have STDIN defined by default |
||||||
|
defined('STDIN') or define('STDIN', fopen('php://stdin', 'r')); |
||||||
|
|
||||||
|
require(__DIR__ . '/vendor/autoload.php'); |
||||||
|
require(__DIR__ . '/vendor/yiisoft/yii2/yii/Yii.php'); |
||||||
|
Yii::importNamespaces(require(__DIR__ . '/vendor/composer/autoload_namespaces.php')); |
||||||
|
|
||||||
|
$config = yii\helpers\ArrayHelper::merge( |
||||||
|
require(__DIR__ . '/console/config/main.php'), |
||||||
|
require(__DIR__ . '/console/config/main-local.php') |
||||||
|
); |
||||||
|
|
||||||
|
$application = new yii\console\Application($config); |
||||||
|
$exitCode = $application->run(); |
||||||
|
exit($exitCode); |
@ -0,0 +1,2 @@ |
|||||||
|
main-local.php |
||||||
|
params-local.php |
@ -0,0 +1,29 @@ |
|||||||
|
<?php |
||||||
|
/** |
||||||
|
* @link http://www.yiiframework.com/ |
||||||
|
* @copyright Copyright (c) 2008 Yii Software LLC |
||||||
|
* @license http://www.yiiframework.com/license/ |
||||||
|
*/ |
||||||
|
|
||||||
|
namespace frontend\config; |
||||||
|
|
||||||
|
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 = array( |
||||||
|
'css/site.css', |
||||||
|
); |
||||||
|
public $js = array( |
||||||
|
); |
||||||
|
public $depends = array( |
||||||
|
'yii\web\YiiAsset', |
||||||
|
'yii\bootstrap\BootstrapAsset', |
||||||
|
); |
||||||
|
} |
@ -0,0 +1,42 @@ |
|||||||
|
<?php |
||||||
|
$rootDir = __DIR__ . '/../..'; |
||||||
|
|
||||||
|
$params = array_merge( |
||||||
|
require($rootDir . '/common/config/params.php'), |
||||||
|
require($rootDir . '/common/config/params-local.php'), |
||||||
|
require(__DIR__ . '/params.php'), |
||||||
|
require(__DIR__ . '/params-local.php') |
||||||
|
); |
||||||
|
|
||||||
|
return array( |
||||||
|
'id' => 'app-frontend', |
||||||
|
'basePath' => dirname(__DIR__), |
||||||
|
'vendorPath' => dirname(dirname(__DIR__)) . '/vendor', |
||||||
|
'controllerNamespace' => 'frontend\controllers', |
||||||
|
'modules' => array( |
||||||
|
'gii' => 'yii\gii\Module' |
||||||
|
), |
||||||
|
'components' => array( |
||||||
|
'request' => array( |
||||||
|
'enableCsrfValidation' => true, |
||||||
|
), |
||||||
|
'db' => $params['components.db'], |
||||||
|
'cache' => $params['components.cache'], |
||||||
|
'user' => array( |
||||||
|
'identityClass' => 'common\models\User', |
||||||
|
), |
||||||
|
'log' => array( |
||||||
|
'traceLevel' => YII_DEBUG ? 3 : 0, |
||||||
|
'targets' => array( |
||||||
|
array( |
||||||
|
'class' => 'yii\log\FileTarget', |
||||||
|
'levels' => array('error', 'warning'), |
||||||
|
), |
||||||
|
), |
||||||
|
), |
||||||
|
'errorHandler' => array( |
||||||
|
'errorAction' => 'site/error', |
||||||
|
), |
||||||
|
), |
||||||
|
'params' => $params, |
||||||
|
); |
@ -0,0 +1,4 @@ |
|||||||
|
<?php |
||||||
|
return array( |
||||||
|
'adminEmail' => 'admin@example.com', |
||||||
|
); |
@ -0,0 +1,172 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
namespace frontend\controllers; |
||||||
|
|
||||||
|
use Yii; |
||||||
|
use yii\web\Controller; |
||||||
|
use common\models\LoginForm; |
||||||
|
use frontend\models\ContactForm; |
||||||
|
use common\models\User; |
||||||
|
use yii\web\HttpException; |
||||||
|
use yii\helpers\Security; |
||||||
|
|
||||||
|
class SiteController extends Controller |
||||||
|
{ |
||||||
|
public function behaviors() |
||||||
|
{ |
||||||
|
return array( |
||||||
|
'access' => array( |
||||||
|
'class' => \yii\web\AccessControl::className(), |
||||||
|
'only' => array('login', 'logout', 'signup'), |
||||||
|
'rules' => array( |
||||||
|
array( |
||||||
|
'actions' => array('login', 'signup'), |
||||||
|
'allow' => true, |
||||||
|
'roles' => array('?'), |
||||||
|
), |
||||||
|
array( |
||||||
|
'actions' => array('logout'), |
||||||
|
'allow' => true, |
||||||
|
'roles' => array('@'), |
||||||
|
), |
||||||
|
), |
||||||
|
), |
||||||
|
); |
||||||
|
} |
||||||
|
|
||||||
|
public function actions() |
||||||
|
{ |
||||||
|
return array( |
||||||
|
'error' => array( |
||||||
|
'class' => 'yii\web\ErrorAction', |
||||||
|
), |
||||||
|
'captcha' => array( |
||||||
|
'class' => 'yii\captcha\CaptchaAction', |
||||||
|
'fixedVerifyCode' => YII_ENV_TEST ? 'testme' : null, |
||||||
|
), |
||||||
|
); |
||||||
|
} |
||||||
|
|
||||||
|
public function actionIndex() |
||||||
|
{ |
||||||
|
return $this->render('index'); |
||||||
|
} |
||||||
|
|
||||||
|
public function actionLogin() |
||||||
|
{ |
||||||
|
$model = new LoginForm(); |
||||||
|
if ($model->load($_POST) && $model->login()) { |
||||||
|
return $this->goHome(); |
||||||
|
} else { |
||||||
|
return $this->render('login', array( |
||||||
|
'model' => $model, |
||||||
|
)); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public function actionLogout() |
||||||
|
{ |
||||||
|
Yii::$app->user->logout(); |
||||||
|
return $this->goHome(); |
||||||
|
} |
||||||
|
|
||||||
|
public function actionContact() |
||||||
|
{ |
||||||
|
$model = new ContactForm; |
||||||
|
if ($model->load($_POST) && $model->contact(Yii::$app->params['adminEmail'])) { |
||||||
|
Yii::$app->session->setFlash('success', 'Thank you for contacting us. We will respond to you as soon as possible.'); |
||||||
|
return $this->refresh(); |
||||||
|
} else { |
||||||
|
return $this->render('contact', array( |
||||||
|
'model' => $model, |
||||||
|
)); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public function actionAbout() |
||||||
|
{ |
||||||
|
return $this->render('about'); |
||||||
|
} |
||||||
|
|
||||||
|
public function actionSignup() |
||||||
|
{ |
||||||
|
$model = new User(); |
||||||
|
$model->setScenario('signup'); |
||||||
|
if ($model->load($_POST) && $model->save()) { |
||||||
|
if (Yii::$app->getUser()->login($model)) { |
||||||
|
return $this->goHome(); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
return $this->render('signup', array( |
||||||
|
'model' => $model, |
||||||
|
)); |
||||||
|
} |
||||||
|
|
||||||
|
public function actionRequestPasswordReset() |
||||||
|
{ |
||||||
|
$model = new User(); |
||||||
|
$model->scenario = 'requestPasswordResetToken'; |
||||||
|
if ($model->load($_POST) && $model->validate()) { |
||||||
|
if ($this->sendPasswordResetEmail($model->email)) { |
||||||
|
Yii::$app->getSession()->setFlash('success', 'Check your email for further instructions.'); |
||||||
|
return $this->goHome(); |
||||||
|
} else { |
||||||
|
Yii::$app->getSession()->setFlash('error', 'There was an error sending email.'); |
||||||
|
} |
||||||
|
} |
||||||
|
return $this->render('requestPasswordResetToken', array( |
||||||
|
'model' => $model, |
||||||
|
)); |
||||||
|
} |
||||||
|
|
||||||
|
public function actionResetPassword($token) |
||||||
|
{ |
||||||
|
$model = User::find(array( |
||||||
|
'password_reset_token' => $token, |
||||||
|
'status' => User::STATUS_ACTIVE, |
||||||
|
)); |
||||||
|
|
||||||
|
if (!$model) { |
||||||
|
throw new HttpException(400, 'Wrong password reset token.'); |
||||||
|
} |
||||||
|
|
||||||
|
$model->scenario = 'resetPassword'; |
||||||
|
if ($model->load($_POST) && $model->save()) { |
||||||
|
Yii::$app->getSession()->setFlash('success', 'New password was saved.'); |
||||||
|
return $this->goHome(); |
||||||
|
} |
||||||
|
|
||||||
|
return $this->render('resetPassword', array( |
||||||
|
'model' => $model, |
||||||
|
)); |
||||||
|
} |
||||||
|
|
||||||
|
private function sendPasswordResetEmail($email) |
||||||
|
{ |
||||||
|
$user = User::find(array( |
||||||
|
'status' => User::STATUS_ACTIVE, |
||||||
|
'email' => $email, |
||||||
|
)); |
||||||
|
|
||||||
|
if (!$user) { |
||||||
|
return false; |
||||||
|
} |
||||||
|
|
||||||
|
$user->password_reset_token = Security::generateRandomKey(); |
||||||
|
if ($user->save(false)) { |
||||||
|
$fromEmail = \Yii::$app->params['supportEmail']; |
||||||
|
$name = '=?UTF-8?B?' . base64_encode(\Yii::$app->name . ' robot') . '?='; |
||||||
|
$subject = '=?UTF-8?B?' . base64_encode('Password reset for ' . \Yii::$app->name) . '?='; |
||||||
|
$body = $this->renderPartial('/emails/passwordResetToken', array( |
||||||
|
'user' => $user, |
||||||
|
)); |
||||||
|
$headers = "From: $name <{$fromEmail}>\r\n" . |
||||||
|
"MIME-Version: 1.0\r\n" . |
||||||
|
"Content-type: text/plain; charset=UTF-8"; |
||||||
|
return mail($email, $subject, $body, $headers); |
||||||
|
} |
||||||
|
|
||||||
|
return false; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,63 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
namespace frontend\models; |
||||||
|
|
||||||
|
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 array( |
||||||
|
// name, email, subject and body are required |
||||||
|
array('name, email, subject, body', 'required'), |
||||||
|
// email has to be a valid email address |
||||||
|
array('email', 'email'), |
||||||
|
// verifyCode needs to be entered correctly |
||||||
|
array('verifyCode', 'captcha'), |
||||||
|
); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* @return array customized attribute labels |
||||||
|
*/ |
||||||
|
public function attributeLabels() |
||||||
|
{ |
||||||
|
return array( |
||||||
|
'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()) { |
||||||
|
$name = '=?UTF-8?B?' . base64_encode($this->name) . '?='; |
||||||
|
$subject = '=?UTF-8?B?' . base64_encode($this->subject) . '?='; |
||||||
|
$headers = "From: $name <{$this->email}>\r\n" . |
||||||
|
"Reply-To: {$this->email}\r\n" . |
||||||
|
"MIME-Version: 1.0\r\n" . |
||||||
|
"Content-type: text/plain; charset=UTF-8"; |
||||||
|
mail($email, $subject, $this->body, $headers); |
||||||
|
return true; |
||||||
|
} else { |
||||||
|
return false; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,2 @@ |
|||||||
|
* |
||||||
|
!.gitignore |
@ -0,0 +1,16 @@ |
|||||||
|
<?php |
||||||
|
use yii\helpers\Html; |
||||||
|
|
||||||
|
/** |
||||||
|
* @var yii\base\View $this |
||||||
|
* @var common\models\User $user; |
||||||
|
*/ |
||||||
|
|
||||||
|
$resetLink = Yii::$app->urlManager->createAbsoluteUrl('site/reset-password', array('token' => $user->password_reset_token)); |
||||||
|
?> |
||||||
|
|
||||||
|
Hello <?php echo Html::encode($user->username)?>,
|
||||||
|
|
||||||
|
Follow the link below to reset your password: |
||||||
|
|
||||||
|
<?php echo Html::a(Html::encode($resetLink), $resetLink)?> |
@ -0,0 +1,69 @@ |
|||||||
|
<?php |
||||||
|
use frontend\config\AppAsset; |
||||||
|
use yii\helpers\Html; |
||||||
|
use yii\bootstrap\Nav; |
||||||
|
use yii\bootstrap\NavBar; |
||||||
|
use yii\widgets\Breadcrumbs; |
||||||
|
use frontend\widgets\Alert; |
||||||
|
|
||||||
|
/** |
||||||
|
* @var $this \yii\base\View |
||||||
|
* @var $content string |
||||||
|
*/ |
||||||
|
AppAsset::register($this); |
||||||
|
?> |
||||||
|
<?php $this->beginPage(); ?> |
||||||
|
<!DOCTYPE html> |
||||||
|
<html lang="en"> |
||||||
|
<head> |
||||||
|
<meta charset="<?php echo Yii::$app->charset; ?>"/>
|
||||||
|
<title><?php echo Html::encode($this->title); ?></title>
|
||||||
|
<?php $this->head(); ?> |
||||||
|
</head> |
||||||
|
<body> |
||||||
|
<?php $this->beginBody(); ?> |
||||||
|
<?php |
||||||
|
NavBar::begin(array( |
||||||
|
'brandLabel' => 'My Company', |
||||||
|
'brandUrl' => Yii::$app->homeUrl, |
||||||
|
'options' => array( |
||||||
|
'class' => 'navbar-inverse navbar-fixed-top', |
||||||
|
), |
||||||
|
)); |
||||||
|
$menuItems = array( |
||||||
|
array('label' => 'Home', 'url' => array('/site/index')), |
||||||
|
array('label' => 'About', 'url' => array('/site/about')), |
||||||
|
array('label' => 'Contact', 'url' => array('/site/contact')), |
||||||
|
); |
||||||
|
if (Yii::$app->user->isGuest) { |
||||||
|
$menuItems[] = array('label' => 'Signup', 'url' => array('/site/signup')); |
||||||
|
$menuItems[] = array('label' => 'Login', 'url' => array('/site/login')); |
||||||
|
} else { |
||||||
|
$menuItems[] = array('label' => 'Logout (' . Yii::$app->user->identity->username .')' , 'url' => array('/site/logout')); |
||||||
|
} |
||||||
|
echo Nav::widget(array( |
||||||
|
'options' => array('class' => 'navbar-nav pull-right'), |
||||||
|
'items' => $menuItems, |
||||||
|
)); |
||||||
|
NavBar::end(); |
||||||
|
?> |
||||||
|
|
||||||
|
<div class="container"> |
||||||
|
<?php echo Breadcrumbs::widget(array( |
||||||
|
'links' => isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : array(), |
||||||
|
)); ?> |
||||||
|
<?php echo Alert::widget()?> |
||||||
|
<?php echo $content; ?> |
||||||
|
</div> |
||||||
|
|
||||||
|
<footer class="footer"> |
||||||
|
<div class="container"> |
||||||
|
<p class="pull-left">© My Company <?php echo date('Y'); ?></p>
|
||||||
|
<p class="pull-right"><?php echo Yii::powered(); ?></p>
|
||||||
|
</div> |
||||||
|
</footer> |
||||||
|
|
||||||
|
<?php $this->endBody(); ?> |
||||||
|
</body> |
||||||
|
</html> |
||||||
|
<?php $this->endPage(); ?> |
@ -0,0 +1,16 @@ |
|||||||
|
<?php |
||||||
|
use yii\helpers\Html; |
||||||
|
|
||||||
|
/** |
||||||
|
* @var yii\base\View $this |
||||||
|
*/ |
||||||
|
$this->title = 'About'; |
||||||
|
$this->params['breadcrumbs'][] = $this->title; |
||||||
|
?> |
||||||
|
<div class="site-about"> |
||||||
|
<h1><?php echo Html::encode($this->title); ?></h1>
|
||||||
|
|
||||||
|
<p>This is the About page. You may modify the following file to customize its content:</p> |
||||||
|
|
||||||
|
<code><?php echo __FILE__; ?></code>
|
||||||
|
</div> |
@ -0,0 +1,39 @@ |
|||||||
|
<?php |
||||||
|
use yii\helpers\Html; |
||||||
|
use yii\widgets\ActiveForm; |
||||||
|
use yii\captcha\Captcha; |
||||||
|
|
||||||
|
/** |
||||||
|
* @var yii\base\View $this |
||||||
|
* @var yii\widgets\ActiveForm $form |
||||||
|
* @var app\models\ContactForm $model |
||||||
|
*/ |
||||||
|
$this->title = 'Contact'; |
||||||
|
$this->params['breadcrumbs'][] = $this->title; |
||||||
|
?> |
||||||
|
<div class="site-contact"> |
||||||
|
<h1><?php echo Html::encode($this->title); ?></h1>
|
||||||
|
|
||||||
|
<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(array('id' => 'contact-form')); ?> |
||||||
|
<?php echo $form->field($model, 'name'); ?> |
||||||
|
<?php echo $form->field($model, 'email'); ?> |
||||||
|
<?php echo $form->field($model, 'subject'); ?> |
||||||
|
<?php echo $form->field($model, 'body')->textArea(array('rows' => 6)); ?> |
||||||
|
<?php echo $form->field($model, 'verifyCode')->widget(Captcha::className(), array( |
||||||
|
'options' => array('class' => 'form-control'), |
||||||
|
'template' => '<div class="row"><div class="col-lg-3">{image}</div><div class="col-lg-6">{input}</div></div>', |
||||||
|
)); ?> |
||||||
|
<div class="form-group"> |
||||||
|
<?php echo Html::submitButton('Submit', array('class' => 'btn btn-primary')); ?> |
||||||
|
</div> |
||||||
|
<?php ActiveForm::end(); ?> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
|
||||||
|
</div> |
@ -0,0 +1,29 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
use yii\helpers\Html; |
||||||
|
|
||||||
|
/** |
||||||
|
* @var yii\base\View $this |
||||||
|
* @var string $name |
||||||
|
* @var string $message |
||||||
|
* @var Exception $exception |
||||||
|
*/ |
||||||
|
|
||||||
|
$this->title = $name; |
||||||
|
?> |
||||||
|
<div class="site-error"> |
||||||
|
|
||||||
|
<h1><?php echo Html::encode($this->title); ?></h1>
|
||||||
|
|
||||||
|
<div class="alert alert-danger"> |
||||||
|
<?php echo 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> |
@ -0,0 +1,53 @@ |
|||||||
|
<?php |
||||||
|
/** |
||||||
|
* @var yii\base\View $this |
||||||
|
*/ |
||||||
|
$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> |
@ -0,0 +1,33 @@ |
|||||||
|
<?php |
||||||
|
use yii\helpers\Html; |
||||||
|
use yii\widgets\ActiveForm; |
||||||
|
|
||||||
|
/** |
||||||
|
* @var yii\base\View $this |
||||||
|
* @var yii\widgets\ActiveForm $form |
||||||
|
* @var app\models\LoginForm $model |
||||||
|
*/ |
||||||
|
$this->title = 'Login'; |
||||||
|
$this->params['breadcrumbs'][] = $this->title; |
||||||
|
?> |
||||||
|
<div class="site-login"> |
||||||
|
<h1><?php echo Html::encode($this->title); ?></h1>
|
||||||
|
|
||||||
|
<p>Please fill out the following fields to login:</p> |
||||||
|
|
||||||
|
<div class="row"> |
||||||
|
<div class="col-lg-5"> |
||||||
|
<?php $form = ActiveForm::begin(array('id' => 'login-form')); ?> |
||||||
|
<?php echo $form->field($model, 'username'); ?> |
||||||
|
<?php echo $form->field($model, 'password')->passwordInput(); ?> |
||||||
|
<?php echo $form->field($model, 'rememberMe')->checkbox(); ?> |
||||||
|
<div style="color:#999;margin:1em 0"> |
||||||
|
If you forgot your password you can <?php echo Html::a('reset it', array('site/request-password-reset'))?>.
|
||||||
|
</div> |
||||||
|
<div class="form-group"> |
||||||
|
<?php echo Html::submitButton('Login', array('class' => 'btn btn-primary')); ?> |
||||||
|
</div> |
||||||
|
<?php ActiveForm::end(); ?> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
</div> |
@ -0,0 +1,28 @@ |
|||||||
|
<?php |
||||||
|
use yii\helpers\Html; |
||||||
|
use yii\widgets\ActiveForm; |
||||||
|
|
||||||
|
/** |
||||||
|
* @var yii\base\View $this |
||||||
|
* @var yii\widgets\ActiveForm $form |
||||||
|
* @var common\models\User $model |
||||||
|
*/ |
||||||
|
$this->title = 'Request password reset'; |
||||||
|
$this->params['breadcrumbs'][] = $this->title; |
||||||
|
?> |
||||||
|
<div class="site-request-password-reset"> |
||||||
|
<h1><?php echo Html::encode($this->title); ?></h1>
|
||||||
|
|
||||||
|
<p>Please fill out your email. A link to reset password will be sent there.</p> |
||||||
|
|
||||||
|
<div class="row"> |
||||||
|
<div class="col-lg-5"> |
||||||
|
<?php $form = ActiveForm::begin(array('id' => 'request-password-reset-form')); ?> |
||||||
|
<?php echo $form->field($model, 'email'); ?> |
||||||
|
<div class="form-group"> |
||||||
|
<?php echo Html::submitButton('Send', array('class' => 'btn btn-primary')); ?> |
||||||
|
</div> |
||||||
|
<?php ActiveForm::end(); ?> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
</div> |
@ -0,0 +1,28 @@ |
|||||||
|
<?php |
||||||
|
use yii\helpers\Html; |
||||||
|
use yii\widgets\ActiveForm; |
||||||
|
|
||||||
|
/** |
||||||
|
* @var yii\base\View $this |
||||||
|
* @var yii\widgets\ActiveForm $form |
||||||
|
* @var common\models\User $model |
||||||
|
*/ |
||||||
|
$this->title = 'Reset password'; |
||||||
|
$this->params['breadcrumbs'][] = $this->title; |
||||||
|
?> |
||||||
|
<div class="site-reset-password"> |
||||||
|
<h1><?php echo Html::encode($this->title); ?></h1>
|
||||||
|
|
||||||
|
<p>Please choose your new password:</p> |
||||||
|
|
||||||
|
<div class="row"> |
||||||
|
<div class="col-lg-5"> |
||||||
|
<?php $form = ActiveForm::begin(array('id' => 'reset-password-form')); ?> |
||||||
|
<?php echo $form->field($model, 'password')->passwordInput(); ?> |
||||||
|
<div class="form-group"> |
||||||
|
<?php echo Html::submitButton('Save', array('class' => 'btn btn-primary')); ?> |
||||||
|
</div> |
||||||
|
<?php ActiveForm::end(); ?> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
</div> |
@ -0,0 +1,30 @@ |
|||||||
|
<?php |
||||||
|
use yii\helpers\Html; |
||||||
|
use yii\widgets\ActiveForm; |
||||||
|
|
||||||
|
/** |
||||||
|
* @var yii\base\View $this |
||||||
|
* @var yii\widgets\ActiveForm $form |
||||||
|
* @var common\models\User $model |
||||||
|
*/ |
||||||
|
$this->title = 'Signup'; |
||||||
|
$this->params['breadcrumbs'][] = $this->title; |
||||||
|
?> |
||||||
|
<div class="site-signup"> |
||||||
|
<h1><?php echo Html::encode($this->title); ?></h1>
|
||||||
|
|
||||||
|
<p>Please fill out the following fields to signup:</p> |
||||||
|
|
||||||
|
<div class="row"> |
||||||
|
<div class="col-lg-5"> |
||||||
|
<?php $form = ActiveForm::begin(array('id' => 'form-signup')); ?> |
||||||
|
<?php echo $form->field($model, 'username'); ?> |
||||||
|
<?php echo $form->field($model, 'email'); ?> |
||||||
|
<?php echo $form->field($model, 'password')->passwordInput(); ?> |
||||||
|
<div class="form-group"> |
||||||
|
<?php echo Html::submitButton('Signup', array('class' => 'btn btn-primary')); ?> |
||||||
|
</div> |
||||||
|
<?php ActiveForm::end(); ?> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
</div> |
@ -0,0 +1,2 @@ |
|||||||
|
* |
||||||
|
!.gitignore |
@ -0,0 +1,19 @@ |
|||||||
|
body { |
||||||
|
padding-top: 70px; |
||||||
|
} |
||||||
|
|
||||||
|
.footer { |
||||||
|
border-top: 1px solid #ddd; |
||||||
|
margin-top: 30px; |
||||||
|
padding-top: 15px; |
||||||
|
padding-bottom: 30px; |
||||||
|
} |
||||||
|
|
||||||
|
.jumbotron { |
||||||
|
text-align: center; |
||||||
|
background-color: transparent; |
||||||
|
} |
||||||
|
.jumbotron .btn { |
||||||
|
font-size: 21px; |
||||||
|
padding: 14px 24px; |
||||||
|
} |
@ -0,0 +1,48 @@ |
|||||||
|
<?php |
||||||
|
/** |
||||||
|
* @link http://www.yiiframework.com/ |
||||||
|
* @copyright Copyright (c) 2008 Yii Software LLC |
||||||
|
* @license http://www.yiiframework.com/license/ |
||||||
|
*/ |
||||||
|
|
||||||
|
namespace frontend\widgets; |
||||||
|
|
||||||
|
use yii\helpers\Html; |
||||||
|
|
||||||
|
/** |
||||||
|
* Alert widget renders a message from session flash. You can set message as following: |
||||||
|
* |
||||||
|
* - \Yii::$app->getSession()->setFlash('error', 'This is the message'); |
||||||
|
* - \Yii::$app->getSession()->setFlash('success', 'This is the message'); |
||||||
|
* - \Yii::$app->getSession()->setFlash('info', 'This is the message'); |
||||||
|
* |
||||||
|
* @author Alexander Makarov <sam@rmcerative.ru> |
||||||
|
*/ |
||||||
|
class Alert extends \yii\bootstrap\Alert |
||||||
|
{ |
||||||
|
private $_doNotRender = false; |
||||||
|
public function init() |
||||||
|
{ |
||||||
|
if ($this->body = \Yii::$app->getSession()->getFlash('error', null, true)) { |
||||||
|
Html::addCssClass($this->options, 'alert-danger'); |
||||||
|
} elseif ($this->body = \Yii::$app->getSession()->getFlash('success', null, true)) { |
||||||
|
Html::addCssClass($this->options, 'alert-success'); |
||||||
|
} elseif ($this->body = \Yii::$app->getSession()->getFlash('info', null, true)) { |
||||||
|
Html::addCssClass($this->options, 'alert-info'); |
||||||
|
} elseif ($this->body = \Yii::$app->getSession()->getFlash('warning', null, true)) { |
||||||
|
Html::addCssClass($this->options, 'alert-warning'); |
||||||
|
} else { |
||||||
|
$this->_doNotRender = true; |
||||||
|
return; |
||||||
|
} |
||||||
|
|
||||||
|
parent::init(); |
||||||
|
} |
||||||
|
|
||||||
|
public function run() |
||||||
|
{ |
||||||
|
if (!$this->_doNotRender) { |
||||||
|
parent::run(); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,154 @@ |
|||||||
|
#!/usr/bin/env php |
||||||
|
<?php |
||||||
|
$params = getParams(); |
||||||
|
$root = str_replace('\\', '/', __DIR__); |
||||||
|
$envs = require("$root/environments/index.php"); |
||||||
|
$envNames = array_keys($envs); |
||||||
|
|
||||||
|
echo "Yii Application Initialization Tool v1.0\n\n"; |
||||||
|
|
||||||
|
$envName = null; |
||||||
|
if (empty($params['env'])) { |
||||||
|
echo "Which environment do you want the application to be initialized in?\n\n"; |
||||||
|
foreach ($envNames as $i => $name) { |
||||||
|
echo " [$i] $name\n"; |
||||||
|
} |
||||||
|
echo "\n Your choice [0-" . (count($envs) - 1) . ', or "q" to quit] '; |
||||||
|
$answer = trim(fgets(STDIN)); |
||||||
|
|
||||||
|
if (!ctype_digit($answer) || !in_array($answer, range(0, count($envs) - 1))) { |
||||||
|
echo "\n Quit initialization.\n"; |
||||||
|
exit(1); |
||||||
|
} |
||||||
|
|
||||||
|
if(isset($envNames[$answer])) { |
||||||
|
$envName = $envNames[$answer]; |
||||||
|
} |
||||||
|
} |
||||||
|
else { |
||||||
|
$envName = $params['env']; |
||||||
|
} |
||||||
|
|
||||||
|
if (!in_array($envName, $envNames)) { |
||||||
|
$envsList = implode(', ', $envNames); |
||||||
|
echo "\n $envName is not a valid environment. Try one of the following: $envsList. \n"; |
||||||
|
exit(2); |
||||||
|
} |
||||||
|
|
||||||
|
$env = $envs[$envName]; |
||||||
|
|
||||||
|
if (empty($params['env'])) { |
||||||
|
echo "\n Initialize the application under '{$envNames[$answer]}' environment? [yes|no] "; |
||||||
|
$answer = trim(fgets(STDIN)); |
||||||
|
if (strncasecmp($answer, 'y', 1)) { |
||||||
|
echo "\n Quit initialization.\n"; |
||||||
|
exit(1); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
echo "\n Start initialization ...\n\n"; |
||||||
|
$files = getFileList("$root/environments/{$env['path']}"); |
||||||
|
$all = false; |
||||||
|
foreach ($files as $file) { |
||||||
|
if (!copyFile($root, "environments/{$env['path']}/$file", $file, $all)) { |
||||||
|
break; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
if (isset($env['writable'])) { |
||||||
|
foreach ($env['writable'] as $writable) { |
||||||
|
echo " chmod 0777 $writable\n"; |
||||||
|
@chmod("$root/$writable", 0777); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
if (isset($env['executable'])) { |
||||||
|
foreach ($env['executable'] as $executable) { |
||||||
|
echo " chmod 0755 $executable\n"; |
||||||
|
@chmod("$root/$executable", 0755); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
echo "\n ... initialization completed.\n\n"; |
||||||
|
|
||||||
|
function getFileList($root, $basePath = '') |
||||||
|
{ |
||||||
|
$files = array(); |
||||||
|
$handle = opendir($root); |
||||||
|
while (($path = readdir($handle)) !== false) { |
||||||
|
if ($path === '.svn' || $path === '.' || $path === '..') { |
||||||
|
continue; |
||||||
|
} |
||||||
|
$fullPath = "$root/$path"; |
||||||
|
$relativePath = $basePath === '' ? $path : "$basePath/$path"; |
||||||
|
if (is_dir($fullPath)) { |
||||||
|
$files = array_merge($files, getFileList($fullPath, $relativePath)); |
||||||
|
} else { |
||||||
|
$files[] = $relativePath; |
||||||
|
} |
||||||
|
} |
||||||
|
closedir($handle); |
||||||
|
return $files; |
||||||
|
} |
||||||
|
|
||||||
|
function copyFile($root, $source, $target, &$all) |
||||||
|
{ |
||||||
|
if (!is_file($root . '/' . $source)) { |
||||||
|
echo " skip $target ($source not exist)\n"; |
||||||
|
return true; |
||||||
|
} |
||||||
|
if (is_file($root . '/' . $target)) { |
||||||
|
if (file_get_contents($root . '/' . $source) === file_get_contents($root . '/' . $target)) { |
||||||
|
echo " unchanged $target\n"; |
||||||
|
return true; |
||||||
|
} |
||||||
|
if ($all) { |
||||||
|
echo " overwrite $target\n"; |
||||||
|
} else { |
||||||
|
echo " exist $target\n"; |
||||||
|
echo " ...overwrite? [Yes|No|All|Quit] "; |
||||||
|
$answer = trim(fgets(STDIN)); |
||||||
|
if (!strncasecmp($answer, 'q', 1)) { |
||||||
|
return false; |
||||||
|
} else { |
||||||
|
if (!strncasecmp($answer, 'y', 1)) { |
||||||
|
echo " overwrite $target\n"; |
||||||
|
} else { |
||||||
|
if (!strncasecmp($answer, 'a', 1)) { |
||||||
|
echo " overwrite $target\n"; |
||||||
|
$all = true; |
||||||
|
} else { |
||||||
|
echo " skip $target\n"; |
||||||
|
return true; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
file_put_contents($root . '/' . $target, file_get_contents($root . '/' . $source)); |
||||||
|
return true; |
||||||
|
} |
||||||
|
echo " generate $target\n"; |
||||||
|
@mkdir(dirname($root . '/' . $target), 0777, true); |
||||||
|
file_put_contents($root . '/' . $target, file_get_contents($root . '/' . $source)); |
||||||
|
return true; |
||||||
|
} |
||||||
|
|
||||||
|
function getParams() |
||||||
|
{ |
||||||
|
$rawParams = array(); |
||||||
|
if (isset($_SERVER['argv'])) { |
||||||
|
$rawParams = $_SERVER['argv']; |
||||||
|
array_shift($rawParams); |
||||||
|
} |
||||||
|
|
||||||
|
$params = array(); |
||||||
|
foreach ($rawParams as $param) { |
||||||
|
if (preg_match('/^--(\w+)(=(.*))?$/', $param, $matches)) { |
||||||
|
$name = $matches[1]; |
||||||
|
$params[$name] = isset($matches[3]) ? $matches[3] : true; |
||||||
|
} else { |
||||||
|
$params[] = $param; |
||||||
|
} |
||||||
|
} |
||||||
|
return $params; |
||||||
|
} |
@ -0,0 +1,20 @@ |
|||||||
|
@echo off |
||||||
|
|
||||||
|
rem ------------------------------------------------------------- |
||||||
|
rem Yii command line init script for Windows. |
||||||
|
rem |
||||||
|
rem @author Qiang Xue <qiang.xue@gmail.com> |
||||||
|
rem @link http://www.yiiframework.com/ |
||||||
|
rem @copyright Copyright © 2012 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%init" %* |
||||||
|
|
||||||
|
@endlocal |
@ -0,0 +1,103 @@ |
|||||||
|
<?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/yii'; |
||||||
|
|
||||||
|
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(); |
||||||
|
|
||||||
|
/** |
||||||
|
* Adjust requirements according to your application specifics. |
||||||
|
*/ |
||||||
|
$requirements = array( |
||||||
|
// Database : |
||||||
|
array( |
||||||
|
'name' => 'PDO extension', |
||||||
|
'mandatory' => true, |
||||||
|
'condition' => extension_loaded('pdo'), |
||||||
|
'by' => 'All <a href="http://www.yiiframework.com/doc/api/#system.db">DB-related classes</a>', |
||||||
|
), |
||||||
|
array( |
||||||
|
'name' => 'PDO SQLite extension', |
||||||
|
'mandatory' => false, |
||||||
|
'condition' => extension_loaded('pdo_sqlite'), |
||||||
|
'by' => 'All <a href="http://www.yiiframework.com/doc/api/#system.db">DB-related classes</a>', |
||||||
|
'memo' => 'Required for SQLite database.', |
||||||
|
), |
||||||
|
array( |
||||||
|
'name' => 'PDO MySQL extension', |
||||||
|
'mandatory' => false, |
||||||
|
'condition' => extension_loaded('pdo_mysql'), |
||||||
|
'by' => 'All <a href="http://www.yiiframework.com/doc/api/#system.db">DB-related classes</a>', |
||||||
|
'memo' => 'Required for MySQL database.', |
||||||
|
), |
||||||
|
// Cache : |
||||||
|
array( |
||||||
|
'name' => 'Memcache extension', |
||||||
|
'mandatory' => false, |
||||||
|
'condition' => extension_loaded('memcache') || extension_loaded('memcached'), |
||||||
|
'by' => '<a href="http://www.yiiframework.com/doc/api/CMemCache">CMemCache</a>', |
||||||
|
'memo' => extension_loaded('memcached') ? 'To use memcached set <a href="http://www.yiiframework.com/doc/api/CMemCache#useMemcached-detail">CMemCache::useMemcached</a> to <code>true</code>.' : '' |
||||||
|
), |
||||||
|
array( |
||||||
|
'name' => 'APC extension', |
||||||
|
'mandatory' => false, |
||||||
|
'condition' => extension_loaded('apc') || extension_loaded('apc'), |
||||||
|
'by' => '<a href="http://www.yiiframework.com/doc/api/CApcCache">CApcCache</a>', |
||||||
|
), |
||||||
|
// Additional PHP extensions : |
||||||
|
array( |
||||||
|
'name' => 'Mcrypt extension', |
||||||
|
'mandatory' => false, |
||||||
|
'condition' => extension_loaded('mcrypt'), |
||||||
|
'by' => '<a href="http://www.yiiframework.com/doc/api/CSecurityManager">CSecurityManager</a>', |
||||||
|
'memo' => 'Required by encrypt and decrypt methods.' |
||||||
|
), |
||||||
|
// PHP ini : |
||||||
|
'phpSafeMode' => array( |
||||||
|
'name' => 'PHP safe mode', |
||||||
|
'mandatory' => false, |
||||||
|
'condition' => $requirementsChecker->checkPhpIniOff("safe_mode"), |
||||||
|
'by' => 'File uploading and console command execution', |
||||||
|
'memo' => '"safe_mode" should be disabled at 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', |
||||||
|
), |
||||||
|
); |
||||||
|
$requirementsChecker->checkYii()->check($requirements)->render(); |
@ -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 © 2012 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 |
@ -0,0 +1,32 @@ |
|||||||
|
The Yii framework is free software. It is released under the terms of |
||||||
|
the following BSD License. |
||||||
|
|
||||||
|
Copyright © 2008-2013 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. |
@ -0,0 +1,79 @@ |
|||||||
|
Yii 2 Basic Application Template |
||||||
|
================================ |
||||||
|
|
||||||
|
**NOTE** Yii 2 and the relevant applications and extensions are still under heavy |
||||||
|
development. We may make significant changes without prior notices. Please do not |
||||||
|
use them for production. Please consider using [Yii v1.1](https://github.com/yiisoft/yii) |
||||||
|
if you have a project to be deployed for production soon. |
||||||
|
|
||||||
|
|
||||||
|
Thank you for using Yii 2 Basic Application Template - an application template |
||||||
|
that works out-of-box and can be easily customized to fit for your needs. |
||||||
|
|
||||||
|
Yii 2 Basic Application Template is best suitable for small Websites which mainly contain |
||||||
|
a few informational pages. |
||||||
|
|
||||||
|
|
||||||
|
DIRECTORY STRUCTURE |
||||||
|
------------------- |
||||||
|
|
||||||
|
commands/ contains console commands (controllers) |
||||||
|
config/ contains application configurations |
||||||
|
controllers/ contains Web controller classes |
||||||
|
models/ contains model classes |
||||||
|
runtime/ contains files generated during runtime |
||||||
|
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 Yii is that your Web server supports PHP 5.3.?. |
||||||
|
|
||||||
|
In order for captcha to work you need either GD2 extension or ImageMagick PHP extension. |
||||||
|
|
||||||
|
INSTALLATION |
||||||
|
------------ |
||||||
|
|
||||||
|
### Install via Composer |
||||||
|
|
||||||
|
If you do not have [Composer](http://getcomposer.org/), you may download it from |
||||||
|
[http://getcomposer.org/](http://getcomposer.org/) or run the following command on Linux/Unix/MacOS: |
||||||
|
|
||||||
|
~~~ |
||||||
|
curl -s http://getcomposer.org/installer | php |
||||||
|
~~~ |
||||||
|
|
||||||
|
You can then install the Bootstrap Application using the following command: |
||||||
|
|
||||||
|
~~~ |
||||||
|
php composer.phar create-project --stability=dev yiisoft/yii2-app-basic yii-basic |
||||||
|
~~~ |
||||||
|
|
||||||
|
Now you should be able to access the application using the URL `http://localhost/yii-basic/web/`, |
||||||
|
assuming `yii-basic` is directly under the document root of your Web server. |
||||||
|
|
||||||
|
Note that in order to install some dependencies you must have `php_openssl` extension enabled. |
||||||
|
|
||||||
|
|
||||||
|
### Install from an Archive File |
||||||
|
|
||||||
|
This is not currently available. We will provide it when Yii 2 is formally released. |
||||||
|
|
||||||
|
|
||||||
|
### Install from development repository |
||||||
|
|
||||||
|
If you've cloned the [Yii 2 framework main development repository](https://github.com/yiisoft/yii2) you |
||||||
|
can bootstrap your application with: |
||||||
|
|
||||||
|
~~~ |
||||||
|
cd yii2/apps/basic |
||||||
|
php composer.phar create-project |
||||||
|
~~~ |
||||||
|
|
||||||
|
*Note: If the above command fails with `[RuntimeException] Not enough arguments.` run |
||||||
|
`php composer.phar self-update` to obtain an updated version of composer which supports creating projects |
||||||
|
from local packages.* |
@ -0,0 +1,18 @@ |
|||||||
|
paths: |
||||||
|
tests: tests |
||||||
|
log: tests/_log |
||||||
|
data: tests/_data |
||||||
|
helpers: tests/_helpers |
||||||
|
settings: |
||||||
|
bootstrap: _bootstrap.php |
||||||
|
suite_class: \PHPUnit_Framework_TestSuite |
||||||
|
colors: true |
||||||
|
memory_limit: 1024M |
||||||
|
log: true |
||||||
|
modules: |
||||||
|
config: |
||||||
|
Db: |
||||||
|
dsn: '' |
||||||
|
user: '' |
||||||
|
password: '' |
||||||
|
dump: tests/_data/dump.sql |
@ -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 what 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"; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,35 @@ |
|||||||
|
{ |
||||||
|
"name": "yiisoft/yii2-app-basic", |
||||||
|
"description": "Yii 2 Basic Application Template", |
||||||
|
"keywords": ["yii", "framework", "basic", "application 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": "dev", |
||||||
|
"require": { |
||||||
|
"php": ">=5.3.0", |
||||||
|
"yiisoft/yii2": "dev-master", |
||||||
|
"yiisoft/yii2-composer": "dev-master" |
||||||
|
}, |
||||||
|
"scripts": { |
||||||
|
"post-create-project-cmd": [ |
||||||
|
"yii\\composer\\InstallHandler::setPermissions" |
||||||
|
] |
||||||
|
}, |
||||||
|
"extra": { |
||||||
|
"yii-install-writable": [ |
||||||
|
"runtime", |
||||||
|
"web/assets" |
||||||
|
], |
||||||
|
"yii-install-executable": [ |
||||||
|
"yii" |
||||||
|
] |
||||||
|
} |
||||||
|
} |
@ -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\config; |
||||||
|
|
||||||
|
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 = array( |
||||||
|
'css/site.css', |
||||||
|
); |
||||||
|
public $js = array( |
||||||
|
); |
||||||
|
public $depends = array( |
||||||
|
'yii\web\YiiAsset', |
||||||
|
'yii\bootstrap\BootstrapAsset', |
||||||
|
); |
||||||
|
} |
@ -0,0 +1,25 @@ |
|||||||
|
<?php |
||||||
|
$params = require(__DIR__ . '/params.php'); |
||||||
|
return array( |
||||||
|
'id' => 'bootstrap-console', |
||||||
|
'basePath' => dirname(__DIR__), |
||||||
|
'preload' => array('log'), |
||||||
|
'controllerPath' => dirname(__DIR__) . '/commands', |
||||||
|
'controllerNamespace' => 'app\commands', |
||||||
|
'modules' => array( |
||||||
|
), |
||||||
|
'components' => array( |
||||||
|
'cache' => array( |
||||||
|
'class' => 'yii\caching\FileCache', |
||||||
|
), |
||||||
|
'log' => array( |
||||||
|
'targets' => array( |
||||||
|
array( |
||||||
|
'class' => 'yii\log\FileTarget', |
||||||
|
'levels' => array('error', 'warning'), |
||||||
|
), |
||||||
|
), |
||||||
|
), |
||||||
|
), |
||||||
|
'params' => $params, |
||||||
|
); |
@ -0,0 +1,5 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
return array( |
||||||
|
'adminEmail' => 'admin@example.com', |
||||||
|
); |
@ -0,0 +1,7 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
$config = require(__DIR__ . '/web.php'); |
||||||
|
|
||||||
|
// ... customize $config for the "test" environment here... |
||||||
|
|
||||||
|
return $config; |
@ -0,0 +1,38 @@ |
|||||||
|
<?php |
||||||
|
$params = require(__DIR__ . '/params.php'); |
||||||
|
$config = array( |
||||||
|
'id' => 'bootstrap', |
||||||
|
'basePath' => dirname(__DIR__), |
||||||
|
'components' => array( |
||||||
|
'request' => array( |
||||||
|
'enableCsrfValidation' => true, |
||||||
|
), |
||||||
|
'cache' => array( |
||||||
|
'class' => 'yii\caching\FileCache', |
||||||
|
), |
||||||
|
'user' => array( |
||||||
|
'identityClass' => 'app\models\User', |
||||||
|
), |
||||||
|
'errorHandler' => array( |
||||||
|
'errorAction' => 'site/error', |
||||||
|
), |
||||||
|
'log' => array( |
||||||
|
'traceLevel' => YII_DEBUG ? 3 : 0, |
||||||
|
'targets' => array( |
||||||
|
array( |
||||||
|
'class' => 'yii\log\FileTarget', |
||||||
|
'levels' => array('error', 'warning'), |
||||||
|
), |
||||||
|
), |
||||||
|
), |
||||||
|
), |
||||||
|
'params' => $params, |
||||||
|
); |
||||||
|
|
||||||
|
if (YII_ENV_DEV) { |
||||||
|
$config['preload'][] = 'debug'; |
||||||
|
$config['modules']['debug'] = 'yii\debug\Module'; |
||||||
|
$config['modules']['gii'] = 'yii\gii\Module'; |
||||||
|
} |
||||||
|
|
||||||
|
return $config; |
@ -0,0 +1,95 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
namespace app\controllers; |
||||||
|
|
||||||
|
use Yii; |
||||||
|
use yii\web\AccessControl; |
||||||
|
use yii\web\Controller; |
||||||
|
use yii\web\VerbFilter; |
||||||
|
use app\models\LoginForm; |
||||||
|
use app\models\ContactForm; |
||||||
|
|
||||||
|
class SiteController extends Controller |
||||||
|
{ |
||||||
|
public function behaviors() |
||||||
|
{ |
||||||
|
return array( |
||||||
|
'access' => array( |
||||||
|
'class' => AccessControl::className(), |
||||||
|
'only' => array('login', 'logout'), |
||||||
|
'rules' => array( |
||||||
|
array( |
||||||
|
'actions' => array('login'), |
||||||
|
'allow' => true, |
||||||
|
'roles' => array('?'), |
||||||
|
), |
||||||
|
array( |
||||||
|
'actions' => array('logout'), |
||||||
|
'allow' => true, |
||||||
|
'roles' => array('@'), |
||||||
|
), |
||||||
|
), |
||||||
|
), |
||||||
|
'verbs' => array( |
||||||
|
'class' => VerbFilter::className(), |
||||||
|
'actions' => array( |
||||||
|
'logout' => array('post'), |
||||||
|
), |
||||||
|
), |
||||||
|
); |
||||||
|
} |
||||||
|
|
||||||
|
public function actions() |
||||||
|
{ |
||||||
|
return array( |
||||||
|
'error' => array( |
||||||
|
'class' => 'yii\web\ErrorAction', |
||||||
|
), |
||||||
|
'captcha' => array( |
||||||
|
'class' => 'yii\captcha\CaptchaAction', |
||||||
|
'fixedVerifyCode' => YII_ENV_TEST ? 'testme' : null, |
||||||
|
), |
||||||
|
); |
||||||
|
} |
||||||
|
|
||||||
|
public function actionIndex() |
||||||
|
{ |
||||||
|
return $this->render('index'); |
||||||
|
} |
||||||
|
|
||||||
|
public function actionLogin() |
||||||
|
{ |
||||||
|
$model = new LoginForm(); |
||||||
|
if ($model->load($_POST) && $model->login()) { |
||||||
|
return $this->goBack(); |
||||||
|
} else { |
||||||
|
return $this->render('login', array( |
||||||
|
'model' => $model, |
||||||
|
)); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public function actionLogout() |
||||||
|
{ |
||||||
|
Yii::$app->user->logout(); |
||||||
|
return $this->goHome(); |
||||||
|
} |
||||||
|
|
||||||
|
public function actionContact() |
||||||
|
{ |
||||||
|
$model = new ContactForm; |
||||||
|
if ($model->load($_POST) && $model->contact(Yii::$app->params['adminEmail'])) { |
||||||
|
Yii::$app->session->setFlash('contactFormSubmitted'); |
||||||
|
return $this->refresh(); |
||||||
|
} else { |
||||||
|
return $this->render('contact', array( |
||||||
|
'model' => $model, |
||||||
|
)); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public function actionAbout() |
||||||
|
{ |
||||||
|
return $this->render('about'); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,61 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
namespace app\models; |
||||||
|
|
||||||
|
class User extends \yii\base\Object implements \yii\web\IdentityInterface |
||||||
|
{ |
||||||
|
public $id; |
||||||
|
public $username; |
||||||
|
public $password; |
||||||
|
public $authKey; |
||||||
|
|
||||||
|
private static $users = array( |
||||||
|
'100' => array( |
||||||
|
'id' => '100', |
||||||
|
'username' => 'admin', |
||||||
|
'password' => 'admin', |
||||||
|
'authKey' => 'test100key', |
||||||
|
), |
||||||
|
'101' => array( |
||||||
|
'id' => '101', |
||||||
|
'username' => 'demo', |
||||||
|
'password' => 'demo', |
||||||
|
'authKey' => 'test101key', |
||||||
|
), |
||||||
|
); |
||||||
|
|
||||||
|
public static function findIdentity($id) |
||||||
|
{ |
||||||
|
return isset(self::$users[$id]) ? new self(self::$users[$id]) : null; |
||||||
|
} |
||||||
|
|
||||||
|
public static function findByUsername($username) |
||||||
|
{ |
||||||
|
foreach (self::$users as $user) { |
||||||
|
if (strcasecmp($user['username'], $username) === 0) { |
||||||
|
return new self($user); |
||||||
|
} |
||||||
|
} |
||||||
|
return null; |
||||||
|
} |
||||||
|
|
||||||
|
public function getId() |
||||||
|
{ |
||||||
|
return $this->id; |
||||||
|
} |
||||||
|
|
||||||
|
public function getAuthKey() |
||||||
|
{ |
||||||
|
return $this->authKey; |
||||||
|
} |
||||||
|
|
||||||
|
public function validateAuthKey($authKey) |
||||||
|
{ |
||||||
|
return $this->authKey === $authKey; |
||||||
|
} |
||||||
|
|
||||||
|
public function validatePassword($password) |
||||||
|
{ |
||||||
|
return $this->password === $password; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,103 @@ |
|||||||
|
<?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/yii'; |
||||||
|
|
||||||
|
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(); |
||||||
|
|
||||||
|
/** |
||||||
|
* Adjust requirements according to your application specifics. |
||||||
|
*/ |
||||||
|
$requirements = array( |
||||||
|
// Database : |
||||||
|
array( |
||||||
|
'name' => 'PDO extension', |
||||||
|
'mandatory' => true, |
||||||
|
'condition' => extension_loaded('pdo'), |
||||||
|
'by' => 'All <a href="http://www.yiiframework.com/doc/api/#system.db">DB-related classes</a>', |
||||||
|
), |
||||||
|
array( |
||||||
|
'name' => 'PDO SQLite extension', |
||||||
|
'mandatory' => false, |
||||||
|
'condition' => extension_loaded('pdo_sqlite'), |
||||||
|
'by' => 'All <a href="http://www.yiiframework.com/doc/api/#system.db">DB-related classes</a>', |
||||||
|
'memo' => 'Required for SQLite database.', |
||||||
|
), |
||||||
|
array( |
||||||
|
'name' => 'PDO MySQL extension', |
||||||
|
'mandatory' => false, |
||||||
|
'condition' => extension_loaded('pdo_mysql'), |
||||||
|
'by' => 'All <a href="http://www.yiiframework.com/doc/api/#system.db">DB-related classes</a>', |
||||||
|
'memo' => 'Required for MySQL database.', |
||||||
|
), |
||||||
|
// Cache : |
||||||
|
array( |
||||||
|
'name' => 'Memcache extension', |
||||||
|
'mandatory' => false, |
||||||
|
'condition' => extension_loaded('memcache') || extension_loaded('memcached'), |
||||||
|
'by' => '<a href="http://www.yiiframework.com/doc/api/CMemCache">CMemCache</a>', |
||||||
|
'memo' => extension_loaded('memcached') ? 'To use memcached set <a href="http://www.yiiframework.com/doc/api/CMemCache#useMemcached-detail">CMemCache::useMemcached</a> to <code>true</code>.' : '' |
||||||
|
), |
||||||
|
array( |
||||||
|
'name' => 'APC extension', |
||||||
|
'mandatory' => false, |
||||||
|
'condition' => extension_loaded('apc') || extension_loaded('apc'), |
||||||
|
'by' => '<a href="http://www.yiiframework.com/doc/api/CApcCache">CApcCache</a>', |
||||||
|
), |
||||||
|
// Additional PHP extensions : |
||||||
|
array( |
||||||
|
'name' => 'Mcrypt extension', |
||||||
|
'mandatory' => false, |
||||||
|
'condition' => extension_loaded('mcrypt'), |
||||||
|
'by' => '<a href="http://www.yiiframework.com/doc/api/CSecurityManager">CSecurityManager</a>', |
||||||
|
'memo' => 'Required by encrypt and decrypt methods.' |
||||||
|
), |
||||||
|
// PHP ini : |
||||||
|
'phpSafeMode' => array( |
||||||
|
'name' => 'PHP safe mode', |
||||||
|
'mandatory' => false, |
||||||
|
'condition' => $requirementsChecker->checkPhpIniOff("safe_mode"), |
||||||
|
'by' => 'File uploading and console command execution', |
||||||
|
'memo' => '"safe_mode" should be disabled at 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', |
||||||
|
), |
||||||
|
); |
||||||
|
$requirementsChecker->checkYii()->check($requirements)->render(); |
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue