Skip to content

Add anchors for easier subheading linking #292

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions artisan.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,28 @@ Artisan is the name of the command-line interface included with Laravel. It prov

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

<a name="listing-all-available-commands"></a>
**Listing All Available Commands**

php artisan list

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`:

<a name="viewing-the-help-screen-for-a-command"></a>
**Viewing The Help Screen For A Command**

php artisan help migrate

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

<a name="specifying-the-configuration-environment"></a>
**Specifying The Configuration Environment**

php artisan migrate --env=local

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

<a name="displaying-your-current-laravel-version"></a>
**Displaying Your Current Laravel Version**

php artisan --version
13 changes: 13 additions & 0 deletions cache.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,38 +9,46 @@
<a name="configuration"></a>
## Configuration

<a name="Foo Bar Baz">

Laravel provides a unified API for various caching systems. The cache configuration is located at `app/config/cache.php`. In this file you may specify which cache driver you would like used by default throughout your application. Laravel supports popular caching backends like [Memcached](http://memcached.org) and [Redis](http://redis.io) out of the box.

The cache configuration file also contains various other options, which are documented within the file, so make sure to read over these options. By default, Laravel is configured to use the `file` cache driver, which stores the serialized, cached objects in the filesystem. For larger applications, it is recommended that you use an in-memory cache such as Memcached or APC.

<a name="cache-usage"></a>
## Cache Usage

<a name="storing-an-item-in-the-cache"></a>
**Storing An Item In The Cache**

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

<a name="storing-an-item-in-the-cache-if-it-doesn't-exist"></a>
**Storing An Item In The Cache If It Doesn't Exist**

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

<a name="checking-for-existence-in-cache"></a>
**Checking For Existence In Cache**

if (Cache::has('key'))
{
//
}

<a name="retrieving-an-item-from-the-cache"></a>
**Retrieving An Item From The Cache**

$value = Cache::get('key');

<a name="retrieving-an-item-or-returning-a-default-value"></a>
**Retrieving An Item Or Returning A Default Value**

$value = Cache::get('key', 'default');

$value = Cache::get('key', function() { return 'default'; });

<a name="storing-an-item-in-the-cache-permanently"></a>
**Storing An Item In The Cache Permanently**

Cache::forever('key', 'value');
Expand All @@ -61,6 +69,7 @@ You may also combine the `remember` and `forever` methods:

Note that all items stored in the cache are serialized, so you are free to store any type of data.

<a name="removing-an-item-from-the-cache"></a>
**Removing An Item From The Cache**

Cache::forget('key');
Expand All @@ -70,12 +79,14 @@ Note that all items stored in the cache are serialized, so you are free to store

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

<a name="incrementing-a-value"></a>
**Incrementing A Value**

Cache::increment('key');

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

<a name="decrementing-a-value"></a>
**Decrementing A Value**

Cache::decrement('key');
Expand All @@ -89,6 +100,7 @@ All drivers except `file` and `database` support the `increment` and `decrement`

Cache sections allow you to group related items in the cache, and then flush the entire section. To access a section, use the `section` method:

<a name="accessing-a-cache-section"></a>
**Accessing A Cache Section**

Cache::section('people')->put('John', $john);
Expand All @@ -97,6 +109,7 @@ Cache sections allow you to group related items in the cache, and then flush the

You may also access cached items from the section, as well as use the other cache methods such as `increment` and `decrement`:

<a name="accessing-items-in-a-cache-section"></a>
**Accessing Items In A Cache Section**

$anne = Cache::section('people')->get('Anne');
Expand Down
13 changes: 13 additions & 0 deletions commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ In addition to the commands provided with Artisan, you may also build your own c

To create a new command, you may use the `command:make` Artisan command, which will generate a command stub to help you get started:

<a name="generate-a-new-command-class"></a>
**Generate A New Command Class**

php artisan command:make FooCommand
Expand Down Expand Up @@ -59,18 +60,22 @@ The `VALUE_NONE` option indicates that the option is simply used as a "switch":

While your command is executing, you will obviously need to access the values for the arguments and options accepted by your application. To do so, you may use the `argument` and `option` methods:

<a name="retrieving-the-value-of-a-command-argument"></a>
**Retrieving The Value Of A Command Argument**

$value = $this->argument('name');

<a name="retrieving-all-arguments"></a>
**Retrieving All Arguments**

$arguments = $this->argument();

<a name="retrieving-the-value-of-a-command-option"></a>
**Retrieving The Value Of A Command Option**

$value = $this->option('name');

<a name="retrieving-all-options"></a>
**Retrieving All Options**

$options = $this->option();
Expand All @@ -79,10 +84,12 @@ While your command is executing, you will obviously need to access the values fo

To send output to the console, you may use the `info`, `comment`, `question` and `error` methods. Each of these methods will use the appropriate ANSI colors for their purpose.

<a name="sending-information-to-the-console"></a>
**Sending Information To The Console**

$this->info('Display this on the screen');

<a name="sending-an-error-message-to-the-console"></a>
**Sending An Error Message To The Console**

$this->error('Something went wrong!');
Expand All @@ -91,14 +98,17 @@ To send output to the console, you may use the `info`, `comment`, `question` and

You may also use the `ask` and `confirm` methods to prompt the user for input:

<a name="asking-the-user-for-input"></a>
**Asking The User For Input**

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

<a name="asking-the-user-for-secret-input"></a>
**Asking The User For Secret Input**

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

<a name="asking-the-user-for-confirmation"></a>
**Asking The User For Confirmation**

if ($this->confirm('Do you wish to continue? [yes|no]'))
Expand All @@ -115,12 +125,14 @@ You may also specify a default value to the `confirm` method, which should be `t

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:

