Skip to content

Commit

Permalink
Merge branch 'master' of github.com:laravel/docs
Browse files Browse the repository at this point in the history
Conflicts:
	upgrade.md
  • Loading branch information
taylorotwell committed Aug 1, 2014
2 parents aa32d7b + c528573 commit d579eed
Show file tree
Hide file tree
Showing 9 changed files with 61 additions and 9 deletions.
4 changes: 2 additions & 2 deletions billing.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,12 @@ Sometimes subscriptions are affected by "quantity". For example, your applicatio
$user->subscription()->increment();

// Add five to the subscription's current quantity...
$user->subscription()->increment(5)
$user->subscription()->increment(5);

$user->subscription->decrement();

// Subtract five to the subscription's current quantity...
$user->subscription()->decrement(5)
$user->subscription()->decrement(5);

<a name="cancelling-a-subscription"></a>
## Cancelling A Subscription
Expand Down
6 changes: 6 additions & 0 deletions extending.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,13 +139,19 @@ Let's take a look at the `UserProviderInterface`:
interface UserProviderInterface {

public function retrieveById($identifier);
public function retrieveByToken($identifier, $token);
public function updateRememberToken(UserInterface $user, $token);
public function retrieveByCredentials(array $credentials);
public function validateCredentials(UserInterface $user, array $credentials);

}

The `retrieveById` function typically receives a numeric key representing the user, such as an auto-incrementing ID from a MySQL database. The `UserInterface` implementation matching the ID should be retrieved and returned by the method.

The `retrieveByToken` function retrieves a user by their unique `$identifier` and "remember me" `$token`, stored in a field `remember_token`. As with with previous method, the `UserInterface` implementation should be returned.

The `updateRememberToken` method updates the `$user` field `remember_token` with the new `$token`. The new token can be either a fresh token, assigned on successfull "remember me" login attempt, or a null when user is logged out.

The `retrieveByCredentials` method receives the array of credentials passed to the `Auth::attempt` method when attempting to sign into an application. The method should then "query" the underlying persistent storage for the user matching those credentials. Typically, this method will run a query with a "where" condition on `$credentials['username']`. **This method should not attempt to do any password validation or authentication.**

