diff --git a/docs/guide/authentication.md b/docs/guide/authentication.md index 216b4c6..0b81f14 100644 --- a/docs/guide/authentication.md +++ b/docs/guide/authentication.md @@ -1,12 +1,10 @@ Authentication ============== -Authentication is basically what happens when one is trying to sign in. Typically login and passwords are read from -the form and then application checks if there's such user with such password. +Authentication is the act of verifying who a user is, and is the basis of the login process. Typically, authentication uses an identifier--a username or email address--and password, submitted through a form. The application then compares this information against that previously stored. -In Yii all this is done semi-automatically and what's left to developer is to implement [[\yii\web\IdentityInterface]]. -Typically it is being implemented in `User` model. You can find a full featured example in -[advanced application template](installation.md). Below only interface methods are listed: +In Yii all this is done semi-automatically, leaving the developer to merely implement [[\yii\web\IdentityInterface]]. Typically, implementation is accomplished using the `User` model. You can find a full featured example in the +[advanced application template](installation.md). Below only the interface methods are listed: ```php class User extends ActiveRecord implements IdentityInterface @@ -51,10 +49,8 @@ class User extends ActiveRecord implements IdentityInterface } ``` -First two methods are simple. `findIdentity` given ID returns model instance while `getId` returns ID itself. -`getAuthKey` and `validateAuthKey` are used to provide extra security to the "remember me" cookie. -`getAuthKey` should return a string that is unique for each user. A good idea is to save this value when user is -created using `Security::generateRandomKey()`: +Two of the outlined methods are simple: `findIdentity` is provided with an ID and returns a model instance represented by that ID. The `getId` method returns the ID itself. +Two of the other methods--`getAuthKey` and `validateAuthKey`--are used to provide extra security to the "remember me" cookie. `getAuthKey` should return a string that is unique for each user. A good idea is to save this value when the user is created by using Yii's `Security::generateRandomKey()`: ```php public function beforeSave($insert) @@ -69,4 +65,4 @@ public function beforeSave($insert) } ``` -`validateAuthKey` just compares `$authKey` passed as parameter (got from cookie) with the value got from database. +The `validateAuthKey` method just compares the `$authKey` variable, passed as parameter (itself retrieved from a cookie), with the value fetched from database. diff --git a/docs/guide/composer.md b/docs/guide/composer.md index 7f72f9c..fdf5d81 100644 --- a/docs/guide/composer.md +++ b/docs/guide/composer.md @@ -1,20 +1,28 @@ Composer ======== -Yii2 uses Composer as its package manager. It is a PHP utility that allows you to automatically install libraries and -extensions keeping them up to date and handling dependencies. +Yii2 uses Composer as its package manager. Composer is a PHP utility that can automatically handle the installation of needed libraries and +extensions, thereby keeping those third-party resources up to date while absolving you of the need to manually manage the project's dependencies. Installing Composer ------------------- -Check the official guide for [linux](http://getcomposer.org/doc/00-intro.md#installation-nix) or -[Windows](http://getcomposer.org/doc/00-intro.md#installation-windows). +In order to install Composer, check the official guide for your operating system: + +* [Linux](http://getcomposer.org/doc/00-intro.md#installation-nix) +* [Windows](http://getcomposer.org/doc/00-intro.md#installation-windows) + +All of the details can be found in the guide, but you'll either download Composer directly from [http://getcomposer.org/](http://getcomposer.org/), or run the following command: + +``` +curl -s http://getcomposer.org/installer | php +``` Adding more packages to your project ------------------------------------ -After [installing an application](installing.md) you will find `composer.json` in the root directory of your project. -This file lists packages that your application uses. The part we're interested in is `require` section. +The act of [installing a Yii application](installing.md) creates the `composer.json` file in the root directory of your project. +In this file you list the packages that your application requires. For Yii sites, the most important part of the file is `require` the section: ``` { @@ -25,23 +33,29 @@ This file lists packages that your application uses. The part we're interested i } ``` -Here you can specify package name and version. Additionally to Yii extensions you may check -[packagist](http://packagist.org/) repository for general purpose PHP packages. +Within the `require` section, you specify the name and version of each required package. The above example says that a version greater than or equal to 1.3 of Michaelf's PHP-Markdown package is required, as is version 4.5 or greater of Ezyang's HTMLPurifier. For details of this syntax, see the [official Composer documentation](http://getcomposer.org). -After packages are specified you can type either +The full list of available Composer-supported PHP packages can be found at [packagist](http://packagist.org/). Any Yii extension can also be explicitly named using the syntax: + +??? + +Once you have edited the `composer.json`, you can invoke Composer to install the identified dependencies. For the first installation of the dependencies, use this command: ``` php composer.phar install ``` -or +This must be executed within your Yii project's directory, where the `composer.json` file can be found. Depending upon your operating system and setup, you may need to provide paths to the PHP executable and to the `composer.phar` script. + +For an existing installation, you can have Composer update the dependencies using: ``` php composer.phar update ``` -depending if you're doing it for the first time or not. Then, after some waiting, packages will be installed and ready -to use. You don't need anything to be configured additionally. +Again, you may need to provide specific path references. + +In both cases, after some waiting, the required packages will be installed and ready to use in your Yii application. No additional configuration of those packages will be required. See also diff --git a/docs/guide/form.md b/docs/guide/form.md index c811c10..da7dc31 100644 --- a/docs/guide/form.md +++ b/docs/guide/form.md @@ -1,12 +1,9 @@ Working with forms ================== -The primary way of using forms in Yii is [[\yii\widgets\ActiveForm]]. It should be preferred when you have a model -behind a form. Additionally there are some useful methods in [[\yii\helpers\Html]] that are typically used for adding -buttons and help text. +The primary way of using forms in Yii is through [[\yii\widgets\ActiveForm]]. This approach should be preferred when the form is based upon a model. Additionally, there are some useful methods in [[\yii\helpers\Html]] that are typically used for adding buttons and help text to any form. -First step creating a form is to create a model. It can be either Active Record or regular Model. Let's use regular -login model as an example: +When creating model-based forms, the first step is to define the model itself. The model can be either based upon the Active Record class, or the more generic Model class. For this login example, a generic model will be used: ```php use yii\base\Model; @@ -57,7 +54,7 @@ class LoginForm extends Model } ``` -In controller we're passing model to view where Active Form is used: +The controller will pass an instance of that model to the view, wherein the Active Form widget is used: ```php use yii\helpers\Html; @@ -78,14 +75,11 @@ use yii\widgets\ActiveForm; ``` -In the code above `ActiveForm::begin()` not only creates form instance but marks the beginning of the form. All the content -that is located between `ActiveForm::begin()` and `ActiveForm::end()` will be wrapped with appropriate `