Commit 55e761a6 by Qiang Xue

Fixes #6059.

parent 544981a4
......@@ -28,7 +28,7 @@ Por ejemplo, si el nombre de una clase es `foo\bar\MyClass`, el [alias](concept-
archivo de la clase sería `@foo/bar/MyClass.php`. Para que este sea capaz de ser resuelto como una ruta de archivo, ya sea
`@foo` o `@foo/bar` debe ser un [alias de raíz](concept-aliases.md#defining-aliases) (root alias).
Cuando utilizas la [Plantilla de Aplicación Básica](start-basic.md), puede que pongas tus clases bajo el nivel superior
Cuando utilizas la [Plantilla de Aplicación Básica](start-installation.md), puede que pongas tus clases bajo el nivel superior
de espacio de nombres `app` para que de esta manera pueda ser automáticamente cargado por Yii sin tener la necesidad de
definir un nuevo alias. Esto es porque `@app` es un [alias predefinido](concept-aliases.md#predefined-aliases), y el
nombre de una clase tal como `app\components\MyClass` puede ser resuelto en el archivo de la clase `AppBasePath/components/MyClass.php`,
......@@ -69,7 +69,7 @@ instalarlos.
Cuando se utiliza el cargador de clases automático de Yii conjuntamente con otros autocargadores, deberías incluir el
archivo `Yii.php` *después* de que todos los demás autocargadores se hayan instalado. Esto hará que el autocargador de
Yii sea el primero en responder a cualquier petición de carga automática de clases. Por ejemplo, el siguiente código ha
sido extraido del [script de entrada](structure-entry-scripts.md) de la [Plantilla de Aplicación Básica](start-basic.md).
sido extraido del [script de entrada](structure-entry-scripts.md) de la [Plantilla de Aplicación Básica](start-installation.md).
La primera línea instala el autocargador de Composer, mientras que la segunda línea instala el autocargador de Yii.
```php
......
......@@ -70,7 +70,7 @@ Las configuraciones se utilizan en muchos lugares en Yii. Al comienzo de esta se
### Configuraciones de aplicación <a name="application-configurations"></a>
Configuración para una [aplicación](structure-applications.md) es probablemente una de las configuraciones más complejas. Esto se debe a que la clase [[yii\web\Application|application]] tiene un montón de propiedades y eventos configurables. Más importante aún, su propiedad [[yii\web\Application::components|components]] que puede recibir una gran variedad de configuraciones para crear componentes que se registran a través de la aplicación. Lo siguiente es un resumen del archivo de configuración de la aplicación para la [plantilla básica de la aplicación](start-basic.md).
Configuración para una [aplicación](structure-applications.md) es probablemente una de las configuraciones más complejas. Esto se debe a que la clase [[yii\web\Application|application]] tiene un montón de propiedades y eventos configurables. Más importante aún, su propiedad [[yii\web\Application::components|components]] que puede recibir una gran variedad de configuraciones para crear componentes que se registran a través de la aplicación. Lo siguiente es un resumen del archivo de configuración de la aplicación para la [plantilla básica de la aplicación](start-installation.md).
```php
$config = [
......
......@@ -17,7 +17,7 @@ Instalación
Yii 2.0 adopta íntegramente [Composer](https://getcomposer.org/), el administrador de paquetes de facto de PHP.
Tanto la instalación del núcleo del framework como las extensiones se manejan a través de Composer. Por favor consulta
la sección [Comenzando con la Aplicación Básica](start-basic.md) para aprender a instalar Yii 2.0. Si quieres crear extensiones
la sección [Comenzando con la Aplicación Básica](start-installation.md) para aprender a instalar Yii 2.0. Si quieres crear extensiones
o transformar extensiones de Yii 1.1 para que sean compatibles con Yii 2.0, consulta la sección [Creando Extensiones](extend-creating-extensions.md) de la guía.
......
......@@ -26,7 +26,7 @@ $classFile = Yii::getAlias('@' . str_replace('\\', '/', $className) . '.php');
`@foo/bar/MyClass.php`. Для того, чтобы данный псевдоним можно было преобразовать в путь к файлу, необходимо чтобы
либо `@foo` либо `@foo/bar` являлся [корневым псевдонимом](concept-aliases.md#defining-aliases).
При использовании [шаблона приложения basic](start-basic.md) вы можете хранить свои классы в пространстве имён `app`.
При использовании [шаблона приложения basic](start-installation.md) вы можете хранить свои классы в пространстве имён `app`.
В этом случае они будут загружаться автоматически без создания нового псевдонима. Это работает потому как `@app`
является [заранее определённым псевдонимом](concept-aliases.md#predefined-aliases) и такое имя класса как
`app\components\MyClass` в соответствии с описанным выше алготимом преобразуется в путь
......@@ -66,7 +66,7 @@ Yii::$classMap['foo\bar\MyClass'] = 'path/to/MyClass.php';
При использовании дополнительных автозагрузчиков файл `Yii.php` должен быть подключен *после* их установки. Это позволит
автозагрузчику Yii первым пробовать загрузить класс. К примеру, приведённый ниже код взят из
[входного скрипта](structure-entry-scripts.md) [шаблона приложения basic](start-basic.md). Первая строка устанавливает
[входного скрипта](structure-entry-scripts.md) [шаблона приложения basic](start-installation.md). Первая строка устанавливает
автозагрузчик Composer, а вторая — автозагрузчик Yii:
```php
......
......@@ -91,7 +91,7 @@ Yii::configure($object, $config);
Причина в том, что класс [[yii\web\Application|application]] содержит большое количество конфигурируемых
свойств и событий. Более того, свойство приложения [[yii\web\Application::components|components]]
может принимать массив с конфигурацией для создания компонентов, регистрируемых на уровне приложения.
Пример конфигурации приложения для [шаблона приложения basic](start-basic.md).
Пример конфигурации приложения для [шаблона приложения basic](start-installation.md).
```php
$config = [
......
......@@ -22,7 +22,7 @@ $classFile = Yii::getAlias('@' . str_replace('\\', '/', $className) . '.php');
Наприклад, якщо абсолютне ім'я класу `foo\bar\MyClass`, то [псевдонім шляху](concept-aliases.md) даного файлу буде
`@foo/bar/MyClass.php`. Для того, щоб даний псевдонім можна було перетворити в шлях до файлу, необхідно щоб або `@foo` або `@foo/bar` був [кореневим псевдонімом](concept-aliases.md#defining-aliases).
при використанні [шаблону додатку basic](start-basic.md) ви можете зберігати свої класи в просторі імен `app`.
при використанні [шаблону додатку basic](start-installation.md) ви можете зберігати свої класи в просторі імен `app`.
В цьому випадку вони будуть завантажуватися автоматично без створення нового псевдоніма. Це працює тому як `@app`
є [заздалегідь певним псевдонімом](concept-aliases.md#predefined-aliases) і таке ім'я класу як
`app\components\MyClass` відповідно до описаного вище алготімом перетвориться в шлях
......@@ -58,7 +58,7 @@ Yii::$classMap['foo\bar\MyClass'] = 'path/to/MyClass.php';
При використанні додаткових автозавантажувач файл `Yii.php` повинен бути підключений *після* їх установки. це дозволить
автозавантажувачу Yii першим пробувати завантажити клас. Приміром, наведений нижче код взятий з
[вхідного скрипта](structure-entry-scripts.md) [шаблону додатку basic](start-basic.md). Перший рядок встановлює автозавантажувач Composer, а друга - автозавантажувач Yii:
[вхідного скрипта](structure-entry-scripts.md) [шаблону додатку basic](start-installation.md). Перший рядок встановлює автозавантажувач Composer, а друга - автозавантажувач Yii:
```php
require(__DIR__ . '/../vendor/autoload.php');
......
......@@ -22,7 +22,7 @@ $classFile = Yii::getAlias('@' . str_replace('\\', '/', $className) . '.php');
举例来说,若某个类名为 `foo\bar\MyClass`,对应类的文件路径[别名](concept-aliases.md)会是 `@foo/bar/MyClass.php`。为了让该别名能被正确解析为文件路径,`@foo``@foo/bar`
中的一个必须是[根别名](concept-aliases.md#defining-aliases)
当我们使用[基本应用模版](start-basic.md)时,可以把你的类放置在顶级命名空间 `app` 下,这样它们就可以被 Yii 自动加载,而无需定义一个新的别名。这是因为 `@app` 本身是一个[预定义别名](concept-aliases.md#predefined-aliases),且类似于 `app\components\MyClass` 这样的类名,基于我们刚才所提到的算法,可以正确解析出 `AppBasePath/components/MyClass.php` 路径。
当我们使用[基本应用模版](start-installation.md)时,可以把你的类放置在顶级命名空间 `app` 下,这样它们就可以被 Yii 自动加载,而无需定义一个新的别名。这是因为 `@app` 本身是一个[预定义别名](concept-aliases.md#predefined-aliases),且类似于 `app\components\MyClass` 这样的类名,基于我们刚才所提到的算法,可以正确解析出 `AppBasePath/components/MyClass.php` 路径。
[高级应用模版](tutorial-advanced-app.md)里,每一逻辑层级会使用他自己的根别名。比如,前端层会使用 `@frontend` 而后端层会使用 `@backend`。因此,你可以把前端的类放在 `frontend` 命名空间,而后端的类放在 `backend`。 这样这些类就可以被 Yii 自动加载了。
......@@ -46,7 +46,7 @@ Yii::$classMap['foo\bar\MyClass'] = 'path/to/MyClass.php';
因为 Yii 完全支持 Composer 管理依赖包,所以推荐你也同时安装 Composer 的自动加载器,如果你用了一些自带自动加载器的第三方类库,你应该也安装下它们。
当你同时使用其他自动加载器和 Yii 自动加载器时,应该在其他自动加载器安装成功**之后**,再包含 `Yii.php` 文件。这将使 Yii 成为第一个响应任何类自动加载请求的自动加载器。举例来说,以下代码提取自[基本应用模版](start-basic.md)[入口脚本](structure-entry-scripts.md) 。第一行安装了 Composer 的自动加载器,第二行才是 Yii 的自动加载器:
当你同时使用其他自动加载器和 Yii 自动加载器时,应该在其他自动加载器安装成功**之后**,再包含 `Yii.php` 文件。这将使 Yii 成为第一个响应任何类自动加载请求的自动加载器。举例来说,以下代码提取自[基本应用模版](start-installation.md)[入口脚本](structure-entry-scripts.md) 。第一行安装了 Composer 的自动加载器,第二行才是 Yii 的自动加载器:
```php
require(__DIR__ . '/../vendor/autoload.php');
......@@ -64,4 +64,4 @@ require(__DIR__ . '/../vendor/yiisoft/yii2/Yii.php');
Yii 自动加载器支持自动加载[扩展](structure-extensions.md)的类。唯一的要求是它需要在 `composer.json`
文件里正确地定义 `autoload` 部分。请参考 [Composer 文档(英文)](https://getcomposer.org/doc/04-schema.md#autoload)[中文汉化](https://github.com/5-say/composer-doc-cn/blob/master/cn-introduction/04-schema.md#autoload)),来了解如何正确描述 `autoload` 的更多细节。
在你不使用 Yii 的自动加载器时,Composer 的自动加载器仍然可以帮你自动加载扩展内的类。
\ No newline at end of file
在你不使用 Yii 的自动加载器时,Composer 的自动加载器仍然可以帮你自动加载扩展内的类。
......@@ -73,7 +73,7 @@ Yii 中的配置可以用在很多场景。本章开头我们展示了如何使
### 应用的配置 <a name="application-configurations"></a>
[应用](structure-applications.md)的配置可能是最复杂的配置之一。因为 [[yii\web\Application|application]] 类拥有很多可配置的属性和事件。更重要的是它的 [[yii\web\Application::components|components]] 属性可以接收配置数组并通过应用注册为组件。以下是一个针对[基础应用模板](start-basic.md)的应用配置概要:
[应用](structure-applications.md)的配置可能是最复杂的配置之一。因为 [[yii\web\Application|application]] 类拥有很多可配置的属性和事件。更重要的是它的 [[yii\web\Application::components|components]] 属性可以接收配置数组并通过应用注册为组件。以下是一个针对[基础应用模板](start-installation.md)的应用配置概要:
```php
$config = [
......@@ -229,4 +229,4 @@ if (YII_ENV_DEV) {
}
return $config;
```
\ No newline at end of file
```
......@@ -89,7 +89,7 @@ The configuration for an [application](structure-applications.md) is probably on
This is because the [[yii\web\Application|application]] class has a lot of configurable properties and events.
More importantly, its [[yii\web\Application::components|components]] property can receive an array of configurations
for creating components that are registered through the application. The following is an abstract from the application
configuration file for the [basic application template](start-basic.md).
configuration file for the [basic application template](start-installation.md).
```php
$config = [
......
......@@ -4,7 +4,17 @@ Installing Yii
You can install Yii in two ways, using [Composer](http://getcomposer.org/) or by downloading an archive file.
The former is the preferred way, as it allows you to install new [extensions](structure-extensions.md) or update Yii by simply running a single command.
> Note: Unlike with Yii 1, standard installations of Yii 2 result in both, the framework and an application skeleton being downloaded and installed.
Standard installations of Yii result in both the framework and an application template being downloaded and installed.
An application template is a working Yii application implementing some basic features, such as login, contact form, etc.
Its code is organized is a recommended way. Therefore, it can serve as a good starting point for your projects.
In this and next few sections, we will describe how to install Yii with the so-called *Basic Application Template* and
how to implement new features on top of this application template. Yii also provides another template called
the [Advanced Application Template](tutorial-advanced-app.md) which is more oriented towards team development environment.
> Info: The Basic Application Template is suitable for developing 90 percent of Web applications. It differs
from the Advanced Application Template mainly in how their code is organized. If you are new to Yii, we strongly
recommend you stick to the Basic Application Template for its simplicity yet sufficient functionalities.
Installing via Composer <a name="installing-via-composer"></a>
......@@ -33,10 +43,9 @@ The first command installs the [composer asset plugin](https://github.com/franco
which allows managing bower and npm package dependencies through Composer. You only need to run this command
once for all. The second command installs Yii in a directory named `basic`. You can choose a different directory name if you want.
> Note: During the installation it may happen that Composer asks for login credentials for your Github account because it hits the
> Github API rate-limit. This is normal because Composer needs to retrieve a lot of information for all the packages from Github.
> Logging in to Github increases the API rate-limit so Composer can go on with its work. For more details, please refer to the
> [Composer documentation](https://getcomposer.org/doc/articles/troubleshooting.md#api-rate-limit-and-oauth-tokens).
> Note: During the installation Composer may ask for your Github login credentials. This is normal because Composer
> needs to get enough API rate-limit to retrieve the dependent package information from Github. For more details,
> please refer to the [Composer documentation](https://getcomposer.org/doc/articles/troubleshooting.md#api-rate-limit-and-oauth-tokens).
> Tip: If you want to install the latest development version of Yii, you may use the following command instead,
> which adds a [stability option](https://getcomposer.org/doc/04-schema.md#minimum-stability):
......@@ -66,7 +75,8 @@ Other Installation Options <a name="other-installation-options"></a>
--------------------------
The above installation instructions show how to install Yii, which also creates a basic Web application that works out of the box.
This approach is a good starting point for small projects, or for when you just start learning Yii.
This approach is a good starting point for most projects, either small or big. It is especially suitable if you just
start learning Yii.
But there are other installation options available:
......
Advanced application template
Advanced Application Template
=============================
> Note: This section is under development.
......@@ -7,6 +7,28 @@ This template is for large projects developed in teams where the backend is divi
to multiple servers etc. This application template also goes a bit further regarding features and provides essential
database, signup and password restore out of the box.
The following table compares the difference between the advanced and the basic application templates:
| Feature | Basic | Advanced |
|---|:---:|:---:|
| Project structure | ✓ | ✓ |
| Site controller | ✓ | ✓ |
| User login/out | ✓ | ✓ |
| Form models | ✓ | ✓ |
| DB connection | ✓ | ✓ |
| Console command | ✓ | ✓ |
| Asset bundle | ✓ | ✓ |
| Codeception tests | ✓ | ✓ |
| Front- and back-end apps | | ✓ |
| Active record models | | ✓ |
| User registration | | ✓ |
| Email | ✓ | ✓ |
| Twitter Bootstrap | ✓ | ✓ |
| etc... | | ✓ |
Installation
------------
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment