Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yii2
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PSDI Army
yii2
Commits
ef0d709f
Commit
ef0d709f
authored
Jul 28, 2013
by
Qiang Xue
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of github.com:yiisoft/yii2
parents
539be8eb
68d2bc2f
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
55 additions
and
48 deletions
+55
-48
.travis.yml
.travis.yml
+4
-6
README.md
README.md
+1
-1
SiteController.php
apps/benchmark/protected/controllers/SiteController.php
+2
-0
build.bat
build/build.bat
+23
-22
bootstrap.md
docs/guide/bootstrap.md
+1
-1
index.md
docs/guide/index.md
+1
-1
installation.md
docs/guide/installation.md
+1
-1
model.md
docs/guide/model.md
+17
-11
mvc.md
docs/guide/mvc.md
+1
-1
ErrorHandler.php
framework/yii/base/ErrorHandler.php
+1
-1
DetailView.php
framework/yii/widgets/DetailView.php
+3
-3
No files found.
.travis.yml
View file @
ef0d709f
...
...
@@ -5,11 +5,8 @@ php:
-
5.4
-
5.5
env
:
-
DB=mysql
before_script
:
-
sh -c "if [ '$DB' = 'mysql' ]; then mysql -e 'create database IF NOT EXISTS yiitest;'; fi"
-
psql -U postgres -c '
drop database if exists yiitest;';
-
psql -U postgres -c 'create database yiitest;';
-
mysql -e 'CREATE DATABASE yiitest;';
-
psql -U postgres -c '
CREATE DATABASE yiitest;';
script
:
phpunit
\ No newline at end of file
README.md
View file @
ef0d709f
...
...
@@ -9,7 +9,7 @@ If you are looking for a production-ready PHP framework, please use
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.**
[
![Build Status
](
https://secure.travis-ci.org/yiisoft/yii2.png
)
](http://travis-ci.org/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/benchmark/protected/controllers/SiteController.php
View file @
ef0d709f
<?php
namespace
app\controllers
;
use
yii\web\Controller
;
class
SiteController
extends
Controller
...
...
build/build.bat
View file @
ef0d709f
@echo off
rem -------------------------------------------------------------
rem build script for Windows.
rem
rem This is the bootstrap script for running build on Windows.
rem
rem @author Qiang Xue <qiang.xue@gmail.com>
rem @link http://www.yiiframework.com/
rem @copyright 2008 Yii Software LLC
rem @license http://www.yiiframework.com/license/
rem @version $Id$
rem -------------------------------------------------------------
@setlocal
set BUILD_PATH=%~dp0
if "%PHP_COMMAND%" == "" set PHP_COMMAND=php.exe
%PHP_COMMAND% "%BUILD_PATH%build" %*
@echo off
rem -------------------------------------------------------------
rem build script for Windows.
rem
rem This is the bootstrap script for running build on Windows.
rem
rem @author Qiang Xue <qiang.xue@gmail.com>
rem @link http://www.yiiframework.com/
rem @copyright 2008 Yii Software LLC
rem @license http://www.yiiframework.com/license/
rem @version $Id$
rem -------------------------------------------------------------
@setlocal
set BUILD_PATH=%~dp0
if "%PHP_COMMAND%" == "" set PHP_COMMAND=php.exe
%PHP_COMMAND% "%BUILD_PATH%build" %*
@endlocal
\ No newline at end of file
docs/guide/bootstrap.md
View file @
ef0d709f
...
...
@@ -4,7 +4,7 @@ Bootstrap with Yii
Yii provides a few ready-to-use application templates. Based on your needs, you may
choose one of them to bootstrap your project.
In following, we describe how to get started with the "Yii 2 Basic Application Template".
In
the
following, we describe how to get started with the "Yii 2 Basic Application Template".
### Install via Composer
...
...
docs/guide/index.md
View file @
ef0d709f
...
...
@@ -14,9 +14,9 @@ Base concepts
=============
-
[
MVC Overview
](
mvc.md
)
-
[
Controller
](
controller.md
)
-
[
Model
](
model.md
)
-
[
View
](
view.md
)
-
[
Controller
](
controller.md
)
-
[
Application
](
application.md
)
Database
...
...
docs/guide/installation.md
View file @
ef0d709f
...
...
@@ -24,7 +24,7 @@ script via the following URL in a Web browser:
http://hostname/path/to/yii/requirements/index.php
~~~
Yii requires PHP 5.3
, so the server must have PHP 5.3
or above installed and
Yii requires PHP 5.3
.7, so the server must have PHP 5.3.7
or above installed and
available to the web server. Yii has been tested with
[
Apache HTTP server
](
http://httpd.apache.org/
)
on Windows and Linux. It may also run on other Web servers and platforms,
provided PHP 5.3 is supported.
...
...
docs/guide/model.md
View file @
ef0d709f
...
...
@@ -27,8 +27,8 @@ echo $post->title;
echo
$post
->
content
;
```
Since
model implements
[
ArrayAccess
](
http://php.net/manual/en/class.arrayaccess.php
)
interface you can use it
as if it was an array
:
Since
[
[\yii\base\Model|Model
]
] implements the
[
ArrayAccess
](
http://php.net/manual/en/class.arrayaccess.php
)
interface,
you can also access the attributes like accessing array elements
:
```
php
$post
=
new
Post
;
...
...
@@ -38,8 +38,9 @@ echo $post['title'];
echo
$post
[
'content'
];
```
Default model implementation has a strict rule that all its attributes should be explicitly declared as public and
non-static class properties such as the following:
By default,
[
[\yii\base\Model|Model
]
] requires that attributes be declared as
*public*
and
*non-static*
class member variables. In the following example, the
`LoginForm`
model class declares two attributes:
`username`
and
`password`
.
```
php
// LoginForm has two attributes: username and password
...
...
@@ -50,17 +51,22 @@ class LoginForm extends \yii\base\Model
}
```
In order to change this, you can override
`attributes()`
method that returns a list of model attribute names.
Derived model classes may use different ways to declare attributes by overriding the
[
[\yii\base\Model::attributes()|attributes()
]
]
method. For example,
[
[\yii\db\ActiveRecord
]
] defines attributes as the column names of the database table
that is associated with the class.
Attribute
l
abels
Attribute
L
abels
----------------
Attribute labels are mainly used for display purpose. For example, given an attribute
`firstName`
, we can declare
a label
`First Name`
which is more user-friendly and can be displayed to end users for example as a form label.
a label
`First Name`
which is more user-friendly and can be displayed to end users in places such as form labels,
error messages. Given an attribute name, you can obtain its label by calling
[
[\yii\base\Model::getAttributeLabel()
]
].
By default an attribute label is generated using
[
[\yii\base\Model\generateAttributeLabel()
]
] but the better way is to
specify it explicitly like the following:
To declare attribute labels, you should override the
[
[\yii\base\Model::attributeLabels()
]
] method and return
a mapping from attribute names to attribute labels, like shown in the example below. If an attribute is not found
in this mapping, its label will be generated using the
[
[\yii\base\Model::generateAttributeLabel()
]
] method, which
in many cases, will generate reasonable labels (e.g.
`username`
to
`Username`
,
`orderNumber`
to
`Order Number`
).
```
php
// LoginForm has two attributes: username and password
...
...
@@ -71,7 +77,7 @@ class LoginForm extends \yii\base\Model
public
function
attributeLabels
()
{
re
u
turn
array
(
return
array
(
'username'
=>
'Your name'
,
'password'
=>
'Your password'
,
);
...
...
@@ -85,7 +91,7 @@ Scenarios
A model may be used in different scenarios. For example, a
`User`
model may be used to collect user login inputs,
and it may also be used for user registration purpose. For this reason, each model has a property named
`scenario`
which stores the name of the scenario that the model is currently being used in. As we will explain in the next
few sections, the concept of scenario is mainly used for validation and massive attribute assignment.
few sections, the concept of scenario is mainly used for
data
validation and massive attribute assignment.
Associated with each scenario is a list of attributes that are
*active*
in that particular scenario. For example,
in the
`login`
scenario, only the
`username`
and
`password`
attributes are active; while in the
`register`
scenario,
...
...
docs/guide/mvc.md
View file @
ef0d709f
...
...
@@ -10,7 +10,7 @@ of the user interface such as text, form inputs; and the controller manages
the communication between the model and the view.
Besides implementing MVC, Yii also introduces a front-controller, called
`
A
pplication`
, which encapsulates the execution context for the processing
`
a
pplication`
, which encapsulates the execution context for the processing
of a request. Application collects information about a user request and
then dispatches it to an appropriate controller for further handling.
...
...
framework/yii/base/ErrorHandler.php
View file @
ef0d709f
...
...
@@ -37,7 +37,7 @@ class ErrorHandler extends Component
/**
* @var string the route (e.g. 'site/error') to the controller action that will be used
* to display external errors. Inside the action, it can retrieve the error information
* by Yii::$app->errorHandler->e
rror
. This property defaults to null, meaning ErrorHandler
* by Yii::$app->errorHandler->e
xception
. This property defaults to null, meaning ErrorHandler
* will handle the error display.
*/
public
$errorAction
;
...
...
framework/yii/widgets/DetailView.php
View file @
ef0d709f
...
...
@@ -30,8 +30,8 @@ use yii\helpers\Inflector;
* A typical usage of DetailView is as follows:
*
* ~~~
*
\yii\widgets\
DetailView::widget(array(
* '
data
' => $model,
*
echo
DetailView::widget(array(
* '
model
' => $model,
* 'attributes' => array(
* 'title', // title attribute (in plain text)
* 'description:html', // description attribute in HTML
...
...
@@ -90,7 +90,7 @@ class DetailView extends Widget
* @var array the HTML attributes for the container tag of this widget. The "tag" option specifies
* what container tag should be used. It defaults to "table" if not set.
*/
public
$options
=
array
(
'class'
=>
'table table-striped'
);
public
$options
=
array
(
'class'
=>
'table table-striped
table-bordered
'
);
/**
* @var array|Formatter the formatter used to format model attribute values into displayable texts.
* This can be either an instance of [[Formatter]] or an configuration array for creating the [[Formatter]]
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment