Skip to content

Commit

Permalink
Updating documentation.
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell committed Mar 28, 2013
1 parent 6c2631f commit eff2f84
Show file tree
Hide file tree
Showing 7 changed files with 101 additions and 4 deletions.
21 changes: 21 additions & 0 deletions cache.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

- [Configuration](#configuration)
- [Cache Usage](#cache-usage)
- [Increments & Decrements](#increments-and-decrements)
- [Database Cache](#database-cache)

<a name="configuration"></a>
Expand All @@ -18,6 +19,10 @@ The cache configuration file also contains various other options, which are docu

Cache::put('key', 'value', $minutes);

**Storing An Item In The Cache If It Doesn't Exist**

Cache::add('key', 'value', $minutes);

**Retrieving An Item From The Cache**

$value = Cache::get('key');
Expand Down Expand Up @@ -52,6 +57,22 @@ Note that all items stored in the cache are serialized, so you are free to store

Cache::forget('key');

<a name="increments-and-decrements"></a>

All drivers except `file` and `database` support the `increment` and `decrement` operations:

**Incrementing A Value**

Cache::increment('key');

Cache::increment('key', $amount);

**Decrementing A Value**

Cache::decrement('key');

Cache::decrement('key', $amount);

<a name="database-cache"></a>
## Database Cache

Expand Down
4 changes: 4 additions & 0 deletions commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,10 @@ You may also use the `ask` and `confirm` methods to prompt the user for input:

$name = $this->ask('What is your name?');

**Asking The User For Secret Input**

$password = $this->secret('What is the password?');

**Asking The User For Confirmation**

if ($this->confirm('Do you wish to continue? [yes|no]'))
Expand Down
21 changes: 21 additions & 0 deletions eloquent.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
- [Basic Usage](#basic-usage)
- [Insert, Update, Delete](#insert-update-delete)
- [Timestamps](#timestamps)
- [Query Scopes](#query-scopes)
- [Relationships](#relationships)
- [Eager Loading](#eager-loading)
- [Inserting Related Models](#inserting-related-models)
Expand Down Expand Up @@ -148,6 +149,26 @@ If you wish to customize the format of your timestamps, you may override the `fr

}

<a name="query-scopes"></a>
## Query Scopes

Scopes allow you to easily re-use query logic in your models. To define a scope, simply prefix a model method with `scope`:

**Defining A Query Scope**

class User extends Eloquent {

public function scopePopular($query)
{
return $query->where('votes', '>', 100);
}

}

**Utilizing A Query Scope**

$users = User::popular()->orderBy('created_at')->get();

<a name="relationships"></a>
## Relationships

Expand Down
4 changes: 2 additions & 2 deletions lifecycle.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Of course, if you have other environments in addition to `local`, you may create
<a name="application-events"></a>
## Application Events

You may also do pre and post request processing by registering `before` and `after` application events:
You may also do pre and post request processing by registering `before`, `after`, `close`, `finish`, and `shutdown` application events:

**Registering Application Events**

Expand All @@ -30,7 +30,7 @@ You may also do pre and post request processing by registering `before` and `aft
//
});

App::after(function()
App::after(function($request, $response)
{
//
});
Expand Down
2 changes: 2 additions & 0 deletions packages.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,8 @@ Some packages may have assets such as JavaScript, CSS, and images. However, we a

**Moving Package Assets To Public**

php artisan asset:publish

php artisan asset:publish vendor/package

If the package is still in the `workbench`, use the `--bench` directive:
Expand Down
10 changes: 8 additions & 2 deletions queues.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

The Laravel Queue component provides a unified API across a variety of different queue services. Queues allow you to defer the processing of a time consuming task, such as sending an e-mail, until a later time, thus drastically speeding up the web requests to your application.

The queue configuration file is stored in `app/config/queue.php`. In this file you will find connection configurations for each of the queue drivers that are included with the framework, which includes a [Beanstalkd](http://kr.github.com/beanstalkd) and synchronous (for local use) driver.
The queue configuration file is stored in `app/config/queue.php`. In this file you will find connection configurations for each of the queue drivers that are included with the framework, which includes a [Beanstalkd](http://kr.github.com/beanstalkd), [IronMQ](http://iron.io), [Amazon SQS](http://aws.amazon.com/sqs), and synchronous (for local use) driver.

<a name="basic-usage"></a>
## Basic Usage
Expand Down Expand Up @@ -85,7 +85,13 @@ You may also specify which queue connection the listener should utilize:

Note that once this task has started, it will continue to run until it is manually stopped. You may use a process monitor such as [Supervisor](http://supervisord.org/) to ensure that the queue listener does not stop running.

To process the only the first job on the queue, you may use the `queue:work` command:
You may also set the length of time (in seconds) each job should be allowed run:

**Specifying The Job Timeout Parameter**

php artisan queue:listen --timeout=60

To process only the first job on the queue, you may use the `queue:work` command:

**Processing The First Job On The Queue**

Expand Down
43 changes: 43 additions & 0 deletions testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
- [Test Environment](#test-environment)
- [Calling Routes From Tests](#calling-routes-from-tests)
- [Mocking Facades](#mocking-facades)
- [Framework Assertions](#framework-assertions)
- [Helper Methods](#helper-methods)

<a name="introduction"></a>
Expand Down Expand Up @@ -105,6 +106,48 @@ We can mock the call to the `Event` class by using the `shouldReceive` method on

> **Note:** You should not mock the `Request` facade. Instead, pass the input you desire into the `call` method when running your test.
<a name="framework-assertions"></a>
## Framework Assertions

Laravel ships with several `assert` methods to make testing a little easier:

**Asserting Responses Are OK**

public function testMethod()
{
$this->call('GET', '/');

$this->assertRepsonseIsOk();
}

**Asserting Responses Are Redirects**

$this->assertRedirectedTo('foo');

$this->assertRedirectedToRoute('route.name');

$this->assertRedirectedToAction('Controller@method');

**Asserting A View Has Some Data**

public function testMethod()
{
$this->call('GET', '/');

$this->assertViewHas('name');
$this->assertViewHas('age', $value);
}

**Asserting The Session Has Some Data**

public function testMethod()
{
$this->call('GET', '/');

$this->assertSessionHas('name');
$this->assertSessionHas('age', $value);
}

<a name="helper-methods"></a>
## Helper Methods

Expand Down

0 comments on commit eff2f84

Please sign in to comment.