Skip to content

Commit

Permalink
Fix a ton of doc formatting issues.
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell committed May 9, 2014
1 parent e5e765e commit fb85738
Show file tree
Hide file tree
Showing 22 changed files with 145 additions and 165 deletions.
16 changes: 8 additions & 8 deletions artisan.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,26 @@ Artisan is the name of the command-line interface included with Laravel. It prov
<a name="usage"></a>
## Usage

To view a list of all available Artisan commands, you may use the `list` command:

#### Listing All Available Commands

php artisan list
To view a list of all available Artisan commands, you may use the `list` command:

Every command also includes a "help" screen which displays and describes the command's available arguments and options. To view a help screen, simply precede the name of the command with `help`:
php artisan list

#### Viewing The Help Screen For A Command

php artisan help migrate
Every command also includes a "help" screen which displays and describes the command's available arguments and options. To view a help screen, simply precede the name of the command with `help`:

You may specify the configuration environment that should be used while running a command using the `--env` switch:
php artisan help migrate

#### Specifying The Configuration Environment

php artisan migrate --env=local
You may specify the configuration environment that should be used while running a command using the `--env` switch:

You may also view the current version of your Laravel installation using the `--version` option:
php artisan migrate --env=local

#### Displaying Your Current Laravel Version

You may also view the current version of your Laravel installation using the `--version` option:

php artisan --version
8 changes: 4 additions & 4 deletions cache.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,17 +95,17 @@ All drivers except `file` and `database` support the `increment` and `decrement`

> **Note:** Cache tags are not supported when using the `file` or `database` cache drivers. Furthermore, when using multiple tags with caches that are stored "forever", performance will be best with a driver such as `memcached`, which automatically purges stale records.
Cache tags allow you to tag related items in the cache, and then flush all caches tagged with a given name. To access a tagged cache, use the `tags` method:

#### Accessing A Tagged Cache

You may store a tagged cache by passing in an ordered list of tag names as arguments, or as an ordered array of tag names.
Cache tags allow you to tag related items in the cache, and then flush all caches tagged with a given name. To access a tagged cache, use the `tags` method.

You may store a tagged cache by passing in an ordered list of tag names as arguments, or as an ordered array of tag names:

Cache::tags('people', 'authors')->put('John', $john, $minutes);

Cache::tags(array('people', 'artists'))->put('Anne', $anne, $minutes);

You may use any cache storage method in combination with tags, including `remember`, `forever`, and `rememberForever`. You may also access cached items from the tagged cache, as well as use the other cache methods such as `increment` and `decrement`:
You may use any cache storage method in combination with tags, including `remember`, `forever`, and `rememberForever`. You may also access cached items from the tagged cache, as well as use the other cache methods such as `increment` and `decrement`.

#### Accessing Items In A Tagged Cache

Expand Down
10 changes: 4 additions & 6 deletions commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,23 +117,21 @@ You may also specify a default value to the `confirm` method, which should be `t
<a name="registering-commands"></a>
## Registering Commands

Once your command is finished, you need to register it with Artisan so it will be available for use. This is typically done in the `app/start/artisan.php` file. Within this file, you may use the `Artisan::add` method to register the command:

#### Registering An Artisan Command

Artisan::add(new CustomCommand);
Once your command is finished, you need to register it with Artisan so it will be available for use. This is typically done in the `app/start/artisan.php` file. Within this file, you may use the `Artisan::add` method to register the command:

If your command is registered in the application [IoC container](/docs/ioc), you may use the `Artisan::resolve` method to make it available to Artisan:
Artisan::add(new CustomCommand);

#### Registering A Command That Is In The IoC Container

If your command is registered in the application [IoC container](/docs/ioc), you may use the `Artisan::resolve` method to make it available to Artisan:

Artisan::resolve('binding.name');

<a name="calling-other-commands"></a>
## Calling Other Commands

Sometimes you may wish to call other commands from your command. You may do so using the `call` method:

#### Calling Another Command

$this->call('command:name', array('argument' => 'foo', '--option' => 'bar'));
8 changes: 4 additions & 4 deletions configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ You may also specify a default value to return if the configuration option does

$timezone = Config::get('app.timezone', 'UTC');

Notice that "dot" style syntax may be used to access values in the various files. You may also set configuration values at run-time:

#### Setting A Configuration Value

Notice that "dot" style syntax may be used to access values in the various files. You may also set configuration values at run-time:

Config::set('database.default', 'sqlite');

Configuration values that are set at run-time are only set for the current request, and will not be carried over to subsequent requests.
Expand Down Expand Up @@ -67,10 +67,10 @@ If you need more flexible environment detection, you may pass a `Closure` to the
return $_SERVER['MY_LARAVEL_ENV'];
});

You may access the current application environment via the `environment` method:

#### Accessing The Current Application Environment

You may access the current application environment via the `environment` method:

$environment = App::environment();

You may also pass arguments to the `environment` method to check if the environment matches a given value:
Expand Down
2 changes: 0 additions & 2 deletions controllers.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,6 @@ If you would like to use another method on the controller as a filter, you may u

Laravel allows you to easily define a single route to handle every action in a controller using simple, REST naming conventions. First, define the route using the `Route::controller` method:

#### Defining A RESTful Controller

Route::controller('users', 'UserController');

The `controller` method accepts two arguments. The first is the base URI the controller handles, while the second is the class name of the controller. Next, just add methods to your controller, prefixed with the HTTP verb they respond to:
Expand Down
4 changes: 2 additions & 2 deletions database.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,10 @@ The `select` method will always return an `array` of results.

DB::statement('drop table users');

You may listen for query events using the `DB::listen` method:

#### Listening For Query Events

You may listen for query events using the `DB::listen` method:

DB::listen(function($sql, $bindings, $time)
{
//
Expand Down
32 changes: 16 additions & 16 deletions events.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,18 @@ The Laravel `Event` class provides a simple observer implementation, allowing yo

$event = Event::fire('auth.login', array($user));

You may also specify a priority when subscribing to events. Listeners with higher priority will be run first, while listeners that have the same priority will be run in order of subscription.

#### Subscribing To Events With Priority

You may also specify a priority when subscribing to events. Listeners with higher priority will be run first, while listeners that have the same priority will be run in order of subscription.

Event::listen('auth.login', 'LoginHandler', 10);

Event::listen('auth.login', 'OtherHandler', 5);

Sometimes, you may wish to stop the propagation of an event to other listeners. You may do so using by returning `false` from your listener:

#### Stopping The Propagation Of An Event

Sometimes, you may wish to stop the propagation of an event to other listeners. You may do so using by returning `false` from your listener:

Event::listen('auth.login', function($event)
{
// Handle the event...
Expand All @@ -52,10 +52,10 @@ If your `start` files are getting too crowded, you could create a separate `app/
<a name="wildcard-listeners"></a>
## Wildcard Listeners

When registering an event listener, you may use asterisks to specify wildcard listeners:

#### Registering Wildcard Event Listeners

When registering an event listener, you may use asterisks to specify wildcard listeners:

