Browse Source

Revert "Fix anchors in docs (#18344)"

This reverts commit 0f4b147352.
tags/2.0.39
Alexander Makarov 4 years ago
parent
commit
1d514e2ded
No known key found for this signature in database
GPG Key ID: 3617B79C6A325E4A
  1. 10
      docs/guide/caching-data.md
  2. 2
      docs/guide/caching-fragment.md
  3. 6
      docs/guide/concept-aliases.md
  4. 2
      docs/guide/concept-behaviors.md
  5. 8
      docs/guide/concept-configurations.md
  6. 7
      docs/guide/concept-di-container.md
  7. 2
      docs/guide/concept-service-locator.md
  8. 6
      docs/guide/db-active-record.md
  9. 6
      docs/guide/db-dao.md
  10. 6
      docs/guide/db-migrations.md
  11. 14
      docs/guide/db-query-builder.md
  12. 2
      docs/guide/helper-overview.md
  13. 2
      docs/guide/input-forms.md
  14. 8
      docs/guide/input-validation.md
  15. 4
      docs/guide/intro-upgrade-from-v1.md
  16. 2
      docs/guide/output-client-scripts.md
  17. 6
      docs/guide/output-data-providers.md
  18. 16
      docs/guide/output-data-widgets.md
  19. 6
      docs/guide/output-formatting.md
  20. 2
      docs/guide/rest-quick-start.md
  21. 2
      docs/guide/rest-resources.md
  22. 6
      docs/guide/runtime-logging.md
  23. 4
      docs/guide/runtime-requests.md
  24. 2
      docs/guide/runtime-responses.md
  25. 6
      docs/guide/security-authorization.md
  26. 2
      docs/guide/security-overview.md
  27. 6
      docs/guide/start-installation.md
  28. 4
      docs/guide/structure-applications.md
  29. 8
      docs/guide/structure-assets.md
  30. 16
      docs/guide/structure-controllers.md
  31. 8
      docs/guide/structure-extensions.md
  32. 14
      docs/guide/structure-models.md
  33. 2
      docs/guide/structure-modules.md
  34. 14
      docs/guide/structure-views.md
  35. 6
      docs/guide/tutorial-console.md
  36. 8
      docs/guide/tutorial-i18n.md
  37. 7
      docs/guide/tutorial-yii-integration.md

10
docs/guide/caching-data.md

@ -50,7 +50,7 @@ $data = $cache->getOrSet($key, function () use ($user_id) {
See [Cache Expiration](#cache-expiration) and [Cache Dependencies](#cache-dependencies) to know more.
## Cache Components
## Cache Components <span id="cache-components"></span>
Data caching relies on the so-called *cache components* which represent various cache storage,
such as memory, files, databases.
@ -99,7 +99,7 @@ For example, you can modify the above configuration to use [[yii\caching\ApcCach
by default by many cache-dependent classes (e.g. [[yii\web\UrlManager]]).
### Supported Cache Storage
### Supported Cache Storage <span id="supported-cache-storage"></span>
Yii supports a wide range of cache storage. The following is a summary:
@ -218,7 +218,7 @@ property. For example, in the application configuration you can write the follow
To ensure interoperability, only alphanumeric characters should be used.
### Cache Expiration
### Cache Expiration <span id="cache-expiration"></span>
A data item stored in a cache will remain there forever unless it is removed because of some caching policy
enforcement (e.g. caching space is full and the oldest data are removed). To change this behavior, you can provide
@ -244,7 +244,7 @@ over the default unlimited duration.
This will allow you not to pass custom `duration` parameter to [[yii\caching\Cache::set()|set()]] each time.
### Cache Dependencies
### Cache Dependencies <span id="cache-dependencies"></span>
Besides expiration setting, cached data item may also be invalidated by changes of the so-called *cache dependencies*.
For example, [[yii\caching\FileDependency]] represents the dependency of a file's modification time.
@ -284,7 +284,7 @@ Below is a summary of the available cache dependencies:
[[yii\caching\Cache::get()|get()]] may return `false` while [[yii\caching\Cache::exists()|exists()]] returns `true`.
## Query Caching
## Query Caching <span id="query-caching"></span>
Query caching is a special caching feature built on top of data caching. It is provided to cache the result
of database queries.

2
docs/guide/caching-fragment.md

@ -143,7 +143,7 @@ inner cache has been invalidated. Therefore, you must be careful in setting the
of the nested caches, otherwise the outdated inner fragments may be kept in the outer fragment.
## Dynamic Content
## Dynamic Content <span id="dynamic-content"></span>
When using fragment caching, you may encounter the situation where a large fragment of content is relatively
static except at one or a few places. For example, a page header may display the main menu bar together with

6
docs/guide/concept-aliases.md

@ -8,7 +8,7 @@ without leading `@` will be prefixed with `@` character.
Yii has many pre-defined aliases already available. For example, the alias `@yii` represents the installation path of
the Yii framework; `@web` represents the base URL for the currently running Web application.
Defining Aliases
Defining Aliases <span id="defining-aliases"></span>
----------------
You can define an alias for a file path or URL by calling [[Yii::setAlias()]]:
@ -104,7 +104,7 @@ $cache = new FileCache([
Please pay attention to the API documentation to see if a property or method parameter supports aliases.
Predefined Aliases
Predefined Aliases <span id="predefined-aliases"></span>
------------------
Yii predefines a set of aliases to easily reference commonly used file paths and URLs:
@ -125,7 +125,7 @@ The rest of the aliases are defined in the application constructor when applying
> Note: `@web` and `@webroot` aliases as their descriptions indicate are defined within [[yii\web\Application|Web application]] and therefore are not available for [[yii\console\Application|Console application]] by default.
Extension Aliases
Extension Aliases <span id="extension-aliases"></span>
-----------------
An alias is automatically defined for each [extension](structure-extensions.md) that is installed via Composer.

2
docs/guide/concept-behaviors.md

@ -99,7 +99,7 @@ function ($event) {
}
```
Attaching Behaviors
Attaching Behaviors <span id="attaching-behaviors"></span>
-------------------
You can attach a behavior to a [[yii\base\Component|component]] either statically or dynamically. The former is more common in practice.

8
docs/guide/concept-configurations.md

@ -35,7 +35,7 @@ Yii::configure($object, $config);
Note that, in this case, the configuration array should not contain a `class` element.
## Configuration Format
## Configuration Format <span id="configuration-format"></span>
The format of a configuration can be formally described as:
@ -85,7 +85,7 @@ create an object according to a configuration by using [[Yii::createObject()]].
describe application configurations and widget configurations - two major usages of configurations.
### Application Configurations
### Application Configurations <span id="application-configurations"></span>
The configuration for an [application](structure-applications.md) is probably one of the most complex arrays in Yii.
This is because the [[yii\web\Application|application]] class has a lot of configurable properties and events.
@ -183,7 +183,7 @@ The `items` property is also configured with menu items to be displayed.
Note that because the class name is already given, the configuration array should NOT have the `class` key.
## Configuration Files
## Configuration Files <span id="configuration-files"></span>
When a configuration is very complex, a common practice is to store it in one or multiple PHP files, known as
*configuration files*. A configuration file returns a PHP array representing the configuration.
@ -256,7 +256,7 @@ Without using default configurations, you would have to configure `maxButtonCoun
link pagers.
## Environment Constants
## Environment Constants <span id="environment-constants"></span>
Configurations often vary according to the environment in which an application runs. For example,
in development environment, you may want to use a database named `mydb_dev`, while on production server

7
docs/guide/concept-di-container.md

@ -219,7 +219,7 @@ $container->setSingleton('yii\db\Connection', [
]);
```
Resolving Dependencies
Resolving Dependencies <span id="resolving-dependencies"></span>
----------------------
Once you have registered dependencies, you can use the DI container to create new objects,
@ -313,7 +313,7 @@ $lister = new UserLister($finder);
```
Practical Usage
Practical Usage <span id="practical-usage"></span>
---------------
Yii creates a DI container when you include the `Yii.php` file in the [entry script](structure-entry-scripts.md)
@ -396,7 +396,8 @@ class HotelController extends Controller
}
```
## Advanced Practical Usage
Advanced Practical Usage <span id="advanced-practical-usage"></span>
---------------
Say we work on API application and have:

2
docs/guide/concept-service-locator.md

@ -119,7 +119,7 @@ This alternative approach is most preferable when you are releasing a Yii compon
3rd-party library. You use the static method like shown above to represent the complex logic of building the
3rd-party object, and the user of your component only needs to call the static method to configure the component.
## Tree traversal
## Tree traversal <span id="tree-traversal"></span>
Modules allow arbitrary nesting; a Yii application is essentially a tree of modules.
Since each of these modules is a service locator it makes sense for children to have access to their parent.

6
docs/guide/db-active-record.md

@ -476,7 +476,7 @@ If you are interested in the attribute values prior to their most recent modific
> [intval()](https://secure.php.net/manual/en/function.intval.php), [floatval()](https://secure.php.net/manual/en/function.floatval.php),
> [boolval](https://secure.php.net/manual/en/function.boolval.php), etc...
### Default Attribute Values
### Default Attribute Values <span id="default-attribute-values"></span>
Some of your table columns may have default values defined in the database. Sometimes, you may want to pre-populate your
Web form for an Active Record instance with these default values. To avoid writing the same default values again,
@ -493,7 +493,7 @@ $customer->loadDefaultValues();
### Attributes Typecasting <span id="attributes-typecasting"></span>
Being populated by query results, [[yii\db\ActiveRecord]] performs automatic typecast for its attribute values, using
information from [database table schema](db-dao.md#working-with-database-schema). This allows data retrieved from table column
information from [database table schema](db-dao.md#database-schema). This allows data retrieved from table column
declared as integer to be populated in ActiveRecord instance with PHP integer, boolean with boolean and so on.
However, typecasting mechanism has several limitations:
@ -1154,7 +1154,7 @@ In the code example above, we are modifying the relational query by appending an
> ```
### Joining with Relations
### Joining with Relations <span id="joining-with-relations"></span>
> Note: The content described in this subsection is only applicable to relational databases, such as
MySQL, PostgreSQL, etc.

6
docs/guide/db-dao.md

@ -288,7 +288,7 @@ Note that the aforementioned methods only create the query and you always have t
to actually run them.
## Quoting Table and Column Names
## Quoting Table and Column Names <span id="quoting-table-and-column-names"></span>
When writing database-agnostic code, properly quoting table and column names is often a headache because
different databases have different name quoting rules. To overcome this problem, you may use the following
@ -339,7 +339,7 @@ $count = Yii::$app->db->createCommand("SELECT COUNT([[id]]) FROM {{%employee}}")
```
## Performing Transactions
## Performing Transactions <span id="performing-transactions"></span>
When running multiple related queries in a sequence, you may need to wrap them in a transaction to ensure the integrity
and consistency of your database. If any of the queries fails, the database will be rolled back to the state as if
@ -638,7 +638,7 @@ $rows = Yii::$app->db->useMaster(function ($db) {
You may also directly set `Yii::$app->db->enableSlaves` to be `false` to direct all queries to the master connection.
## Working with Database Schema
## Working with Database Schema <span id="database-schema"></span>
Yii DAO provides a whole set of methods to let you manipulate the database schema, such as creating new tables,
dropping a column from a table, etc. These methods are listed as follows:

6
docs/guide/db-migrations.md

@ -143,7 +143,7 @@ class m150101_185401_create_news_table extends Migration
The base migration class [[yii\db\Migration]] exposes a database connection via the [[yii\db\Migration::db|db]]
property. You can use it to manipulate the database schema using the methods as described in
[Working with Database Schema](db-dao.md#working-with-database-schema).
[Working with Database Schema](db-dao.md#database-schema).
Rather than using physical types, when creating a table or column you should use *abstract types*
so that your migrations are independent of specific DBMS. The [[yii\db\Schema]] class defines
@ -188,7 +188,7 @@ class m150101_185401_create_news_table extends Migration
A list of all available methods for defining the column types is available in the API documentation of [[yii\db\SchemaBuilderTrait]].
## Generating Migrations
## Generating Migrations <span id="generating-migrations"></span>
Since version 2.0.7 migration console provides a convenient way to create migrations.
@ -982,7 +982,7 @@ yii migrate/create app\\migrations\\Create_studentsExamTable
This generates migration within namespace `app\migrations` creating table `studentsExam`.
### Separated Migrations
### Separated Migrations <span id="separated-migrations"></span>
Sometimes using single migration history for all project migrations is not desirable. For example: you may install some
'blog' extension, which contains fully separated functionality and contain its own migrations, which should not affect

14
docs/guide/db-query-builder.md

@ -37,7 +37,7 @@ LIMIT 10
[[yii\db\Query]] objects.
## Building Queries
## Building Queries <span id="building-queries"></span>
To build a [[yii\db\Query]] object, you call different query building methods to specify different parts of
a SQL query. The names of these methods resemble the SQL keywords used in the corresponding parts of the SQL
@ -167,7 +167,7 @@ the four formats to specify a `WHERE` condition:
- operator format, e.g. `['like', 'name', 'test']`
- object format, e.g. `new LikeCondition('name', 'LIKE', 'test')`
#### String Format
#### String Format <span id="string-format"></span>
String format is best used to specify very simple conditions or if you need to use built-in functions of the DBMS.
It works as if you are writing a raw SQL. For example,
@ -201,7 +201,7 @@ $query->where('status=:status')
As with all places where raw SQL is involved, you may use the [DBMS agnostic quoting syntax](db-dao.md#quoting-table-and-column-names)
for table and column names when writing conditions in string format.
#### Hash Format
#### Hash Format <span id="hash-format"></span>
Hash format is best used to specify multiple `AND`-concatenated sub-conditions each being a simple equality assertion.
It is written as an array whose keys are column names and values the corresponding values that the columns should be.
@ -333,7 +333,7 @@ $query->where(['=', $column, $value]);
// $value is safe, but $column name won't be encoded!
```
#### Object Format
#### Object Format <span id="object-format"></span>
Object Form is available since 2.0.14 and is both most powerful and most complex way to define conditions.
You need to follow it either if you want to build your own abstraction over query builder or if you want to implement
@ -393,7 +393,7 @@ WHERE (`status` = 10) AND (`title` LIKE '%yii%')
```
#### Filter Conditions
#### Filter Conditions <span id="filter-conditions"></span>
When building `WHERE` conditions based on input from end users, you usually want to ignore those input values, that are empty.
For example, in a search form that allows you to search by username and email, you would like to ignore the username/email
@ -625,7 +625,7 @@ $mainQuery = (new \yii\db\Query())
[[yii\db\Query::withQuery()|withQuery()]] can be called multiple times to prepend more CTE's to main query. Queries will be prepend in same order as they attached. If one of query is recursive then whole CTE become recursive.
## Query Methods
## Query Methods <span id="query-methods"></span>
[[yii\db\Query]] provides a whole set of methods for different query purposes:
@ -867,7 +867,7 @@ $unbufferedDb->close();
It is recommended to design your own code with your production practice for extra massive data,
[for example, divide the range for integer keys, loop them with Unbuffered Queries](https://github.com/yiisoft/yii2/issues/8420#issuecomment-296109257).
### Adding custom Conditions and Expressions
### Adding custom Conditions and Expressions <span id="adding-custom-conditions-and-expressions"></span>
As it was mentioned in [Conditions – Object Format](#object-format) chapter, it is possible to create custom condition
classes. For example, let's create a condition that will check that specific columns are less than some value.

2
docs/guide/helper-overview.md

@ -40,7 +40,7 @@ The following core helper classes are provided in the Yii releases:
- VarDumper
Customizing Helper Classes
Customizing Helper Classes <span id="customizing-helper-classes"></span>
--------------------------
To customize a core helper class (e.g. [[yii\helpers\ArrayHelper]]), you should create a new class extending

2
docs/guide/input-forms.md

@ -88,7 +88,7 @@ of all attributes for the login form to be available in `$_POST['LoginForm']` on
> Tip: If you have only one model in a form and want to simplify the input names you may skip the array part by
> overriding the [[yii\base\Model::formName()|formName()]] method of the model to return an empty string.
> This can be useful for filter models used in the [GridView](output-data-widgets.md#gridview) to create nicer URLs.
> This can be useful for filter models used in the [GridView](output-data-widgets.md#grid-view) to create nicer URLs.
Specifying the attribute of the model can be done in more sophisticated ways. For example when an attribute may
take an array value when uploading multiple files or selecting multiple items you may specify it by appending `[]`

8
docs/guide/input-validation.md

@ -194,7 +194,7 @@ function whose return value determines whether to apply the rule or not. For exa
```
### Data Filtering
### Data Filtering <span id="data-filtering"></span>
User inputs often need to be filtered or preprocessed. For example, you may want to trim the spaces around the
`username` input. You may use validation rules to achieve this goal.
@ -236,7 +236,7 @@ The above code will perform the following operations on the input:
Here we set [[yii\validators\FilterValidator::$skipOnEmpty|$skipOnEmpty]] to `true`, which is `false` by default
on the [[yii\validators\FilterValidator|filter]] validator.
### Handling Empty Inputs
### Handling Empty Inputs <span id="handling-empty-inputs"></span>
When input data are submitted from HTML forms, you often need to assign some default values to the inputs
if they are empty. You can do so by using the [default](tutorial-core-validators.md#default) validator. For example,
@ -344,7 +344,7 @@ Besides using the [core validators](tutorial-core-validators.md) included in the
create your own validators. You may create inline validators or standalone validators.
### Inline Validators
### Inline Validators <span id="inline-validators"></span>
An inline validator is one defined in terms of a model method or an anonymous function. The signature of
the method/function is:
@ -746,7 +746,7 @@ JS;
> to [Working with ActiveForm via JavaScript](https://github.com/samdark/yii2-cookbook/blob/master/book/forms-activeform-js.md)
> in Yii 2.0 Cookbook.
### Deferred Validation
### Deferred Validation <span id="deferred-validation"></span>
If you need to perform asynchronous client-side validation, you can create [Deferred objects](http://api.jquery.com/category/deferred-object/).
For example, to perform a custom AJAX validation, you can use the following code:

4
docs/guide/intro-upgrade-from-v1.md

@ -527,7 +527,7 @@ the same goal.
Please refer to the [Url manager docs](runtime-routing.md) section for more details.
An important change in the naming convention for routes is that camel case names of controllers
and actions are now converted to lower case where each word is separated by a hyphen, e.g. the controller
and actions are now converted to lower case where each word is separated by a hypen, e.g. the controller
id for the `CamelCaseController` will be `camel-case`.
See the section about [controller IDs](structure-controllers.md#controller-ids) and [action IDs](structure-controllers.md#action-ids) for more details.
@ -536,5 +536,5 @@ Using Yii 1.1 and 2.x together
------------------------------
If you have legacy Yii 1.1 code that you want to use together with Yii 2.0, please refer to
the [Using Yii 1.1 and 2.0 Together](tutorial-yii-integration.md#using-both-yii2-with-yii) section.
the [Using Yii 1.1 and 2.0 Together](tutorial-yii-integration.md#using-both-yii2-yii1) section.

2
docs/guide/output-client-scripts.md

@ -200,7 +200,7 @@ string in valid JS syntax, which can be inserted into the JavaScript code to pla
> The jQuery function in form of `$(` or `$.` is not interpreted
> as a PHP variable and can safely be used.
## The `yii.js` script
## The `yii.js` script <span id="yii.js"></span>
> Note: This section has not been written yet. It should contain explanation of the functionality provided by `yii.js`:
>

6
docs/guide/output-data-providers.md

@ -54,7 +54,7 @@ These data providers mainly vary in the way how the data source is specified. In
we will explain the detailed usage of each of these data providers.
## Active Data Provider
## Active Data Provider <span id="active-data-provider"></span>
To use [[yii\data\ActiveDataProvider]], you should configure its [[yii\data\ActiveDataProvider::query|query]] property.
It can take either a [[yii\db\Query]] or [[yii\db\ActiveQuery]] object. If the former, the data returned will be arrays;
@ -99,7 +99,7 @@ By default, [[yii\data\ActiveDataProvider]] uses the `db` application component
use a different database connection by configuring the [[yii\data\ActiveDataProvider::db]] property.
## SQL Data Provider
## SQL Data Provider <span id="sql-data-provider"></span>
[[yii\data\SqlDataProvider]] works with a raw SQL statement which is used to fetch the needed
data. Based on the specifications of [[yii\data\SqlDataProvider::sort|sort]] and
@ -340,7 +340,7 @@ class CsvDataProvider extends BaseDataProvider
}
```
## Filtering Data Providers using Data Filters
## Filtering Data Providers using Data Filters <span id="filtering-data-providers-using-data-filters"></span>
While you can build conditions for active data provider manually as described in
[Filtering Data](output-data-widgets.md#filtering-data) and [Separate Filter Form](output-data-widgets.md#separate-filter-form)

16
docs/guide/output-data-widgets.md

@ -2,12 +2,12 @@ Data widgets
============
Yii provides a set of [widgets](structure-widgets.md) that can be used to display data.
While the [DetailView](#detailview) widget can be used to display data for a single record,
[ListView](#listview) and [GridView](#gridview) can be used to display a list or table of data records
While the [DetailView](#detail-view) widget can be used to display data for a single record,
[ListView](#list-view) and [GridView](#grid-view) can be used to display a list or table of data records
providing features like pagination, sorting and filtering.
DetailView
DetailView <span id="detail-view"></span>
----------
The [[yii\widgets\DetailView|DetailView]] widget displays the details of a single data [[yii\widgets\DetailView::$model|model]].
@ -59,7 +59,7 @@ echo DetailView::widget([
]);
```
ListView
ListView <span id="list-view"></span>
--------
The [[yii\widgets\ListView|ListView]] widget is used to display data from a [data provider](output-data-providers.md).
@ -124,7 +124,7 @@ echo ListView::widget([
These are then also available as variables in the view.
GridView
GridView <span id="grid-view"></span>
--------
Data grid or [[yii\grid\GridView|GridView]] is one of the most powerful Yii widgets. It is extremely useful if you need to quickly build the admin
@ -224,7 +224,7 @@ You may specify various container HTML options by passing arrays to:
- [[yii\grid\Column::contentOptions|contentOptions]]
#### Data column
#### Data column <span id="data-column"></span>
[[yii\grid\DataColumn|Data column]] is used for displaying and sorting data. It is the default column type so the specifying class could be omitted when
using it.
@ -375,7 +375,7 @@ echo GridView::widget([
>
> - https://github.com/yiisoft/yii2/issues/1576
### Filtering data
### Filtering data <span id="filtering-data"></span>
For filtering data, the GridView needs a [model](structure-models.md) that represents the search criteria which is
usually taken from the filter fields in the GridView table.
@ -462,7 +462,7 @@ echo GridView::widget([
]);
```
### Separate filter form
### Separate filter form <span id="separate-filter-form"></span>
Most of the time using GridView header filters is enough, but in case you need a separate filter form,
you can easily add it as well. You can create partial view `_search.php` with the following contents:

6
docs/guide/output-formatting.md

@ -125,7 +125,7 @@ Since version 2.0.7 it is also possible to format dates in different calendar sy
Please refer to the API documentation of the formatters [[yii\i18n\Formatter::$calendar|$calendar]]-property on how to set a different calendar.
### Time Zones
### Time Zones <span id="time-zones"></span>
When formatting date and time values, Yii will convert them to the target [[yii\i18n\Formatter::timeZone|time zone]].
The value being formatted is assumed to be in UTC, unless a time zone is explicitly given or you have configured
@ -152,7 +152,7 @@ as set in the PHP configuration.
> likely that you do not have the latest information in the time zone database installed on your system.
> You may refer to the [ICU manual](http://userguide.icu-project.org/datetime/timezone#TOC-Updating-the-Time-Zone-Data)
> for details on updating the time zone database. Please also read
> [Setting up your PHP environment for internationalization](tutorial-i18n.md#setting-up-php-environment).
> [Setting up your PHP environment for internationalization](tutorial-i18n.md#setup-environment).
## Formatting Numbers <span id="numbers"></span>
@ -238,7 +238,7 @@ By default, the currently active [[yii\i18n\Formatter::locale|locale]] is determ
> Note: The Yii formatter relies on the [PHP intl extension](https://secure.php.net/manual/en/book.intl.php) to support
> localized data formatting. Because different versions of the ICU library compiled with PHP may cause different
> formatting results, it is recommended that you use the same ICU version for all your environments. For more details,
> please refer to [Setting up your PHP environment for internationalization](tutorial-i18n.md#setting-up-php-environment).
> please refer to [Setting up your PHP environment for internationalization](tutorial-i18n.md#setup-environment).
>
> If the intl extension is not installed, the data will not be localized.
>

2
docs/guide/rest-quick-start.md

@ -82,7 +82,7 @@ the `request` [application component](structure-application-components.md) to us
`application/x-www-form-urlencoded` and `multipart/form-data` input formats.
## Trying it Out
## Trying it Out <span id="trying-it-out"></span>
With the above minimal amount of effort, you have already finished your task of creating the RESTful APIs
for accessing the user data. The APIs you have created include:

2
docs/guide/rest-resources.md

@ -252,7 +252,7 @@ Since collection in REST APIs is a data provider, it shares all data provider fe
An example may be found in the [Quick Start](rest-quick-start.md#trying-it-out) section.
### Filtering collections
### Filtering collections <span id="filtering-collections"></span>
Since version 2.0.13 Yii provides a facility to filter collections. An example can be found in the
[Quick Start](rest-quick-start.md#trying-it-out) guide. In case you're implementing an endpoint yourself,

6
docs/guide/runtime-logging.md

@ -14,7 +14,7 @@ Using the Yii logging framework involves the following steps:
In this section, we will mainly describe the first two steps.
## Log Messages
## Log Messages <span id="log-messages"></span>
Recording log messages is as simple as calling one of the following logging methods:
@ -56,7 +56,7 @@ enough messages are logged or when the application ends, the logger object will
[[yii\log\Dispatcher|message dispatcher]] to send recorded log messages to the registered [log targets](#log-targets).
## Log Targets
## Log Targets <span id="log-targets"></span>
A log target is an instance of the [[yii\log\Target]] class or its child class. It filters the log messages by their
severity levels and categories and then exports them to some medium. For example, a [[yii\log\DbTarget|database target]]
@ -359,7 +359,7 @@ log target classes included in the Yii release.
as [Monolog](https://github.com/Seldaek/monolog) by using
[PSR log target extension](https://github.com/samdark/yii2-psr-log-target).
## Performance Profiling
## Performance Profiling <span id="performance-profiling"></span>
Performance profiling is a special type of message logging that is used to measure the time taken by certain
code blocks and find out what are the performance bottlenecks. For example, the [[yii\db\Command]] class uses

4
docs/guide/runtime-requests.md

@ -57,7 +57,7 @@ $param = $request->getBodyParam('id');
You can customize the way how these parameters are parsed by configuring the [[yii\web\Request::parsers]] property.
## Request Methods
## Request Methods <span id="request-methods"></span>
You can get the HTTP method used by the current request via the expression `Yii::$app->request->method`.
A whole set of boolean properties is also provided for you to check if the current method is of certain type.
@ -139,7 +139,7 @@ $userHost = Yii::$app->request->userHost;
$userIP = Yii::$app->request->userIP;
```
## Trusted proxies and headers
## Trusted proxies and headers <span id="trusted-proxies"></span>
In the previous section you have seen how to get user information like host and IP address.
This will work out of the box in a normal setup where a single webserver is used to serve the website.

2
docs/guide/runtime-responses.md

@ -195,7 +195,7 @@ redirect the browser accordingly.
> Info: Yii comes with a `yii.js` JavaScript file which provides a set of commonly used JavaScript utilities,
including browser redirection based on the `X-Redirect` header. Therefore, if you are using this JavaScript file
(by registering the [[yii\web\YiiAsset]] asset bundle), you do not need to write anything to support AJAX redirection.
More information about `yii.js` can be found in the [Client Scripts Section](output-client-scripts.md#the-yiijs-script).
More information about `yii.js` can be found in the [Client Scripts Section](output-client-scripts.md#yii.js).
## Sending Files <span id="sending-files"></span>

6
docs/guide/security-authorization.md

@ -253,7 +253,7 @@ Read more about working with migrations from different namespaces in
The `authManager` can now be accessed via `\Yii::$app->authManager`.
### Building Authorization Data
### Building Authorization Data <span id="generating-rbac-data"></span>
Building authorization data is all about the following tasks:
@ -338,7 +338,7 @@ Migration could be applied by using `yii migrate`.
### Using console command
If your permissions hierarchy doesn't change at all and you have a fixed number of users you can create a
-[console command](tutorial-console.md#creating-your-own-console-commands) that will initialize authorization data once via
-[console command](tutorial-console.md#create-command) that will initialize authorization data once via
APIs offered by `authManager`:
```php
@ -648,7 +648,7 @@ class UserGroupRule extends Rule
}
```
Then create your own command/migration as explained [in the previous section](#building-authorization-data):
Then create your own command/migration as explained [in the previous section](#generating-rbac-data):
```php
$auth = Yii::$app->authManager;

2
docs/guide/security-overview.md

@ -12,4 +12,4 @@ Yii powered application as secure as possible, Yii has included several excellen
* [Views security](structure-views.md#security)
* [Auth Clients](https://github.com/yiisoft/yii2-authclient/blob/master/docs/guide/README.md)
* [Best Practices](security-best-practices.md)
* [Trusted proxies and headers](runtime-requests.md#trusted-proxies-and-headers)
* [Trusted proxies and headers](runtime-requests.md#trusted-proxies)

6
docs/guide/start-installation.md

@ -18,7 +18,7 @@ to develop applications with multiple tiers.
recommend you stick to the Basic Project Template for its simplicity yet sufficient functionalities.
Installing via Composer
Installing via Composer <span id="installing-via-composer"></span>
-----------------------
### Installing Composer
@ -177,7 +177,7 @@ should have PHP 5.4 or above. Ideally latest PHP 7. You should also install the
and a corresponding database driver (such as `pdo_mysql` for MySQL databases), if your application needs a database.
Configuring Web Servers
Configuring Web Servers <span id="configuring-web-servers"></span>
-----------------------
> Info: You may skip this subsection for now if you are just test driving Yii with no intention
@ -204,7 +204,7 @@ to modify its Web server configuration, you may still adjust the structure of yo
the [Shared Hosting Environment](tutorial-shared-hosting.md) section for more details.
> Info: If you are running your Yii application behind a reverse proxy, you might need to configure
> [Trusted proxies and headers](runtime-requests.md#trusted-proxies-and-headers) in the request component.
> [Trusted proxies and headers](runtime-requests.md#trusted-proxies) in the request component.
### Recommended Apache Configuration <span id="recommended-apache-configuration"></span>

4
docs/guide/structure-applications.md

@ -13,7 +13,7 @@ There are two types of applications: [[yii\web\Application|Web applications]] an
Web requests, while the latter handles console command requests.
## Application Configurations
## Application Configurations <span id="application-configurations"></span>
When an [entry script](structure-entry-scripts.md) creates an application, it will load
a [configuration](concept-configurations.md) and apply it to the application, as follows:
@ -588,7 +588,7 @@ as for that of `beforeAction`. That is, controllers are the first objects trigge
followed by modules (if any), and finally applications.
## Application Lifecycle
## Application Lifecycle <span id="application-lifecycle"></span>
![Application Lifecycle](images/application-lifecycle.png)

8
docs/guide/structure-assets.md

@ -205,7 +205,7 @@ The above example defines an asset bundle for the ["fontawesome" package](http:/
the `only` publishing option, only the `fonts` and `css` subdirectories will be published.
### Bower and NPM Assets installation
### Bower and NPM Assets installation <span id="bower-npm-assets"></span>
Most JavaScript/CSS packages are managed by [Bower](http://bower.io/) and/or [NPM](https://www.npmjs.org/) package
managers. In PHP world we have Composer, that manages PHP dependencies, but it is possible to load
@ -295,7 +295,7 @@ After configuring Composer to support Bower and NPM:
uses `@bower/jquery/dist` instead of `@bower/jquery`.
## Using Asset Bundles
## Using Asset Bundles <span id="using-asset-bundles"></span>
To use an asset bundle, register it with a [view](structure-views.md) by calling the [[yii\web\AssetBundle::register()]]
method. For example, in a view template you can register an asset bundle like the following:
@ -362,7 +362,7 @@ $bundle->js[] = 'i18n/' . Yii::$app->language . '.js'; // dynamic file added
unexpected side effects, and should be avoided if possible.
### Customizing Asset Bundles
### Customizing Asset Bundles <span id="customizing-asset-bundles"></span>
Yii manages asset bundles through an application component named `assetManager` which is implemented by [[yii\web\AssetManager]].
By configuring the [[yii\web\AssetManager::bundles]] property, it is possible to customize the behavior of an asset bundle.
@ -564,7 +564,7 @@ be referenced in your application or extension code.
- [[yii\web\YiiAsset]]: It mainly includes the `yii.js` file which implements a mechanism of organizing JavaScript code
in modules. It also provides special support for `data-method` and `data-confirm` attributes and other useful features.
More information about `yii.js` can be found in the [Client Scripts Section](output-client-scripts.md#the-yiijs-script).
More information about `yii.js` can be found in the [Client Scripts Section](output-client-scripts.md#yii.js).
- [[yii\web\JqueryAsset]]: It includes the `jquery.js` file from the jQuery Bower package.
- [[yii\bootstrap\BootstrapAsset]]: It includes the CSS file from the Twitter Bootstrap framework.
- [[yii\bootstrap\BootstrapPluginAsset]]: It includes the JavaScript file from the Twitter Bootstrap framework for

16
docs/guide/structure-controllers.md

@ -8,7 +8,7 @@ controllers will analyze incoming request data, pass them to [models](structure-
into [views](structure-views.md), and finally generate outgoing responses.
## Actions
## Actions <span id="actions"></span>
Controllers are composed of *actions* which are the most basic units that end users can address and request for
execution. A controller can have one or multiple actions.
@ -62,7 +62,7 @@ will redirect the browser to the `view` action with the ID of the newly created
the `create` view through which users can provide the needed input.
## Routes
## Routes <span id="routes"></span>
End users address actions through the so-called *routes*. A route is a string that consists of the following parts:
@ -88,7 +88,7 @@ will be executed. For more details on how routes are resolved into actions, plea
the [Routing and URL Creation](runtime-routing.md) section.
## Creating Controllers
## Creating Controllers <span id="creating-controllers"></span>
In [[yii\web\Application|Web applications]], controllers should extend from [[yii\web\Controller]] or its
child classes. Similarly in [[yii\console\Application|console applications]], controllers should extend from
@ -105,7 +105,7 @@ class SiteController extends Controller
```
### Controller IDs
### Controller IDs <span id="controller-ids"></span>
Usually, a controller is designed to handle the requests regarding a particular type of resource.
For this reason, controller IDs are often nouns referring to the types of the resources that they are handling.
@ -190,7 +190,7 @@ You may change the default controller with the following [application configurat
```
## Creating Actions
## Creating Actions <span id="creating-actions"></span>
Creating actions can be as simple as defining the so-called *action methods* in a controller class. An action method is
a *public* method whose name starts with the word `action`. The return value of an action method represents
@ -216,7 +216,7 @@ class SiteController extends Controller
```
### Action IDs
### Action IDs <span id="action-ids"></span>
An action is often designed to perform a particular manipulation of a resource. For this reason,
action IDs are usually verbs, such as `view`, `update`, etc.
@ -255,7 +255,7 @@ if you plan to reuse the same action in different places, or if you want to redi
you should consider defining it as a *standalone action*.
### Standalone Actions
### Standalone Actions <span id="standalone-actions"></span>
Standalone actions are defined in terms of action classes extending [[yii\base\Action]] or its child classes.
For example, in the Yii releases, there are [[yii\web\ViewAction]] and [[yii\web\ErrorAction]], both of which
@ -329,7 +329,7 @@ public function actionForward()
```
### Action Parameters
### Action Parameters <span id="action-parameters"></span>
The action methods for inline actions and the `run()` methods for standalone actions can take parameters,
called *action parameters*. Their values are obtained from requests. For [[yii\web\Application|Web applications]],

8
docs/guide/structure-extensions.md

@ -11,7 +11,7 @@ other people your great work.
that can be used without Yii, we will refer to them using the term "package" or "library".
## Using Extensions
## Using Extensions <span id="using-extensions"></span>
To use an extension, you need to install it first. Most extensions are distributed as [Composer](https://getcomposer.org/)
packages which can be installed by taking the following two simple steps:
@ -90,7 +90,7 @@ are under the `myext` namespace, then you can include the following code in your
```
## Creating Extensions
## Creating Extensions <span id="creating-extensions"></span>
You may consider creating an extension when you feel the need to share with other people your great code.
An extension can contain any code you like, such as a helper class, a widget, a module, etc.
@ -204,7 +204,7 @@ to refer to a NPM package. When Composer installs a Bower or NPM package, by def
installed under the `@vendor/bower/PackageName` and `@vendor/npm/Packages` directories, respectively.
These two directories can also be referred to using the shorter aliases `@bower/PackageName` and `@npm/PackageName`.
For more details about asset management, please refer to the [Assets](structure-assets.md#bower-and-npm-assets-installation) section.
For more details about asset management, please refer to the [Assets](structure-assets.md#bower-npm-assets) section.
#### Class Autoloading <span id="class-autoloading"></span>
@ -250,7 +250,7 @@ extension, we use `yii\imagine` as the namespace for its classes.
Do not use `yii`, `yii2` or `yiisoft` as your vendor name. These names are reserved for use by the Yii core code.
#### Bootstrapping Classes
#### Bootstrapping Classes <span id="bootstrapping-classes"></span>
Sometimes, you may want your extension to execute some code during the [bootstrapping process](runtime-bootstrapping.md)
stage of an application. For example, your extension may want to respond to the application's `beginRequest` event

14
docs/guide/structure-models.md

@ -21,7 +21,7 @@ Please refer to the relevant documentation for more details about these advanced
components built to support [[yii\base\Model]], it is usually the preferable base class for a model.
## Attributes
## Attributes <span id="attributes"></span>
Models represent business data in terms of *attributes*. Each attribute is like a publicly accessible property
of a model. The method [[yii\base\Model::attributes()]] specifies what attributes a model class has.
@ -82,7 +82,7 @@ override the magic methods such as `__get()`, `__set()` so that the attributes c
normal object properties.
### Attribute Labels
### Attribute Labels <span id="attribute-labels"></span>
When displaying values or getting input for attributes, you often need to display some labels associated
with attributes. For example, given an attribute named `firstName`, you may want to display a label `First Name`
@ -151,7 +151,7 @@ is being used in, you may return different labels for the same attribute.
in models is often very convenient and can result in very clean and reusable code.
## Scenarios
## Scenarios <span id="scenarios"></span>
A model may be used in different *scenarios*. For example, a `User` model may be used to collect user login inputs,
but it may also be used for the user registration purpose. In different scenarios, a model may use different
@ -232,7 +232,7 @@ You can, however, use it for other purposes. For example, you may declare [attri
differently based on the current scenario.
## Validation Rules
## Validation Rules <span id="validation-rules"></span>
When the data for a model is received from end users, it should be validated to make sure it satisfies
certain rules (called *validation rules*, also known as *business rules*). For example, given a `ContactForm` model,
@ -304,7 +304,7 @@ An attribute will be validated if and only if it is an active attribute declared
is associated with one or multiple active rules declared in `rules()`.
## Massive Assignment
## Massive Assignment <span id="massive-assignment"></span>
Massive assignment is a convenient way of populating a model with user inputs using a single line of code.
It populates the attributes of a model by assigning the input data directly to the [[yii\base\Model::$attributes]]
@ -327,7 +327,7 @@ $model->body = isset($data['body']) ? $data['body'] : null;
```
### Safe Attributes
### Safe Attributes <span id="safe-attributes"></span>
Massive assignment only applies to the so-called *safe attributes* which are the attributes listed in
[[yii\base\Model::scenarios()]] for the current [[yii\base\Model::scenario|scenario]] of a model.
@ -406,7 +406,7 @@ public function rules()
In this case attributes `username`, `password` and `secret` are required, but `secret` must be assigned explicitly.
## Data Exporting
## Data Exporting <span id="data-exporting"></span>
Models often need to be exported in different formats. For example, you may want to convert a collection of
models into JSON or Excel format. The exporting process can be broken down into two independent steps:

2
docs/guide/structure-modules.md

@ -27,7 +27,7 @@ forum/
```
### Module Classes
### Module Classes <span id="module-classes"></span>
Each module should have a unique module class which extends from [[yii\base\Module]]. The class should be located
directly under the module's [[yii\base\Module::basePath|base path]] and should be [autoloadable](concept-autoloading.md).

14
docs/guide/structure-views.md

@ -48,7 +48,7 @@ or other objects which trigger the [view rendering](#rendering-views).
be recognized by IDEs. It is also a good way of documenting your views.
### Security
### Security <span id="security"></span>
When creating views that generate HTML pages, it is important that you encode and/or filter the data coming
from end users before presenting them. Otherwise, your application may be subject to
@ -116,7 +116,7 @@ methodName($view, $params = [])
```
### Rendering in Controllers
### Rendering in Controllers <span id="rendering-in-controllers"></span>
Within [controllers](structure-controllers.md), you may call the following controller methods to render views:
@ -218,7 +218,7 @@ echo \Yii::$app->view->renderFile('@app/views/site/license.php');
```
### Named Views
### Named Views <span id="named-views"></span>
When you render a view, you can specify the view using either a view name or a view file path/alias. In most cases,
you would use the former because it is more concise and flexible. We call views specified using names as *named views*.
@ -248,7 +248,7 @@ actually render the view file `@app/views/post/view.php`, while calling `$this->
will render the view file `@app/views/post/_overview.php`.
### Accessing Data in Views
### Accessing Data in Views <span id="accessing-data-in-views"></span>
There are two approaches to access data within a view: push and pull.
@ -279,7 +279,7 @@ on context objects. Its drawback is that you need to manually build the data arr
become tedious and error prone if a view is shared and rendered in different places.
### Sharing Data among Views
### Sharing Data among Views <span id="sharing-data-among-views"></span>
The [[yii\base\View|view component]] provides the [[yii\base\View::params|params]] property that you can use
to share data among views.
@ -301,7 +301,7 @@ passed along [[yii\base\View::params|params]]:
```
## Layouts
## Layouts <span id="layouts"></span>
Layouts are a special type of views that represent the common parts of multiple views. For example, the pages
for most Web applications share the same page header and footer. While you can repeat the same page header and footer
@ -571,7 +571,7 @@ Then in the layout, make sure you have the following code in the `<head>` sectio
```
### Registering Meta Tags
### Registering Meta Tags <span id="registering-meta-tags"></span>
Web pages usually need to generate various meta tags needed by different parties. Like page titles, meta tags
appear in the `<head>` section and are usually generated in layouts.

6
docs/guide/tutorial-console.md

@ -20,11 +20,11 @@ As you can see in the screenshot, Yii has already defined a set of commands that
You can learn more about this command in the [Assets Section](structure-assets.md#using-asset-bundles).
- [[yii\console\controllers\CacheController|CacheController]] - Allows you to flush application caches.
- [[yii\console\controllers\FixtureController|FixtureController]] - Manages fixture data loading and unloading for testing purposes.
This command is described in more detail in the [Testing Section about Fixtures](test-fixtures.md#managing-fixtures-with-yii-fixture).
This command is described in more detail in the [Testing Section about Fixtures](test-fixtures.md#managing-fixtures).
- [[yii\console\controllers\HelpController|HelpController]] - Provides help information about console commands, this is the default command
and prints what you have seen in the above output.
- [[yii\console\controllers\MessageController|MessageController]] - Extracts messages to be translated from source files.
To learn more about this command, please refer to the [I18N Section](tutorial-i18n.md#using-the-message-command).
To learn more about this command, please refer to the [I18N Section](tutorial-i18n.md#message-command).
- [[yii\console\controllers\MigrateController|MigrateController]] - Manages application migrations.
Database migrations are described in more detail in the [Database Migration Section](db-migrations.md).
- [[yii\console\controllers\ServeController|ServeController]] - Allows you run PHP built-in web server.
@ -156,7 +156,7 @@ Then reload your shell
exec $SHELL -l
```
Creating your own console commands
Creating your own console commands <span id="create-command"></span>
----------------------------------
### Console Controller and Action

8
docs/guide/tutorial-i18n.md

@ -65,7 +65,7 @@ you can use the following statement to change the target language:
> Tip: If your source language varies among different parts of your code, you can
> override the source language for different message sources, which are described in the next section.
## Message Translation
## Message Translation <span id="message-translation"></span>
### From source language to target language
The message translation service translates a text message from one language (usually the [[yii\base\Application::$sourceLanguage|source language]])
@ -127,7 +127,7 @@ message source.
The [[yii\i18n\PhpMessageSource]] class uses PHP files with a simple PHP array to store message translations.
These files contain a map of the messages in `source language` to the translation in the `target language`.
> Info: You can automatically generate these PHP files by using the [`message` command](#using-the-message-command),
> Info: You can automatically generate these PHP files by using the [`message` command](#message-command),
> which will be introduced later in this chapter.
Each PHP file corresponds to the messages of a single category. By default, the file name should be the same as
@ -679,7 +679,7 @@ If [[yii\i18n\MissingTranslationEvent::translatedMessage]] is set by the event h
> and wish them to treat the missing translations in the same way, you should assign the corresponding event handler to each of them.
### Using the `message` command
### Using the `message` command <span id="message-command"></span>
Translations can be stored in [[yii\i18n\PhpMessageSource|php files]], [[yii\i18n\GettextMessageSource|.po files]] or in a [[yii\i18n\DbMessageSource|database]]. See specific classes for additional options.
@ -736,7 +736,7 @@ to render the view `views/site/index.php`, it will end up rendering the translat
See the [Data Formatting](output-formatting.md) section for details.
## Setting Up PHP Environment
## Setting Up PHP Environment <span id="setup-environment"></span>
Yii uses the [PHP intl extension](https://secure.php.net/manual/en/book.intl.php) to provide most of its I18N features,
such as the date and number formatting of the [[yii\i18n\Formatter]] class and the message formatting using [[yii\i18n\MessageFormatter]].

7
docs/guide/tutorial-yii-integration.md

@ -70,7 +70,7 @@ Yii::$classMap['Class2'] = 'path/to/Class2.php';
```
Using Yii in Third-Party Systems
Using Yii in Third-Party Systems <span id="using-yii-in-others"></span>
--------------------------------
Because Yii provides many excellent features, sometimes you may want to use some of its features to support
@ -118,7 +118,8 @@ Now you can use most features provided by Yii. For example, you can create Activ
to work with databases.
## Using Yii 2 with Yii 1
Using Yii 2 with Yii 1 <span id="using-both-yii2-yii1"></span>
----------------------
If you were using Yii 1 previously, it is likely you have a running Yii 1 application. Instead of rewriting
the whole application in Yii 2, you may just want to enhance it using some of the features only available in Yii 2.
@ -127,7 +128,7 @@ This can be achieved as described below.
> Note: Yii 2 requires PHP 5.4 or above. You should make sure that both your server and the existing application
> support this.
First, install Yii 2 in your existing application by following the instructions given in the [last subsection](#using-yii-in-third-party-systems).
First, install Yii 2 in your existing application by following the instructions given in the [last subsection](#using-yii-in-others).
Second, modify the entry script of the application as follows,

Loading…
Cancel
Save