Browse Source

Merge branch 'upstream' into 365-bootstrap-tabs

* upstream: (122 commits)
  Refactored StringHelper.
  Line number tweak for error page
  added note about dependency to registerJsFile
  docs: Be explicitly clear about ActiveRecord::create()
  fixed AutoTimestamp example in advanced app
  \yii\rbac\DbManager::isAssigned() signature fix
  Changed the way to set timestamp for multiple attributes.
  Fixes issue #428 Allowing UniqueValidator to be used with non-AR models.
  Better exception page look.
  Removed unnecessary code from MSSQL schema.
  Hover and error line increased by 1 px.
  Error line number fix.
  Error line number fix.
  Error line number fix.
  Lift off!11 #418
  MSIE fix.
  Fixes (theoretically) #418 and #413.
  Removed echo
  RBAC DbManager fixes
  Always refetch the migration table definition.
  ...
tags/2.0.0-alpha
Antonio Ramirez 11 years ago
parent
commit
65feda3ec3
  1. 2
      README.md
  2. 1
      apps/advanced/.gitignore
  3. 0
      apps/advanced/LICENSE.md
  4. 98
      apps/advanced/README.md
  5. 0
      apps/advanced/backstage/assets/.gitkeep
  6. 2
      apps/advanced/backstage/config/.gitignore
  7. 0
      apps/advanced/backstage/config/assets.php
  8. 40
      apps/advanced/backstage/config/main.php
  9. 0
      apps/advanced/backstage/config/params.php
  10. 33
      apps/advanced/backstage/controllers/SiteController.php
  11. 0
      apps/advanced/backstage/models/.gitkeep
  12. 2
      apps/advanced/backstage/runtime/.gitignore
  13. 64
      apps/advanced/backstage/views/layouts/main.php
  14. 0
      apps/advanced/backstage/views/site/index.php
  15. 0
      apps/advanced/backstage/views/site/login.php
  16. 1
      apps/advanced/backstage/www/.gitignore
  17. 2
      apps/advanced/backstage/www/assets/.gitignore
  18. 0
      apps/advanced/backstage/www/css/site.css
  19. 1
      apps/advanced/common/config/.gitignore
  20. 16
      apps/advanced/common/config/params.php
  21. 58
      apps/advanced/common/models/LoginForm.php
  22. 114
      apps/advanced/common/models/User.php
  23. 44
      apps/advanced/composer.json
  24. 164
      apps/advanced/composer.lock
  25. 2
      apps/advanced/console/config/.gitignore
  26. 33
      apps/advanced/console/config/main.php
  27. 5
      apps/advanced/console/config/params.php
  28. 0
      apps/advanced/console/controllers/.gitkeep
  29. 27
      apps/advanced/console/migrations/m130524_201442_init.php
  30. 0
      apps/advanced/console/models/.gitkeep
  31. 2
      apps/advanced/console/runtime/.gitignore
  32. 17
      apps/advanced/environments/dev/backstage/config/main-local.php
  33. 3
      apps/advanced/environments/dev/backstage/config/params-local.php
  34. 14
      apps/advanced/environments/dev/backstage/www/index.php
  35. 3
      apps/advanced/environments/dev/common/config/params-local.php
  36. 3
      apps/advanced/environments/dev/console/config/main-local.php
  37. 3
      apps/advanced/environments/dev/console/config/params-local.php
  38. 17
      apps/advanced/environments/dev/frontend/config/main-local.php
  39. 3
      apps/advanced/environments/dev/frontend/config/params-local.php
  40. 15
      apps/advanced/environments/dev/frontend/www/index.php
  41. 25
      apps/advanced/environments/dev/yii
  42. 38
      apps/advanced/environments/index.php
  43. 3
      apps/advanced/environments/prod/backstage/config/main-local.php
  44. 3
      apps/advanced/environments/prod/backstage/config/params-local.php
  45. 14
      apps/advanced/environments/prod/backstage/www/index.php
  46. 3
      apps/advanced/environments/prod/common/config/params-local.php
  47. 3
      apps/advanced/environments/prod/console/config/main-local.php
  48. 3
      apps/advanced/environments/prod/console/config/params-local.php
  49. 3
      apps/advanced/environments/prod/frontend/config/main-local.php
  50. 3
      apps/advanced/environments/prod/frontend/config/params-local.php
  51. 15
      apps/advanced/environments/prod/frontend/www/index.php
  52. 25
      apps/advanced/environments/prod/yii
  53. 2
      apps/advanced/frontend/assets/.gitkeep
  54. 2
      apps/advanced/frontend/config/.gitignore
  55. 18
      apps/advanced/frontend/config/assets.php
  56. 40
      apps/advanced/frontend/config/main.php
  57. 5
      apps/advanced/frontend/config/params.php
  58. 61
      apps/advanced/frontend/controllers/SiteController.php
  59. 63
      apps/advanced/frontend/models/ContactForm.php
  60. 2
      apps/advanced/frontend/runtime/.gitignore
  61. 0
      apps/advanced/frontend/views/layouts/main.php
  62. 0
      apps/advanced/frontend/views/site/about.php
  63. 0
      apps/advanced/frontend/views/site/contact.php
  64. 47
      apps/advanced/frontend/views/site/index.php
  65. 24
      apps/advanced/frontend/views/site/login.php
  66. 1
      apps/advanced/frontend/www/.gitignore
  67. 2
      apps/advanced/frontend/www/assets/.gitignore
  68. 78
      apps/advanced/frontend/www/css/site.css
  69. 112
      apps/advanced/install
  70. 20
      apps/advanced/install.bat
  71. 9
      apps/advanced/requirements.php
  72. 2
      apps/advanced/vendor/.gitignore
  73. 0
      apps/advanced/yii.bat
  74. 32
      apps/basic/LICENSE.md
  75. 16
      apps/basic/README.md
  76. 0
      apps/basic/assets/.gitkeep
  77. 0
      apps/basic/commands/HelloController.php
  78. 6
      apps/basic/composer.json
  79. 164
      apps/basic/composer.lock
  80. 18
      apps/basic/config/assets.php
  81. 4
      apps/basic/config/console.php
  82. 4
      apps/basic/config/main.php
  83. 5
      apps/basic/config/params.php
  84. 0
      apps/basic/controllers/SiteController.php
  85. 0
      apps/basic/models/ContactForm.php
  86. 0
      apps/basic/models/LoginForm.php
  87. 0
      apps/basic/models/User.php
  88. 103
      apps/basic/requirements.php
  89. 2
      apps/basic/runtime/.gitignore
  90. 2
      apps/basic/vendor/.gitignore
  91. 66
      apps/basic/views/layouts/main.php
  92. 16
      apps/basic/views/site/about.php
  93. 46
      apps/basic/views/site/contact.php
  94. 47
      apps/basic/views/site/index.php
  95. 24
      apps/basic/views/site/login.php
  96. 2
      apps/basic/www/assets/.gitignore
  97. 78
      apps/basic/www/css/site.css
  98. 0
      apps/basic/www/index.php
  99. 0
      apps/basic/yii
  100. 20
      apps/basic/yii.bat
  101. Some files were not shown because too many files have changed in this diff Show More

2
README.md

@ -16,7 +16,7 @@ DIRECTORY STRUCTURE
-------------------
apps/ ready-to-use Web apps built on Yii 2
bootstrap/ a simple app supporting user login and contact page
basic/ a simple app supporting user login and contact page
build/ internally used build tools
docs/ documentation
yii/ framework source files

1
apps/advanced/.gitignore vendored

@ -0,0 +1 @@
/yii

0
apps/bootstrap/LICENSE.md → apps/advanced/LICENSE.md

98
apps/advanced/README.md

@ -0,0 +1,98 @@
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 backstage separation,
deployment in different environments, configuration nesting etc.
DIRECTORY STRUCTURE
-------------------
```
common
config/ contains shared configurations
models/ contains model classes used in both backstage 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
backstage
assets/ contains application assets such as JavaScript and CSS
config/ contains backstage configurations
controllers/ contains Web controller classes
models/ contains backstage-specific model classes
runtime/ contains files generated during runtime
views/ contains view files for the Web application
www/ 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
www/ 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.?.
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-advanced yii-advanced
~~~
Now you should be able to access:
- the frontend using the URL `http://localhost/yii-advanced/frontend/www/`
- the backstage using the URL `http://localhost/yii-advanced/backstage/www/`
assuming `yii-advanced` is directly under the document root of your Web server.
### Install from an Archive File
This is not currently available. We will provide it when Yii 2 is formally released.
GETTING STARTED
---------------
After template application and its dependencies are downloaded you need to initialize it and set some config values to
match your application requirements.
1. Execute `install` command selecting `dev` as environment.
2. Set `id` value in `console/config/main.php`, `frontend/config/main.php`, `backstage/config/main.php`.
3. Create new database. It is assumed that MySQL InnoDB is used. If not, adjust `console/migrations/m130524_201442_init.php`.
4. In `common/config/params.php` set your database details in `components.db` values.

0
apps/bootstrap/assets/.gitignore → apps/advanced/backstage/assets/.gitkeep

2
apps/advanced/backstage/config/.gitignore vendored

@ -0,0 +1,2 @@
main-local.php
params-local.php

0
apps/bootstrap/config/assets.php → apps/advanced/backstage/config/assets.php

40
apps/advanced/backstage/config/main.php

@ -0,0 +1,40 @@
<?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' => 'change-me',
'basePath' => dirname(__DIR__),
'vendorPath' => dirname(dirname(__DIR__)) . '/vendor',
'preload' => array('log'),
'controllerNamespace' => 'backstage\controllers',
'modules' => array(
),
'components' => array(
'db' => $params['components.db'],
'cache' => $params['components.cache'],
'user' => array(
'class' => 'yii\web\User',
'identityClass' => 'common\models\User',
),
'assetManager' => array(
'bundles' => require(__DIR__ . '/assets.php'),
),
'log' => array(
'class' => 'yii\logging\Router',
'targets' => array(
array(
'class' => 'yii\logging\FileTarget',
'levels' => array('error', 'warning'),
),
),
),
),
'params' => $params,
);

0
apps/bootstrap/config/params.php → apps/advanced/backstage/config/params.php

33
apps/advanced/backstage/controllers/SiteController.php

@ -0,0 +1,33 @@
<?php
namespace backstage\controllers;
use Yii;
use yii\web\Controller;
use common\models\LoginForm;
class SiteController extends Controller
{
public function actionIndex()
{
echo $this->render('index');
}
public function actionLogin()
{
$model = new LoginForm();
if ($this->populate($_POST, $model) && $model->login()) {
Yii::$app->response->redirect(array('site/index'));
} else {
echo $this->render('login', array(
'model' => $model,
));
}
}
public function actionLogout()
{
Yii::$app->getUser()->logout();
Yii::$app->getResponse()->redirect(array('site/index'));
}
}

0
apps/bootstrap/runtime/.gitignore → apps/advanced/backstage/models/.gitkeep

2
apps/advanced/backstage/runtime/.gitignore vendored

@ -0,0 +1,2 @@
*
!.gitignore

64
apps/advanced/backstage/views/layouts/main.php

@ -0,0 +1,64 @@
<?php
use yii\helpers\Html;
use yii\widgets\Menu;
use yii\widgets\Breadcrumbs;
use yii\debug\Toolbar;
/**
* @var $this \yii\base\View
* @var $content string
*/
$this->registerAssetBundle('app');
?>
<?php $this->beginPage(); ?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8"/>
<title><?php echo Html::encode($this->title); ?></title>
<?php $this->head(); ?>
</head>
<body>
<div class="container">
<?php $this->beginBody(); ?>
<div class="masthead">
<h3 class="muted">My Company</h3>
<div class="navbar">
<div class="navbar-inner">
<div class="container">
<?php echo Menu::widget(array(
'options' => array('class' => 'nav'),
'items' => array(
array('label' => 'Home', 'url' => array('/site/index')),
Yii::$app->user->isGuest ?
array('label' => 'Login', 'url' => array('/site/login')) :
array('label' => 'Logout (' . Yii::$app->user->identity->username .')' , 'url' => array('/site/logout')),
),
)); ?>
</div>
</div>
</div>
<!-- /.navbar -->
</div>
<?php echo Breadcrumbs::widget(array(
'links' => isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : array(),
)); ?>
<?php echo $content; ?>
<hr>
<div class="footer">
<p>&copy; My Company <?php echo date('Y'); ?></p>
<p>
<?php echo Yii::powered(); ?>
Template by <a href="http://twitter.github.io/bootstrap/">Twitter Bootstrap</a>
</p>
</div>
<?php $this->endBody(); ?>
</div>
<?php echo Toolbar::widget(); ?>
</body>
</html>
<?php $this->endPage(); ?>

0
apps/bootstrap/views/site/index.php → apps/advanced/backstage/views/site/index.php

0
apps/bootstrap/views/site/login.php → apps/advanced/backstage/views/site/login.php

1
apps/advanced/backstage/www/.gitignore vendored

@ -0,0 +1 @@
/index.php

2
apps/advanced/backstage/www/assets/.gitignore vendored

@ -0,0 +1,2 @@
*
!.gitignore

0
apps/bootstrap/www/css/site.css → apps/advanced/backstage/www/css/site.css

1
apps/advanced/common/config/.gitignore vendored

@ -0,0 +1 @@
params-local.php

16
apps/advanced/common/config/params.php

@ -0,0 +1,16 @@
<?php
return array(
'adminEmail' => 'admin@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' => '',
),
);

58
apps/advanced/common/models/LoginForm.php

@ -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;
}
}
}

114
apps/advanced/common/models/User.php

@ -0,0 +1,114 @@
<?php
namespace common\models;
use yii\db\ActiveRecord;
use yii\helpers\SecurityHelper;
use yii\web\Identity;
/**
* Class User
* @package common\models
*
* @property integer $id
* @property string $username
* @property string $password_hash
* @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 Identity
{
/**
* @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',
),
),
);
}
public static function findIdentity($id)
{
return static::find($id);
}
public static function findByUsername($username)
{
return static::find(array('username' => $username, 'status' => static::STATUS_ACTIVE));
}
public function getId()
{
return $this->id;
}
public function getAuthKey()
{
return $this->auth_key;
}
public function validateAuthKey($authKey)
{
return $this->auth_key === $authKey;
}
public function validatePassword($password)
{
return SecurityHelper::validatePassword($password, $this->password_hash);
}
public function rules()
{
return array(
array('username', 'filter', 'filter' => 'trim'),
array('username', 'required'),
array('username', 'length', '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.'),
array('password', 'required'),
array('password', 'length', 'min' => 6),
);
}
public function scenarios()
{
return array(
'signup' => array('username', 'email', 'password'),
'login' => array('username', 'password'),
);
}
public function beforeSave($insert)
{
if(parent::beforeSave($insert)) {
if($this->isNewRecord) {
if(!empty($this->password)) {
$this->password_hash = SecurityHelper::generatePasswordHash($this->password);
}
}
return true;
}
return false;
}
}

44
apps/advanced/composer.json

@ -0,0 +1,44 @@
{
"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-install-cmd": [
"yii\\composer\\InstallHandler::setPermissions"
],
"post-update-cmd": [
"yii\\composer\\InstallHandler::setPermissions"
]
},
"extra": {
"yii-install-writable": [
"backstage/runtime",
"backstage/www/assets",
"console/runtime",
"console/migrations",
"frontend/runtime",
"frontend/www/assets"
],
"yii-install-executable": [
"yii"
]
}
}

164
apps/advanced/composer.lock generated

@ -0,0 +1,164 @@
{
"_readme": [
"This file locks the dependencies of your project to a known state",
"Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file"
],
"hash": "0b96a35ac23eae4e84ffd588653e88d2",
"packages": [
{
"name": "yiisoft/yii2",
"version": "dev-master",
"source": {
"type": "git",
"url": "https://github.com/yiisoft/yii2-framework.git",
"reference": "15a8d0559260e39954a8eb6de0d28bfb7de95e7b"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/yiisoft/yii2-framework/zipball/15a8d0559260e39954a8eb6de0d28bfb7de95e7b",
"reference": "15a8d0559260e39954a8eb6de0d28bfb7de95e7b",
"shasum": ""
},
"require": {
"ext-mbstring": "*",
"lib-pcre": "*",
"php": ">=5.3.7"
},
"suggest": {
"ezyang/htmlpurifier": "Required by HtmlPurifier.",
"michelf/php-markdown": "Required by Markdown.",
"smarty/smarty": "Required by SmartyViewRenderer.",
"twig/twig": "Required by TwigViewRenderer."
},
"type": "library",
"autoload": {
"psr-0": {
"yii\\": "/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Qiang Xue",
"email": "qiang.xue@gmail.com",
"homepage": "http://www.yiiframework.com/",
"role": "Founder and project lead"
},
{
"name": "Alexander Makarov",
"email": "sam@rmcreative.ru",
"homepage": "http://rmcreative.ru/",
"role": "Core framework development"
},
{
"name": "Maurizio Domba",
"homepage": "http://mdomba.info/",
"role": "Core framework development"
},
{
"name": "Carsten Brandt",
"email": "mail@cebe.cc",
"homepage": "http://cebe.cc/",
"role": "Core framework development"
},
{
"name": "Wei Zhuo",
"email": "weizhuo@gmail.com",
"role": "Project site maintenance and development"
},
{
"name": "Sebastián Thierer",
"email": "sebas@artfos.com",
"role": "Component development"
},
{
"name": "Jeffrey Winesett",
"email": "jefftulsa@gmail.com",
"role": "Documentation and marketing"
},
{
"name": "Timur Ruziev",
"email": "resurtm@gmail.com",
"homepage": "http://resurtm.com/",
"role": "Core framework development"
},
{
"name": "Paul Klimov",
"email": "klimov.paul@gmail.com",
"role": "Core framework development"
}
],
"description": "Yii2 Web Programming Framework",
"homepage": "http://www.yiiframework.com/",
"keywords": [
"framework",
"yii"
],
"time": "2013-05-25 20:59:05"
},
{
"name": "yiisoft/yii2-composer",
"version": "dev-master",
"source": {
"type": "git",
"url": "https://github.com/yiisoft/yii2-composer.git",
"reference": "7ce4060faca940b836ab88de207638940a0a0568"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/yiisoft/yii2-composer/zipball/7ce4060faca940b836ab88de207638940a0a0568",
"reference": "7ce4060faca940b836ab88de207638940a0a0568",
"shasum": ""
},
"require": {
"yiisoft/yii2": "*"
},
"type": "library",
"autoload": {
"psr-0": {
"yii\\composer": ""
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Qiang Xue",
"email": "qiang.xue@gmail.com",
"homepage": "http://www.yiiframework.com/",
"role": "Founder and project lead"
}
],
"description": "The composer integration for the Yii framework",
"keywords": [
"composer",
"install",
"update",
"yii"
],
"time": "2013-05-23 19:12:45"
}
],
"packages-dev": [
],
"aliases": [
],
"minimum-stability": "dev",
"stability-flags": {
"yiisoft/yii2": 20,
"yiisoft/yii2-composer": 20
},
"platform": {
"php": ">=5.3.0"
},
"platform-dev": [
]
}

2
apps/advanced/console/config/.gitignore vendored

@ -0,0 +1,2 @@
main-local.php
params-local.php

33
apps/advanced/console/config/main.php

@ -0,0 +1,33 @@
<?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' => 'change-me',
'basePath' => dirname(__DIR__),
'vendorPath' => dirname(dirname(__DIR__)) . '/vendor',
'preload' => array('log'),
'controllerNamespace' => 'console\controllers',
'modules' => array(
),
'components' => array(
'db' => $params['components.db'],
'cache' => $params['components.cache'],
'log' => array(
'class' => 'yii\logging\Router',
'targets' => array(
array(
'class' => 'yii\logging\FileTarget',
'levels' => array('error', 'warning'),
),
),
),
),
'params' => $params,
);

5
apps/advanced/console/config/params.php

@ -0,0 +1,5 @@
<?php
return array(
'adminEmail' => 'admin@example.com',
);

0
apps/advanced/console/controllers/.gitkeep

27
apps/advanced/console/migrations/m130524_201442_init.php

@ -0,0 +1,27 @@
<?php
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',
'password_hash' => Schema::TYPE_STRING.' NOT NULL',
'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
apps/bootstrap/vendor/.gitignore → apps/advanced/console/models/.gitkeep

2
apps/advanced/console/runtime/.gitignore vendored

@ -0,0 +1,2 @@
*
!.gitignore

17
apps/advanced/environments/dev/backstage/config/main-local.php

@ -0,0 +1,17 @@
<?php
return array(
'modules' => array(
// 'debug' => array(
// 'class' => 'yii\debug\Module',
// ),
),
'components' => array(
'log' => array(
'targets' => array(
// array(
// 'class' => 'yii\logging\DebugTarget',
// )
),
),
),
);

3
apps/advanced/environments/dev/backstage/config/params-local.php

@ -0,0 +1,3 @@
<?php
return array(
);

14
apps/advanced/environments/dev/backstage/www/index.php

@ -0,0 +1,14 @@
<?php
// comment out the following line to disable debug mode
defined('YII_DEBUG') or define('YII_DEBUG', true);
require(__DIR__ . '/../../vendor/yiisoft/yii2/yii/Yii.php');
require(__DIR__ . '/../../vendor/autoload.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();

3
apps/advanced/environments/dev/common/config/params-local.php

@ -0,0 +1,3 @@
<?php
return array(
);

3
apps/advanced/environments/dev/console/config/main-local.php

@ -0,0 +1,3 @@
<?php
return array(
);

3
apps/advanced/environments/dev/console/config/params-local.php

@ -0,0 +1,3 @@
<?php
return array(
);

17
apps/advanced/environments/dev/frontend/config/main-local.php

@ -0,0 +1,17 @@
<?php
return array(
'modules' => array(
// 'debug' => array(
// 'class' => 'yii\debug\Module',
// ),
),
'components' => array(
'log' => array(
'targets' => array(
// array(
// 'class' => 'yii\logging\DebugTarget',
// )
),
),
),
);

3
apps/advanced/environments/dev/frontend/config/params-local.php

@ -0,0 +1,3 @@
<?php
return array(
);

15
apps/advanced/environments/dev/frontend/www/index.php

@ -0,0 +1,15 @@
<?php
// comment out the following line to disable debug mode
defined('YII_DEBUG') or define('YII_DEBUG', true);
require(__DIR__ . '/../../vendor/yiisoft/yii2/yii/Yii.php');
require(__DIR__ . '/../../vendor/autoload.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();

25
apps/advanced/environments/dev/yii

@ -0,0 +1,25 @@
#!/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);
// fcgi doesn't have STDIN defined by default
defined('STDIN') or define('STDIN', fopen('php://stdin', 'r'));
require(__DIR__ . '/vendor/yiisoft/yii2/yii/Yii.php');
require(__DIR__ . '/vendor/autoload.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);
$application->run();

38
apps/advanced/environments/index.php

@ -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(
'yiic',
),
),
'Production' => array(
'path' => 'prod',
'writable' => array(
// handled by composer.json already
),
'executable' => array(
'yiic',
),
),
);

3
apps/advanced/environments/prod/backstage/config/main-local.php

@ -0,0 +1,3 @@
<?php
return array(
);

3
apps/advanced/environments/prod/backstage/config/params-local.php

@ -0,0 +1,3 @@
<?php
return array(
);

14
apps/advanced/environments/prod/backstage/www/index.php

@ -0,0 +1,14 @@
<?php
// comment out the following line to disable debug mode
defined('YII_DEBUG') or define('YII_DEBUG', false);
require(__DIR__ . '/../../vendor/yiisoft/yii2/yii/Yii.php');
require(__DIR__ . '/../../vendor/autoload.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();

3
apps/advanced/environments/prod/common/config/params-local.php

@ -0,0 +1,3 @@
<?php
return array(
);

3
apps/advanced/environments/prod/console/config/main-local.php

@ -0,0 +1,3 @@
<?php
return array(
);

3
apps/advanced/environments/prod/console/config/params-local.php

@ -0,0 +1,3 @@
<?php
return array(
);

3
apps/advanced/environments/prod/frontend/config/main-local.php

@ -0,0 +1,3 @@
<?php
return array(
);

3
apps/advanced/environments/prod/frontend/config/params-local.php

@ -0,0 +1,3 @@
<?php
return array(
);

15
apps/advanced/environments/prod/frontend/www/index.php

@ -0,0 +1,15 @@
<?php
// comment out the following line to disable debug mode
defined('YII_DEBUG') or define('YII_DEBUG', false);
require(__DIR__ . '/../../vendor/yiisoft/yii2/yii/Yii.php');
require(__DIR__ . '/../../vendor/autoload.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();

25
apps/advanced/environments/prod/yii

@ -0,0 +1,25 @@
#!/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);
// fcgi doesn't have STDIN defined by default
defined('STDIN') or define('STDIN', fopen('php://stdin', 'r'));
require(__DIR__ . '/vendor/yiisoft/yii2/yii/Yii.php');
require(__DIR__ . '/vendor/autoload.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);
$application->run();

2
apps/advanced/frontend/assets/.gitkeep

@ -0,0 +1,2 @@
*
!.gitignore

2
apps/advanced/frontend/config/.gitignore vendored

@ -0,0 +1,2 @@
main-local.php
params-local.php

18
apps/advanced/frontend/config/assets.php

@ -0,0 +1,18 @@
<?php
return array(
'app' => array(
'basePath' => '@wwwroot',
'baseUrl' => '@www',
'css' => array(
'css/site.css',
),
'js' => array(
),
'depends' => array(
'yii',
'yii/bootstrap/responsive',
),
),
);

40
apps/advanced/frontend/config/main.php

@ -0,0 +1,40 @@
<?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' => 'change-me',
'basePath' => dirname(__DIR__),
'vendorPath' => dirname(dirname(__DIR__)) . '/vendor',
'preload' => array('log'),
'controllerNamespace' => 'frontend\controllers',
'modules' => array(
),
'components' => array(
'db' => $params['components.db'],
'cache' => $params['components.cache'],
'user' => array(
'class' => 'yii\web\User',
'identityClass' => 'common\models\User',
),
'assetManager' => array(
'bundles' => require(__DIR__ . '/assets.php'),
),
'log' => array(
'class' => 'yii\logging\Router',
'targets' => array(
array(
'class' => 'yii\logging\FileTarget',
'levels' => array('error', 'warning'),
),
),
),
),
'params' => $params,
);

5
apps/advanced/frontend/config/params.php

@ -0,0 +1,5 @@
<?php
return array(
'adminEmail' => 'admin@example.com',
);

61
apps/advanced/frontend/controllers/SiteController.php

@ -0,0 +1,61 @@
<?php
namespace frontend\controllers;
use Yii;
use yii\web\Controller;
use common\models\LoginForm;
use frontend\models\ContactForm;
class SiteController extends Controller
{
public function actions()
{
return array(
'captcha' => array(
'class' => 'yii\web\CaptchaAction',
),
);
}
public function actionIndex()
{
echo $this->render('index');
}
public function actionLogin()
{
$model = new LoginForm();
if ($this->populate($_POST, $model) && $model->login()) {
Yii::$app->response->redirect(array('site/index'));
} else {
echo $this->render('login', array(
'model' => $model,
));
}
}
public function actionLogout()
{
Yii::$app->getUser()->logout();
Yii::$app->getResponse()->redirect(array('site/index'));
}
public function actionContact()
{
$model = new ContactForm;
if ($this->populate($_POST, $model) && $model->contact(Yii::$app->params['adminEmail'])) {
Yii::$app->session->setFlash('contactFormSubmitted');
Yii::$app->response->refresh();
} else {
echo $this->render('contact', array(
'model' => $model,
));
}
}
public function actionAbout()
{
echo $this->render('about');
}
}

63
apps/advanced/frontend/models/ContactForm.php

@ -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;
}
}
}

2
apps/advanced/frontend/runtime/.gitignore vendored

@ -0,0 +1,2 @@
*
!.gitignore

0
apps/bootstrap/views/layouts/main.php → apps/advanced/frontend/views/layouts/main.php

0
apps/bootstrap/views/site/about.php → apps/advanced/frontend/views/site/about.php

0
apps/bootstrap/views/site/contact.php → apps/advanced/frontend/views/site/contact.php

47
apps/advanced/frontend/views/site/index.php

@ -0,0 +1,47 @@
<?php
/**
* @var yii\base\View $this
*/
$this->title = 'Welcome';
?>
<div class="jumbotron">
<h1>Welcome!</h1>
<p class="lead">Cras justo odio, dapibus ac facilisis in, egestas eget quam. Fusce dapibus, tellus ac cursus
commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus.</p>
<a class="btn btn-large btn-success" href="http://www.yiiframework.com">Get started with Yii</a>
</div>
<hr>
<!-- Example row of columns -->
<div class="row-fluid">
<div class="span4">
<h2>Heading</h2>
<p>Donec id elit non mi porta gravida at eget metus. Fusce dapibus, tellus ac cursus commodo, tortor mauris
condimentum nibh, ut fermentum massa justo sit amet risus. Etiam porta sem malesuada magna mollis euismod.
Donec sed odio dui. </p>
<p><a class="btn" href="#">View details &raquo;</a></p>
</div>
<div class="span4">
<h2>Heading</h2>
<p>Donec id elit non mi porta gravida at eget metus. Fusce dapibus, tellus ac cursus commodo, tortor mauris
condimentum nibh, ut fermentum massa justo sit amet risus. Etiam porta sem malesuada magna mollis euismod.
Donec sed odio dui. </p>
<p><a class="btn" href="#">View details &raquo;</a></p>
</div>
<div class="span4">
<h2>Heading</h2>
<p>Donec sed odio dui. Cras justo odio, dapibus ac facilisis in, egestas eget quam. Vestibulum id ligula porta
felis euismod semper. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum
massa.</p>
<p><a class="btn" href="#">View details &raquo;</a></p>
</div>
</div>

24
apps/advanced/frontend/views/site/login.php

@ -0,0 +1,24 @@
<?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;
?>
<h1><?php echo Html::encode($this->title); ?></h1>
<p>Please fill out the following fields to login:</p>
<?php $form = ActiveForm::begin(array('options' => array('class' => 'form-horizontal'))); ?>
<?php echo $form->field($model, 'username')->textInput(); ?>
<?php echo $form->field($model, 'password')->passwordInput(); ?>
<?php echo $form->field($model, 'rememberMe')->checkbox(); ?>
<div class="form-actions">
<?php echo Html::submitButton('Login', null, null, array('class' => 'btn btn-primary')); ?>
</div>
<?php ActiveForm::end(); ?>

1
apps/advanced/frontend/www/.gitignore vendored

@ -0,0 +1 @@
/index.php

2
apps/advanced/frontend/www/assets/.gitignore vendored

@ -0,0 +1,2 @@
*
!.gitignore

78
apps/advanced/frontend/www/css/site.css

@ -0,0 +1,78 @@
body {
padding-top: 20px;
padding-bottom: 60px;
}
/* Custom container */
.container {
margin: 0 auto;
max-width: 1000px;
}
.container > hr {
margin: 60px 0;
}
/* Main marketing message and sign up button */
.jumbotron {
margin: 80px 0;
text-align: center;
}
.jumbotron h1 {
font-size: 100px;
line-height: 1;
}
.jumbotron .lead {
font-size: 24px;
line-height: 1.25;
}
.jumbotron .btn {
font-size: 21px;
padding: 14px 24px;
}
/* Supporting marketing content */
.marketing {
margin: 60px 0;
}
.marketing p + h4 {
margin-top: 28px;
}
/* Customize the navbar links to be fill the entire space of the .navbar */
.navbar .navbar-inner {
padding: 0;
}
.navbar .nav {
margin: 0;
display: table;
width: 100%;
}
.navbar .nav li {
display: table-cell;
width: 1%;
float: none;
}
.navbar .nav li a {
font-weight: bold;
text-align: center;
border-left: 1px solid rgba(255, 255, 255, .75);
border-right: 1px solid rgba(0, 0, 0, .1);
}
.navbar .nav li:first-child a {
border-left: 0;
border-radius: 3px 0 0 3px;
}
.navbar .nav li:last-child a {
border-right: 0;
border-radius: 0 3px 3px 0;
}

112
apps/advanced/install

@ -0,0 +1,112 @@
#!/usr/bin/env php
<?php
$root = str_replace('\\', '/', __DIR__);
$envs = require("$root/environments/index.php");
$envNames = array_keys($envs);
echo "Yii Application Installation Tool v1.0\n\n";
echo "Which environment do you want to install the application to?\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) || !isset($envNames[$answer])) {
echo "\n Quit installation.\n";
return;
}
$env = $envs[$envNames[$answer]];
echo "\n Install the application under '{$envNames[$answer]}' environment? [yes|no] ";
$answer = trim(fgets(STDIN));
if (strncasecmp($answer, 'y', 1)) {
echo "\n Quit installation.\n";
return;
}
echo "\n Start installation ...\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 ... installation 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;
}

20
apps/advanced/install.bat

@ -0,0 +1,20 @@
@echo off
rem -------------------------------------------------------------
rem Yii command line install script for Windows.
rem
rem @author Qiang Xue <qiang.xue@gmail.com>
rem @link http://www.yiiframework.com/
rem @copyright Copyright &copy; 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%install" %*
@endlocal

9
apps/bootstrap/requirements.php → apps/advanced/requirements.php

@ -11,7 +11,14 @@
*/
// you may need to adjust this path to the correct Yii framework path
$frameworkPath = dirname(__FILE__) . '/../../yii';
$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();

2
apps/advanced/vendor/.gitignore vendored

@ -0,0 +1,2 @@
*
!.gitignore

0
apps/bootstrap/yii.bat → apps/advanced/yii.bat

32
apps/basic/LICENSE.md

@ -0,0 +1,32 @@
The Yii framework is free software. It is released under the terms of
the following BSD License.
Copyright © 2008-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.

16
apps/bootstrap/README.md → apps/basic/README.md

@ -1,5 +1,5 @@
Yii 2 Bootstrap Application
===========================
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
@ -7,10 +7,10 @@ use them for production. Please consider using [Yii v1.1](https://github.com/yii
if you have a project to be deployed for production soon.
Thank you for choosing Yii 2 - the new generation of high-performance PHP framework.
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.
The Yii 2 Bootstrap Application is a Web application template that you can easily customize
to fit for your needs. It is particularly suitable for small Websites which mainly contain
Yii 2 Basic Application Template is best suitable for small Websites which mainly contain
a few informational pages.
@ -49,11 +49,11 @@ 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-bootstrap bootstrap
php composer.phar create-project --stability=dev yiisoft/yii2-app-basic yii-basic
~~~
Now you should be able to access the Bootstrap Application using the URL `http://localhost/bootstrap/www/`,
assuming `bootstrap` is directly under the document root of your Web server.
Now you should be able to access the application using the URL `http://localhost/yii-basic/www/`,
assuming `yii-basic` is directly under the document root of your Web server.
### Install from an Archive File

0
apps/bootstrap/www/assets/.gitignore → apps/basic/assets/.gitkeep

0
apps/bootstrap/commands/HelloController.php → apps/basic/commands/HelloController.php

6
apps/bootstrap/composer.json → apps/basic/composer.json

@ -1,7 +1,7 @@
{
"name": "yiisoft/yii2-bootstrap",
"description": "Yii 2 Bootstrap Application",
"keywords": ["yii", "framework", "bootstrap"],
"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",

164
apps/basic/composer.lock generated

@ -0,0 +1,164 @@
{
"_readme": [
"This file locks the dependencies of your project to a known state",
"Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file"
],
"hash": "0411dbbd774aa1c89256c77c68023940",
"packages": [
{
"name": "yiisoft/yii2",
"version": "dev-master",
"source": {
"type": "git",
"url": "https://github.com/yiisoft/yii2-framework.git",
"reference": "15a8d0559260e39954a8eb6de0d28bfb7de95e7b"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/yiisoft/yii2-framework/zipball/15a8d0559260e39954a8eb6de0d28bfb7de95e7b",
"reference": "15a8d0559260e39954a8eb6de0d28bfb7de95e7b",
"shasum": ""
},
"require": {
"ext-mbstring": "*",
"lib-pcre": "*",
"php": ">=5.3.7"
},
"suggest": {
"ezyang/htmlpurifier": "Required by HtmlPurifier.",
"michelf/php-markdown": "Required by Markdown.",
"smarty/smarty": "Required by SmartyViewRenderer.",
"twig/twig": "Required by TwigViewRenderer."
},
"type": "library",
"autoload": {
"psr-0": {
"yii\\": "/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Qiang Xue",
"email": "qiang.xue@gmail.com",
"homepage": "http://www.yiiframework.com/",
"role": "Founder and project lead"
},
{
"name": "Alexander Makarov",
"email": "sam@rmcreative.ru",
"homepage": "http://rmcreative.ru/",
"role": "Core framework development"
},
{
"name": "Maurizio Domba",
"homepage": "http://mdomba.info/",
"role": "Core framework development"
},
{
"name": "Carsten Brandt",
"email": "mail@cebe.cc",
"homepage": "http://cebe.cc/",
"role": "Core framework development"
},
{
"name": "Wei Zhuo",
"email": "weizhuo@gmail.com",
"role": "Project site maintenance and development"
},
{
"name": "Sebastián Thierer",
"email": "sebas@artfos.com",
"role": "Component development"
},
{
"name": "Jeffrey Winesett",
"email": "jefftulsa@gmail.com",
"role": "Documentation and marketing"
},
{
"name": "Timur Ruziev",
"email": "resurtm@gmail.com",
"homepage": "http://resurtm.com/",
"role": "Core framework development"
},
{
"name": "Paul Klimov",
"email": "klimov.paul@gmail.com",
"role": "Core framework development"
}
],
"description": "Yii2 Web Programming Framework",
"homepage": "http://www.yiiframework.com/",
"keywords": [
"framework",
"yii"
],
"time": "2013-05-25 20:59:05"
},
{
"name": "yiisoft/yii2-composer",
"version": "dev-master",
"source": {
"type": "git",
"url": "https://github.com/yiisoft/yii2-composer.git",
"reference": "7ce4060faca940b836ab88de207638940a0a0568"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/yiisoft/yii2-composer/zipball/7ce4060faca940b836ab88de207638940a0a0568",
"reference": "7ce4060faca940b836ab88de207638940a0a0568",
"shasum": ""
},
"require": {
"yiisoft/yii2": "*"
},
"type": "library",
"autoload": {
"psr-0": {
"yii\\composer": ""
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Qiang Xue",
"email": "qiang.xue@gmail.com",
"homepage": "http://www.yiiframework.com/",
"role": "Founder and project lead"
}
],
"description": "The composer integration for the Yii framework",
"keywords": [
"composer",
"install",
"update",
"yii"
],
"time": "2013-05-23 19:12:45"
}
],
"packages-dev": [
],
"aliases": [
],
"minimum-stability": "dev",
"stability-flags": {
"yiisoft/yii2": 20,
"yiisoft/yii2-composer": 20
},
"platform": {
"php": ">=5.3.0"
},
"platform-dev": [
]
}

18
apps/basic/config/assets.php

@ -0,0 +1,18 @@
<?php
return array(
'app' => array(
'basePath' => '@wwwroot',
'baseUrl' => '@www',
'css' => array(
'css/site.css',
),
'js' => array(
),
'depends' => array(
'yii',
'yii/bootstrap/responsive',
),
),
);

4
apps/bootstrap/config/console.php → apps/basic/config/console.php

@ -1,5 +1,5 @@
<?php
$params = require(__DIR__ . '/params.php');
return array(
'id' => 'bootstrap-console',
'basePath' => dirname(__DIR__),
@ -22,5 +22,5 @@ return array(
),
),
),
'params' => require(__DIR__ . '/params.php'),
'params' => $params,
);

4
apps/bootstrap/config/main.php → apps/basic/config/main.php

@ -1,5 +1,5 @@
<?php
$params = require(__DIR__ . '/params.php');
return array(
'id' => 'bootstrap',
'basePath' => dirname(__DIR__),
@ -34,5 +34,5 @@ return array(
),
),
),
'params' => require(__DIR__ . '/params.php'),
'params' => $params,
);

5
apps/basic/config/params.php

@ -0,0 +1,5 @@
<?php
return array(
'adminEmail' => 'admin@example.com',
);

0
apps/bootstrap/controllers/SiteController.php → apps/basic/controllers/SiteController.php

0
apps/bootstrap/models/ContactForm.php → apps/basic/models/ContactForm.php

0
apps/bootstrap/models/LoginForm.php → apps/basic/models/LoginForm.php

0
apps/bootstrap/models/User.php → apps/basic/models/User.php

103
apps/basic/requirements.php

@ -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();

2
apps/basic/runtime/.gitignore vendored

@ -0,0 +1,2 @@
*
!.gitignore

2
apps/basic/vendor/.gitignore vendored

@ -0,0 +1,2 @@
*
!.gitignore

66
apps/basic/views/layouts/main.php

@ -0,0 +1,66 @@
<?php
use yii\helpers\Html;
use yii\widgets\Menu;
use yii\widgets\Breadcrumbs;
use yii\debug\Toolbar;
/**
* @var $this \yii\base\View
* @var $content string
*/
$this->registerAssetBundle('app');
?>
<?php $this->beginPage(); ?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8"/>
<title><?php echo Html::encode($this->title); ?></title>
<?php $this->head(); ?>
</head>
<body>
<div class="container">
<?php $this->beginBody(); ?>
<div class="masthead">
<h3 class="muted">My Company</h3>
<div class="navbar">
<div class="navbar-inner">
<div class="container">
<?php echo Menu::widget(array(
'options' => array('class' => 'nav'),
'items' => array(
array('label' => 'Home', 'url' => array('/site/index')),
array('label' => 'About', 'url' => array('/site/about')),
array('label' => 'Contact', 'url' => array('/site/contact')),
Yii::$app->user->isGuest ?
array('label' => 'Login', 'url' => array('/site/login')) :
array('label' => 'Logout (' . Yii::$app->user->identity->username .')' , 'url' => array('/site/logout')),
),
)); ?>
</div>
</div>
</div>
<!-- /.navbar -->
</div>
<?php echo Breadcrumbs::widget(array(
'links' => isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : array(),
)); ?>
<?php echo $content; ?>
<hr>
<div class="footer">
<p>&copy; My Company <?php echo date('Y'); ?></p>
<p>
<?php echo Yii::powered(); ?>
Template by <a href="http://twitter.github.io/bootstrap/">Twitter Bootstrap</a>
</p>
</div>
<?php $this->endBody(); ?>
</div>
<?php echo Toolbar::widget(); ?>
</body>
</html>
<?php $this->endPage(); ?>