<a name="registering-an-artisan-command"></a>
**Registering An Artisan Command**

Artisan::add(new CustomCommand);

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:

<a name="registering-a-command-that-is-in-the-ioc-container"></a>
**Registering A Command That Is In The IoC Container**

Artisan::resolve('binding.name');
Expand All @@ -130,6 +142,7 @@ If your command is registered in the application [IoC container](/docs/ioc), you

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

<a name="calling-another-command"></a>
**Calling Another Command**

$this->call('command.name', array('argument' => 'foo', '--option' => 'bar'));
3 changes: 3 additions & 0 deletions configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ All of the configuration files for the Laravel framework are stored in the `app/

Sometimes you may need to access configuration values at run-time. You may do so using the `Config` class:

<a name="accessing-a-configuration-value"></a>
**Accessing A Configuration Value**

Config::get('app.timezone');
Expand All @@ -21,6 +22,7 @@ You may also specify a default value to return if the configuration option does

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

<a name="setting-a-configuration-value"></a>
**Setting A Configuration Value**

Config::set('database.default', 'sqlite');
Expand Down Expand Up @@ -63,6 +65,7 @@ You may also pass a `Closure` to the `detectEnvironment` method, allowing you to

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

<a name="accessing-the-current-application-environment"></a>
**Accessing The Current Application Environment**

$environment = App::environment();
Expand Down
3 changes: 3 additions & 0 deletions controllers.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ You may also specify controller filters inline using a Closure:

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:

<a name="defining-a-restful-controller"></a>
**Defining A RESTful Controller**

Route::controller('users', 'UserController');
Expand Down Expand Up @@ -140,6 +141,7 @@ Now we can register a resourceful route to the controller:

This single route declaration creates multiple routes to handle a variety of RESTful actions on the photo resource. Likewise, the generated controller will already have stubbed methods for each of these actions with notes informing you which URIs and verbs they handle.

<a name="actions-handled-by-resource-controller"></a>
**Actions Handled By Resource Controller**

Verb | Path | Action | Route Name
Expand Down Expand Up @@ -168,6 +170,7 @@ And, you may also specify a subset of actions to handle on the route:

A catch-all method may be defined which will be called when no other matching method is found on a given controller. The method should be named `missingMethod`, and receives the parameter array for the request as its only argument:

<a name="defining-a-catch-all-method"></a>
**Defining A Catch-All Method**

public function missingMethod($parameters)
Expand Down
6 changes: 6 additions & 0 deletions database.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,32 +18,38 @@ Currently Laravel supports four database systems: MySQL, Postgres, SQLite, and S

Once you have configured your database connection, you may run queries using the `DB` class.

<a name="running-a-select-query"></a>
**Running A Select Query**

$results = DB::select('select * from users where id = ?', array(1));

The `select` method will always return an `array` of results.

<a name="running-an-insert-statement"></a>
**Running An Insert Statement**

DB::insert('insert into users (id, name) values (?, ?)', array(1, 'Dayle'));

<a name="running-an-update-statement"></a>
**Running An Update Statement**

DB::update('update users set votes = 100 where name = ?', array('John'));

<a name="running-a-delete-statement"></a>
**Running A Delete Statement**

DB::delete('delete from users');

> **Note:** The `update` and `delete` statements return the number of rows affected by the operation.

<a name="running-a-general-statement"></a>
**Running A General Statement**

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

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

<a name="listening-for-query-events"></a>
**Listening For Query Events**

DB::listen(function($sql, $bindings, $time)
Expand Down
Loading