Event::listen('foo.*', function($param)
{
// Handle the event...
Expand All @@ -82,10 +82,10 @@ In some cases, you may wish to use a class to handle an event rather than a Clos

Event::listen('auth.login', 'LoginHandler');

By default, the `handle` method on the `LoginHandler` class will be called:

#### Defining An Event Listener Class

By default, the `handle` method on the `LoginHandler` class will be called:

class LoginHandler {

public function handle($data)
Expand All @@ -95,19 +95,19 @@ By default, the `handle` method on the `LoginHandler` class will be called:

}

If you do not wish to use the default `handle` method, you may specify the method that should be subscribed:

#### Specifying Which Method To Subscribe

If you do not wish to use the default `handle` method, you may specify the method that should be subscribed:

Event::listen('auth.login', 'LoginHandler@onLogin');

<a name="queued-events"></a>
## Queued Events

Using the `queue` and `flush` methods, you may "queue" an event for firing, but not fire it immediately:

#### Registering A Queued Event

Using the `queue` and `flush` methods, you may "queue" an event for firing, but not fire it immediately:

Event::queue('foo', array($user));

#### Registering An Event Flusher
Expand All @@ -124,10 +124,10 @@ Finally, you may run the "flusher" and flush all queued events using the `flush`
<a name="event-subscribers"></a>
## Event Subscribers

Event subscribers are classes that may subscribe to multiple events from within the class itself. Subscribers should define a `subscribe` method, which will be passed an event dispatcher instance:

#### Defining An Event Subscriber

Event subscribers are classes that may subscribe to multiple events from within the class itself. Subscribers should define a `subscribe` method, which will be passed an event dispatcher instance:

class UserEventHandler {

/**
Expand Down Expand Up @@ -161,10 +161,10 @@ Event subscribers are classes that may subscribe to multiple events from within

}

Once the subscriber has been defined, it may be registered with the `Event` class.

#### Registering An Event Subscriber

Once the subscriber has been defined, it may be registered with the `Event` class.

$subscriber = new UserEventHandler;

Event::subscribe($subscriber);
12 changes: 6 additions & 6 deletions html.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ If your form is going to accept file uploads, add a `files` option to your array
<a name="csrf-protection"></a>
## CSRF Protection

Laravel provides an easy method of protecting your application from cross-site request forgeries. First, a random token is placed in your user's session. Don't sweat it, this is done automatically. The CSRF token will be added to your forms as a hidden field automatically. However, if you wish to generate the HTML for the hidden field, you may use the `token` method:

#### Adding The CSRF Token To A Form

Laravel provides an easy method of protecting your application from cross-site request forgeries. First, a random token is placed in your user's session. Don't sweat it, this is done automatically. The CSRF token will be added to your forms as a hidden field automatically. However, if you wish to generate the HTML for the hidden field, you may use the `token` method:

echo Form::token();

#### Attaching The CSRF Filter To A Route
Expand All @@ -62,10 +62,10 @@ Laravel provides an easy method of protecting your application from cross-site r
<a name="form-model-binding"></a>
## Form Model Binding

Often, you will want to populate a form based on the contents of a model. To do so, use the `Form::model` method:

#### Opening A Model Form

Often, you will want to populate a form based on the contents of a model. To do so, use the `Form::model` method:

echo Form::model($user, array('route' => array('user.update', $user->id)))

Now, when you generate a form element, like a text input, the model's value matching the field's name will automatically be set as the field value. So, for example, for a text input named `email`, the user model's `email` attribute would be set as the value. However, there's more! If there is an item in the Session flash data matching the input name, that will take precedence over the model's value. So, the priority looks like this:
Expand Down Expand Up @@ -175,10 +175,10 @@ This allows you to quickly build forms that not only bind to model values, but e
<a name="custom-macros"></a>
## Custom Macros

It's easy to define your own custom Form class helpers called "macros". Here's how it works. First, simply register the macro with a given name and a Closure:

#### Registering A Form Macro

It's easy to define your own custom Form class helpers called "macros". Here's how it works. First, simply register the macro with a given name and a Closure:

Form::macro('myField', function()
{
return '<input type="awesome">';
Expand Down
36 changes: 18 additions & 18 deletions ioc.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ Understanding the Laravel IoC container is essential to building a powerful, lar
<a name="basic-usage"></a>
## Basic Usage

There are two ways the IoC container can resolve dependencies: via Closure callbacks or automatic resolution. First, we'll explore Closure callbacks. First, a "type" may be bound into the container:

#### Binding A Type Into The Container

There are two ways the IoC container can resolve dependencies: via Closure callbacks or automatic resolution. First, we'll explore Closure callbacks. First, a "type" may be bound into the container:

App::bind('foo', function($app)
{
return new FooBar;
Expand All @@ -33,19 +33,19 @@ There are two ways the IoC container can resolve dependencies: via Closure callb

When the `App::make` method is called, the Closure callback is executed and the result is returned.

Sometimes, you may wish to bind something into the container that should only be resolved once, and the same instance should be returned on subsequent calls into the container:

#### Binding A "Shared" Type Into The Container

Sometimes, you may wish to bind something into the container that should only be resolved once, and the same instance should be returned on subsequent calls into the container:

App::singleton('foo', function()
{
return new FooBar;
});

You may also bind an existing object instance into the container using the `instance` method:

#### Binding An Existing Instance Into The Container

You may also bind an existing object instance into the container using the `instance` method:

$foo = new Foo;

App::instance('foo', $foo);
Expand All @@ -60,10 +60,10 @@ If your application has a very large number of IoC bindings, or you simply wish
<a name="automatic-resolution"></a>
## Automatic Resolution

The IoC container is powerful enough to resolve classes without any configuration at all in many scenarios. For example:

#### Resolving A Class

The IoC container is powerful enough to resolve classes without any configuration at all in many scenarios. For example:

class FooBar {

public function __construct(Baz $baz)
Expand All @@ -79,10 +79,10 @@ Note that even though we did not register the FooBar class in the container, the

When a type is not bound in the container, it will use PHP's Reflection facilities to inspect the class and read the constructor's type-hints. Using this information, the container can automatically build an instance of the class.

However, in some cases, a class may depend on an interface implementation, not a "concrete type". When this is the case, the `App::bind` method must be used to inform the container which interface implementation to inject:

#### Binding An Interface To An Implementation

However, in some cases, a class may depend on an interface implementation, not a "concrete type". When this is the case, the `App::bind` method must be used to inform the container which interface implementation to inject:

App::bind('UserRepositoryInterface', 'DbUserRepository');

Now consider the following controller:
Expand Down Expand Up @@ -123,10 +123,10 @@ Laravel provides several opportunities to use the IoC container to increase the

In this example, the `OrderRepository` class will automatically be injected into the controller. This means that when [unit testing](/docs/testing) a "mock" `OrderRepository` may be bound into the container and injected into the controller, allowing for painless stubbing of database layer interaction.

[Filters](/docs/routing#route-filters), [composers](/docs/responses#view-composers), and [event handlers](/docs/events#using-classes-as-listeners) may also be resolved out of the IoC container. When registering them, simply give the name of the class that should be used:

#### Other Examples Of IoC Usage

[Filters](/docs/routing#route-filters), [composers](/docs/responses#view-composers), and [event handlers](/docs/events#using-classes-as-listeners) may also be resolved out of the IoC container. When registering them, simply give the name of the class that should be used:

Route::filter('foo', 'FooFilter');

View::composer('foo', 'FooComposer');
Expand All @@ -140,10 +140,10 @@ Service providers are a great way to group related IoC registrations in a single

In fact, most of the core Laravel components include service providers. All of the registered service providers for your application are listed in the `providers` array of the `app/config/app.php` configuration file.

To create a service provider, simply extend the `Illuminate\Support\ServiceProvider` class and define a `register` method:

#### Defining A Service Provider

To create a service provider, simply extend the `Illuminate\Support\ServiceProvider` class and define a `register` method:

use Illuminate\Support\ServiceProvider;

class FooServiceProvider extends ServiceProvider {
Expand All @@ -160,19 +160,19 @@ To create a service provider, simply extend the `Illuminate\Support\ServiceProvi

Note that in the `register` method, the application IoC container is available to you via the `$this->app` property. Once you have created a provider and are ready to register it with your application, simply add it to the `providers` array in your `app` configuration file.

You may also register a service provider at run-time using the `App::register` method:

#### Registering A Service Provider At Run-Time

You may also register a service provider at run-time using the `App::register` method:

App::register('FooServiceProvider');

<a name="container-events"></a>
## Container Events

The container fires an event each time it resolves an object. You may listen to this event using the `resolving` method:

#### Registering A Resolving Listener

The container fires an event each time it resolves an object. You may listen to this event using the `resolving` method:

App::resolvingAny(function($object)
{
//
Expand Down
4 changes: 2 additions & 2 deletions lifecycle.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ Start files serve as a simple place to place any "bootstrapping" code. For examp
<a name="application-events"></a>
## Application Events

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

#### Registering Application Events

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

App::before(function($request)
{
//
Expand Down
Loading

0 comments on commit fb85738

Please sign in to comment.