16
apps/basic/views/site/about.php

@ -0,0 +1,16 @@
<?php
use yii\helpers\Html;
/**
* @var yii\base\View $this
*/
$this->title = 'About';
$this->params['breadcrumbs'][] = $this->title;
?>
<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>

46
apps/basic/views/site/contact.php

@ -0,0 +1,46 @@
<?php
use yii\helpers\Html;
use yii\widgets\ActiveForm;
use yii\widgets\Captcha;
/**
* @var yii\base\View $this
* @var yii\widgets\ActiveForm $form
* @var app\models\ContactForm $model
*/
$this->title = 'Contact';
$this->params['breadcrumbs'][] = $this->title;
?>
<h1><?php echo Html::encode($this->title); ?></h1>
<?php if (Yii::$app->session->hasFlash('contactFormSubmitted')): ?>
<div class="alert alert-success">
Thank you for contacting us. We will respond to you as soon as possible.
</div>
<?php return; endif; ?>
<p>
If you have business inquiries or other questions, please fill out the following form to contact us. Thank you.
</p>
<?php $form = ActiveForm::begin(array(
'options' => array('class' => 'form-horizontal'),
'fieldConfig' => array('inputOptions' => array('class' => 'input-xlarge')),
)); ?>
<?php echo $form->field($model, 'name')->textInput(); ?>
<?php echo $form->field($model, 'email')->textInput(); ?>
<?php echo $form->field($model, 'subject')->textInput(); ?>
<?php echo $form->field($model, 'body')->textArea(array('rows' => 6)); ?>
<?php
$field = $form->field($model, 'verifyCode');
echo $field->begin()
. $field->label()
. Captcha::widget()
. Html::activeTextInput($model, 'verifyCode', array('class' => 'input-medium'))
. $field->error()
. $field->end();
?>
<div class="form-actions">
<?php echo Html::submitButton('Submit', null, null, array('class' => 'btn btn-primary')); ?>
</div>
<?php ActiveForm::end(); ?>

47
apps/basic/views/site/index.php

@ -0,0 +1,47 @@
<?php
/**
* @var yii\base\View $this
*/
$this->title = 'Welcome';
?>
<div class="jumbotron">
<h1>Welcome!</h1>
<p class="lead">Cras justo odio, dapibus ac facilisis in, egestas eget quam. Fusce dapibus, tellus ac cursus
commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus.</p>
<a class="btn btn-large btn-success" href="http://www.yiiframework.com">Get started with Yii</a>
</div>
<hr>
<!-- Example row of columns -->
<div class="row-fluid">
<div class="span4">
<h2>Heading</h2>
<p>Donec id elit non mi porta gravida at eget metus. Fusce dapibus, tellus ac cursus commodo, tortor mauris
condimentum nibh, ut fermentum massa justo sit amet risus. Etiam porta sem malesuada magna mollis euismod.
Donec sed odio dui. </p>
<p><a class="btn" href="#">View details &raquo;</a></p>
</div>
<div class="span4">
<h2>Heading</h2>
<p>Donec id elit non mi porta gravida at eget metus. Fusce dapibus, tellus ac cursus commodo, tortor mauris
condimentum nibh, ut fermentum massa justo sit amet risus. Etiam porta sem malesuada magna mollis euismod.
Donec sed odio dui. </p>
<p><a class="btn" href="#">View details &raquo;</a></p>
</div>
<div class="span4">
<h2>Heading</h2>
<p>Donec sed odio dui. Cras justo odio, dapibus ac facilisis in, egestas eget quam. Vestibulum id ligula porta
felis euismod semper. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum
massa.</p>
<p><a class="btn" href="#">View details &raquo;</a></p>
</div>
</div>

24
apps/basic/views/site/login.php

@ -0,0 +1,24 @@
<?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;
?>
<h1><?php echo Html::encode($this->title); ?></h1>
<p>Please fill out the following fields to login:</p>
<?php $form = ActiveForm::begin(array('options' => array('class' => 'form-horizontal'))); ?>
<?php echo $form->field($model, 'username')->textInput(); ?>
<?php echo $form->field($model, 'password')->passwordInput(); ?>
<?php echo $form->field($model, 'rememberMe')->checkbox(); ?>
<div class="form-actions">
<?php echo Html::submitButton('Login', null, null, array('class' => 'btn btn-primary')); ?>
</div>
<?php ActiveForm::end(); ?>

2
apps/basic/www/assets/.gitignore vendored

@ -0,0 +1,2 @@
*
!.gitignore

78
apps/basic/www/css/site.css

@ -0,0 +1,78 @@
body {
padding-top: 20px;
padding-bottom: 60px;
}
/* Custom container */
.container {
margin: 0 auto;
max-width: 1000px;
}
.container > hr {
margin: 60px 0;
}
/* Main marketing message and sign up button */
.jumbotron {
margin: 80px 0;
text-align: center;
}
.jumbotron h1 {
font-size: 100px;
line-height: 1;
}
.jumbotron .lead {
font-size: 24px;
line-height: 1.25;
}
.jumbotron .btn {
font-size: 21px;
padding: 14px 24px;
}
/* Supporting marketing content */
.marketing {
margin: 60px 0;
}
.marketing p + h4 {
margin-top: 28px;
}
/* Customize the navbar links to be fill the entire space of the .navbar */
.navbar .navbar-inner {
padding: 0;
}
.navbar .nav {
margin: 0;
display: table;
width: 100%;
}
.navbar .nav li {
display: table-cell;
width: 1%;
float: none;
}
.navbar .nav li a {
font-weight: bold;
text-align: center;
border-left: 1px solid rgba(255, 255, 255, .75);
border-right: 1px solid rgba(0, 0, 0, .1);
}
.navbar .nav li:first-child a {
border-left: 0;
border-radius: 3px 0 0 3px;
}
.navbar .nav li:last-child a {
border-right: 0;
border-radius: 0 3px 3px 0;
}

0
apps/bootstrap/www/index.php → apps/basic/www/index.php

0
apps/bootstrap/yii → apps/basic/yii

20
apps/basic/yii.bat

@ -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 &copy; 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

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save