The `validateCredentials` method should compare the given `$user` with the `$credentials` to authenticate the user. For example, this method might compare the `$user->getAuthPassword()` string to a `Hash::make` of `$credentials['password']`.
Expand Down
2 changes: 2 additions & 0 deletions pagination.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ There are several ways to paginate items. The simplest is by using the `paginate

$users = DB::table('users')->paginate(15);

> **Note:** Currently, pagination operations that use a `groupBy` statement cannot be executed efficiently by Laravel. If you need to use a `groupBy` with a paginated result set, it is recommended that you query the database manually and use `Paginator::make`.
#### Paginating An Eloquent Model

You may also paginate [Eloquent](/docs/eloquent) models:
Expand Down
14 changes: 9 additions & 5 deletions queues.md
Original file line number Diff line number Diff line change
Expand Up @@ -190,15 +190,19 @@ As you can see, the `queue:work` command supports most of the same options avail

### Deploying With Daemon Queue Workers

The simplest way to deploy an application using daemon queue workers is to put the application in maintenance mode at the beginning of your deploymnet. This can be done using the `php artisan down` command. Once the application is in maintenance mode, Laravel will not accept any new jobs off of the queue, but will continue to process existing jobs. Once enough time has passed for all of your existing jobs to execute (usually no longer than 30-60 seconds), you may stop the worker and continue your deployment process.
The simplest way to deploy an application using daemon queue workers is to put the application in maintenance mode at the beginning of your deploymnet. This can be done using the `php artisan down` command. Once the application is in maintenance mode, Laravel will not accept any new jobs off of the queue, but will continue to process existing jobs.

If you are using Supervisor or Laravel Forge, which utilizes Supervisor, you may typically stop a worker with a command like the following:
The easiest way to restart your workers is to include the following command in your deployment script:

supervisorctl stop worker-1
php artisan queue:restart

Once the queues have been drained and your fresh code has been deployed to your server, you should restart the daemon queue work. If you are using Supervisor, this can typically be done with a command like this:
This command will instruct all queue workers to restart after they finish processing their current job.

supervisorctl start worker-1
### Coding For Daemon Queue Workers

Daemon queue workers do not restart the framework before processing each job. Therefore, you should be careful to free any heavy resources before your job finishes. For example, if you are doing image manipulation with the GD library, you should free the memory with `imagedestroy` when you are done.

Similarly, your database connection may disconnect when being used by long-running daemon. You may use the `DB::reconnect` method to ensure you have a fresh connection.

<a name="push-queues"></a>
## Push Queues
Expand Down
11 changes: 10 additions & 1 deletion responses.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,15 @@ The sub-view can then be rendered from the parent view:
</body>
</html>

#### Determining If A View Exists

If you need to check if a view exists, use the `View::exists` method:

if (View::exists('emails.customer'))
{
//
}

<a name="view-composers"></a>
## View Composers

Expand Down Expand Up @@ -222,4 +231,4 @@ The `macro` function accepts a name as its first argument, and a Closure as its

return Response::caps('foo');

You may define your macros in one of your [service providers](/docs/ioc#service-providers).
You may define your macros in one of your [service providers](/docs/ioc#service-providers).
1 change: 1 addition & 0 deletions schema.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ Command | Description
`$table->time('sunrise');` | TIME equivalent to the table
`$table->timestamp('added_on');` | TIMESTAMP equivalent to the table
`$table->timestamps();` | Adds **created\_at** and **updated\_at** columns
`$table->rememberToken();` | Adds `remember_token` as VARCHAR(100) NULL
`->nullable()` | Designate that the column allows NULL values
`->default($value)` | Declare a default value for a column
`->unsigned()` | Set INTEGER to UNSIGNED
Expand Down
2 changes: 1 addition & 1 deletion security.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ By default, Laravel includes a `User` model in your `app/models` directory which

If your application is not using Eloquent, you may use the `database` authentication driver which uses the Laravel query builder.

> **Note:** Before getting started, make sure that your `users` (or equivalent) table contains a nullable, string `remember_token` column of 100 characters. This column will be used to store a token for "remember me" sessions being maintained by your application.
> **Note:** Before getting started, make sure that your `users` (or equivalent) table contains a nullable, string `remember_token` column of 100 characters. This column will be used to store a token for "remember me" sessions being maintained by your application. This can be done by using `$table->rememberToken();` in a migration.
<a name="storing-passwords"></a>
## Storing Passwords
Expand Down
6 changes: 6 additions & 0 deletions templates.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,12 @@ If you don't want the data to be escaped, you may use double curly-braces:
<p>This is user {{ $user->id }}</p>
@endforeach

@forelse($users as $user)
<li>{{ $user->name }}</li>
@empty
<p>No users</p>
@endforelse

@while (true)
<p>I'm looping forever.</p>
@endwhile
Expand Down
24 changes: 24 additions & 0 deletions upgrade.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,30 @@ If you copied the `ClassLoader` call to the `AppServiceProvider` from your `star

If you copied the `App::down` call from your `start/global.php` file into your new `AppServiceProvider`, you should remove this call from the provider. Instead, you may add an `if` statement to your `App::before` global filter which checks for `App::isDownForMaintenance()`. If this method return `true`, you may return any maintenance response you wish.

### Compile Configuration File

The `app/config/compile.php` configuration file should now follow the following format:

<?php

return [

'files' => [
//
],

'providers' => [
//
],

];

The new `providers` option allows you to list service providers which return arrays of files from their `compiles` method.

### Beanstalk Queuing

Laravel 4.3 now requires `"pda/pheanstalk": "~3.0"` instead of `"pda/pheanstalk": "~2.1"` that Laravel 4.2 required.

<a name="upgrade-4.2"></a>
## Upgrading To 4.2 From 4.1

Expand Down

0 comments on commit d579eed

Please sign in to comment.