');
61 |
62 | // save file
63 | grunt.file.write(file, [prepend, content, append].join(''));
64 | });
65 |
66 | });
67 | });
68 |
69 | grunt.loadNpmTasks('grunt-gh-pages');
70 | grunt.loadNpmTasks('grunt-contrib-copy');
71 |
72 | grunt.registerTask('default', ['copy', 'build']);
73 | grunt.registerTask('deploy', ['gh-pages']);
74 | };
75 |
--------------------------------------------------------------------------------
/collections.md:
--------------------------------------------------------------------------------
1 | # Collections
2 |
3 | - [Introduction](#introduction)
4 | - [Basic Usage](#basic-usage)
5 |
6 |
7 | ## Introduction
8 |
9 | The `Illuminate\Support\Collection` class provides a fluent, convenient wrapper for working with arrays of data. For example, check out the following code. We'll use the `collect` helper to create a new collection instance from the array:
10 |
11 | $collection = collect(['taylor', 'abigail', null])->map(function($name)
12 | {
13 | return strtoupper($name);
14 | })
15 | ->reject(function($name)
16 | {
17 | return empty($name);
18 | });
19 |
20 |
21 | As you can see, the `Collection` class allows you to chain its methods to perform fluent mapping and reducing of the underlying array. In general, every `Collection` method returns an entirely new `Collection` instance. To dig in further, keep reading!
22 |
23 |
24 | ## Basic Usage
25 |
26 | #### Creating Collections
27 |
28 | As mentioned above, the `collect` helper will return a new `Illuminate\Support\Collection` instance for the given array. You may also use the `make` command on the `Collection` class:
29 |
30 | $collection = collect([1, 2, 3]);
31 |
32 | $collection = Collection::make([1, 2, 3]);
33 |
34 | Of course, collections of [Eloquent](/docs/{{version}}/eloquent) objects are always returned as `Collection` instances; however, you should feel free to use the `Collection` class wherever it is convenient for your application.
35 |
36 | #### Explore The Collection
37 |
38 | Instead of listing all of the methods (there are a lot) the Collection makes available, check out the [API documentation for the class](http://laravel.com/api/master/Illuminate/Support/Collection.html)!
39 |
--------------------------------------------------------------------------------
/commands.md:
--------------------------------------------------------------------------------
1 | # Artisan Development
2 |
3 | - [Introduction](#introduction)
4 | - [Building A Command](#building-a-command)
5 | - [Registering Commands](#registering-commands)
6 |
7 |
8 | ## Introduction
9 |
10 | In addition to the commands provided with Artisan, you may also build your own custom commands for working with your application. You may store your custom commands in the `app/Console/Commands` directory; however, you are free to choose your own storage location as long as your commands can be autoloaded based on your `composer.json` settings.
11 |
12 |
13 | ## Building A Command
14 |
15 | ### Generating The Class
16 |
17 | To create a new command, you may use the `make:console` Artisan command, which will generate a command stub to help you get started:
18 |
19 | #### Generate A New Command Class
20 |
21 | php artisan make:console FooCommand
22 |
23 | The command above would generate a class at `app/Console/Commands/FooCommand.php`.
24 |
25 | When creating the command, the `--command` option may be used to assign the terminal command name:
26 |
27 | php artisan make:console AssignUsers --command=users:assign
28 |
29 | ### Writing The Command
30 |
31 | Once your command is generated, you should fill out the `name` and `description` properties of the class, which will be used when displaying your command on the `list` screen.
32 |
33 | The `fire` method will be called when your command is executed. You may place any command logic in this method.
34 |
35 | ### Arguments & Options
36 |
37 | The `getArguments` and `getOptions` methods are where you may define any arguments or options your command receives. Both of these methods return an array of commands, which are described by a list of array options.
38 |
39 | When defining `arguments`, the array definition values represent the following:
40 |
41 | [$name, $mode, $description, $defaultValue]
42 |
43 | The argument `mode` may be any of the following: `InputArgument::REQUIRED` or `InputArgument::OPTIONAL`.
44 |
45 | When defining `options`, the array definition values represent the following:
46 |
47 | [$name, $shortcut, $mode, $description, $defaultValue]
48 |
49 | For options, the argument `mode` may be: `InputOption::VALUE_REQUIRED`, `InputOption::VALUE_OPTIONAL`, `InputOption::VALUE_IS_ARRAY`, `InputOption::VALUE_NONE`.
50 |
51 | The `VALUE_IS_ARRAY` mode indicates that the switch may be used multiple times when calling the command:
52 |
53 | InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY
54 |
55 | Would then allow for this command:
56 |
57 | php artisan foo --option=bar --option=baz
58 |
59 | The `VALUE_NONE` option indicates that the option is simply used as a "switch":
60 |
61 | php artisan foo --option
62 |
63 | ### Retrieving Input
64 |
65 | 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:
66 |
67 | #### Retrieving The Value Of A Command Argument
68 |
69 | $value = $this->argument('name');
70 |
71 | #### Retrieving All Arguments
72 |
73 | $arguments = $this->argument();
74 |
75 | #### Retrieving The Value Of A Command Option
76 |
77 | $value = $this->option('name');
78 |
79 | #### Retrieving All Options
80 |
81 | $options = $this->option();
82 |
83 | ### Writing Output
84 |
85 | 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.
86 |
87 | #### Sending Information To The Console
88 |
89 | $this->info('Display this on the screen');
90 |
91 | #### Sending An Error Message To The Console
92 |
93 | $this->error('Something went wrong!');
94 |
95 | ### Asking Questions
96 |
97 | You may also use the `ask` and `confirm` methods to prompt the user for input:
98 |
99 | #### Asking The User For Input
100 |
101 | $name = $this->ask('What is your name?');
102 |
103 | #### Asking The User For Secret Input
104 |
105 | $password = $this->secret('What is the password?');
106 |
107 | #### Asking The User For Confirmation
108 |
109 | if ($this->confirm('Do you wish to continue? [yes|no]'))
110 | {
111 | //
112 | }
113 |
114 | You may also specify a default value to the `confirm` method, which should be `true` or `false`:
115 |
116 | $this->confirm($question, true);
117 |
118 | ### Calling Other Commands
119 |
120 | Sometimes you may wish to call other commands from your command. You may do so using the `call` method:
121 |
122 | $this->call('command:name', ['argument' => 'foo', '--option' => 'bar']);
123 |
124 |
125 | ## Registering Commands
126 |
127 | #### Registering An Artisan Command
128 |
129 | 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/Console/Kernel.php` file. Within this file, you will find a list of commands in the `commands` property. To register your command, simply add it to this list.
130 |
131 | protected $commands = [
132 | 'App\Console\Commands\FooCommand'
133 | ];
134 |
135 | When Artisan boots, all the commands listed in this property will be resolved by the [service container](/docs/{{version}}/container) and registered with Artisan.
136 |
--------------------------------------------------------------------------------
/contributing.md:
--------------------------------------------------------------------------------
1 | # Contribution Guidelines
2 |
3 | If you are submitting documentation for the **current stable release**, submit it to the corresponding branch. For example, documentation for Laravel 5.0 would be submitted to the `5.0` branch. Documentation intended for the next release of Laravel should be submitted to the `master` branch.
--------------------------------------------------------------------------------
/contributions.md:
--------------------------------------------------------------------------------
1 | # Contribution Guide
2 |
3 | - [Bug Reports](#bug-reports)
4 | - [Core Development Discussion](#core-development-discussion)
5 | - [Which Branch?](#which-branch)
6 | - [Security Vulnerabilities](#security-vulnerabilities)
7 | - [Coding Style](#coding-style)
8 |
9 |
10 | ## Bug Reports
11 |
12 | To encourage active collaboration, Laravel strongly encourages pull requests, not just bug reports. "Bug reports" may also be sent in the form of a pull request containing a failing unit test.
13 |
14 | However, if you file a bug report, your issue should contain a title and a clear description of the issue. You should also include as much relevant information as possible and a code sample that demonstrates the issue. The goal of a bug report is to make it easy for yourself - and others - to replicate the bug and develop a fix.
15 |
16 | Remember, bug reports are created in the hope that others with the same problem will be able to collaborate with you on solving it. Do not expect that the bug report will automatically see any activity or that others will jump to fix it. Creating a bug report serves to help yourself and others start on the path of fixing the problem.
17 |
18 | The Laravel source code is managed on Github, and there are repositories for each of the Laravel projects:
19 |
20 | - [Laravel Framework](https://github.com/laravel/framework)
21 | - [Laravel Application](https://github.com/laravel/laravel)
22 | - [Laravel Documentation](https://github.com/laravel/docs)
23 | - [Laravel Cashier](https://github.com/laravel/cashier)
24 | - [Laravel Envoy](https://github.com/laravel/envoy)
25 | - [Laravel Homestead](https://github.com/laravel/homestead)
26 | - [Laravel Homestead Build Scripts](https://github.com/laravel/settler)
27 | - [Laravel Website](https://github.com/laravel/laravel.com)
28 | - [Laravel Art](https://github.com/laravel/art)
29 |
30 |
31 | ## Core Development Discussion
32 |
33 | Discussion regarding bugs, new features, and implementation of existing features takes place in the `#laravel-dev` IRC channel (Freenode). Taylor Otwell, the maintainer of Laravel, is typically present in the channel on weekdays from 8am-5pm (UTC-06:00 or America/Chicago), and sporadically present in the channel at other times.
34 |
35 | The `#laravel-dev` IRC channel is open to all. All are welcome to join the channel either to participate or simply observe the discussions!
36 |
37 |
38 | ## Which Branch?
39 |
40 | **All** bug fixes should be sent to the latest stable branch. Bug fixes should **never** be sent to the `master` branch unless they fix features that exist only in the upcoming release.
41 |
42 | **Minor** features that are **fully backwards compatible** with the current Laravel release may be sent to the latest stable branch.
43 |
44 | **Major** new features should always be sent to the `master` branch, which contains the upcoming Laravel release.
45 |
46 | If you are unsure if your feature qualifies as a major or minor, please ask Taylor Otwell in the `#laravel-dev` IRC channel (Freenode).
47 |
48 |
49 | ## Security Vulnerabilities
50 |
51 | If you discover a security vulnerability within Laravel, please send an e-mail to Taylor Otwell at taylor@laravel.com. All security vulnerabilities will be promptly addressed.
52 |
53 |
54 | ## Coding Style
55 |
56 | Laravel follows the [PSR-4](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-4-autoloader.md) and [PSR-1](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-1-basic-coding-standard.md) coding standards. In addition to these standards, the following coding standards should be followed:
57 |
58 | - The class namespace declaration must be on the same line as `
7 | ## Introduction
8 |
9 | Laravel provides facilities for strong AES encryption via the Mcrypt PHP extension.
10 |
11 |
12 | ## Basic Usage
13 |
14 | #### Encrypting A Value
15 |
16 | $encrypted = Crypt::encrypt('secret');
17 |
18 | > **Note:** Be sure to set a 16, 24, or 32 character random string in the `key` option of the `config/app.php` file. Otherwise, encrypted values will not be secure.
19 |
20 | #### Decrypting A Value
21 |
22 | $decrypted = Crypt::decrypt($encryptedValue);
23 |
24 | #### Setting The Cipher & Mode
25 |
26 | You may also set the cipher and mode used by the encrypter:
27 |
28 | Crypt::setMode('ctr');
29 |
30 | Crypt::setCipher($cipher);
31 |
--------------------------------------------------------------------------------
/errors.md:
--------------------------------------------------------------------------------
1 | # Errors & Logging
2 |
3 | - [Configuration](#configuration)
4 | - [Handling Errors](#handling-errors)
5 | - [HTTP Exceptions](#http-exceptions)
6 | - [Logging](#logging)
7 |
8 |
9 | ## Configuration
10 |
11 | The logging facilities for your application are configured in the `Illuminate\Foundation\Bootstrap\ConfigureLogging` bootstrapper class. This class utilizes the `log` configuration option from your `config/app.php` configuration file.
12 |
13 | By default, the logger is configured to use daily log files; however, you may customize this behavior as needed. Since Laravel uses the popular [Monolog](https://github.com/Seldaek/monolog) logging library, you can take advantage of the variety of handlers that Monolog offers.
14 |
15 | For example, if you wish to use a single log file instead of daily files, you can make the following change to your `config/app.php` configuration file:
16 |
17 | 'log' => 'single'
18 |
19 | Out of the box, Laravel supported `single`, `daily`, `syslog` and `errorlog` logging modes. However, you are free to customize the logging for your application as you wish by overriding the `ConfigureLogging` bootstrapper class.
20 |
21 | ### Error Detail
22 |
23 | The amount of error detail your application displays through the browser is controlled by the `app.debug` configuration option in your `config/app.php` configuration file. By default, this configuration option is set to respect the `APP_DEBUG` environment variable, which is stored in your `.env` file.
24 |
25 | For local development, you should set the `APP_DEBUG` environment variable to `true`. **In your production environment, this value should always be `false`.**
26 |
27 |
28 | ## Handling Errors
29 |
30 | All exceptions are handled by the `App\Exceptions\Handler` class. This class contains two methods: `report` and `render`.
31 |
32 | The `report` method is used to log exceptions or send them to an external service like [BugSnag](https://bugsnag.com). By default, the `report` method simply passes the exception to the base implementation on the parent class where the exception is logged. However, you are free to log exceptions however you wish. If you need to report different types of exceptions in different ways, you may use the PHP `instanceof` comparison operator:
33 |
34 | /**
35 | * Report or log an exception.
36 | *
37 | * This is a great spot to send exceptions to Sentry, Bugsnag, etc.
38 | *
39 | * @param \Exception $e
40 | * @return void
41 | */
42 | public function report(Exception $e)
43 | {
44 | if ($e instanceof CustomException)
45 | {
46 | //
47 | }
48 |
49 | return parent::report($e);
50 | }
51 |
52 | The `render` method is responsible for converting the exception into an HTTP response that should be sent back to the browser. By default, the exception is passed to the base class which generates a response for you. However, you are free to check the exception type or return your own custom response.
53 |
54 | The `dontReport` property of the exception handler contains an array of exception types that will not be logged. By default, exceptions resulting from 404 errors are not written to your log files. You may add other exception types to this array as needed.
55 |
56 |
57 | ## HTTP Exceptions
58 |
59 | Some exceptions describe HTTP error codes from the server. For example, this may be a "page not found" error (404), an "unauthorized error" (401) or even a developer generated 500 error. In order to return such a response, use the following:
60 |
61 | abort(404);
62 |
63 | Optionally, you may provide a response:
64 |
65 | abort(403, 'Unauthorized action.');
66 |
67 | This method may be used at any time during the request's lifecycle.
68 |
69 | ### Custom 404 Error Page
70 |
71 | To return a custom view for all 404 errors, create a `resources/views/errors/404.blade.php` file. This view will be served on all 404 errors generated by your application.
72 |
73 |
74 | ## Logging
75 |
76 | The Laravel logging facilities provide a simple layer on top of the powerful [Monolog](http://github.com/seldaek/monolog) library. By default, Laravel is configured to create daily log files for your application which are stored in the `storage/logs` directory. You may write information to the log like so:
77 |
78 | Log::info('This is some useful information.');
79 |
80 | Log::warning('Something could be going wrong.');
81 |
82 | Log::error('Something is really going wrong.');
83 |
84 | The logger provides the seven logging levels defined in [RFC 5424](http://tools.ietf.org/html/rfc5424): **debug**, **info**, **notice**, **warning**, **error**, **critical**, and **alert**.
85 |
86 | An array of contextual data may also be passed to the log methods:
87 |
88 | Log::info('Log message', ['context' => 'Other helpful information']);
89 |
90 | Monolog has a variety of additional handlers you may use for logging. If needed, you may access the underlying Monolog instance being used by Laravel:
91 |
92 | $monolog = Log::getMonolog();
93 |
94 | You may also register an event to catch all messages passed to the log:
95 |
96 | #### Registering A Log Event Listener
97 |
98 | Log::listen(function($level, $message, $context)
99 | {
100 | //
101 | });
102 |
--------------------------------------------------------------------------------
/gh-pages/_config.yml:
--------------------------------------------------------------------------------
1 | # Site settings
2 | title: 라라벨 한국어 매뉴얼
3 | email: developers@xpressengine.com
4 | description: 라라벨 한글 메뉴얼에 대한 메뉴얼 페이지입니다.
5 | baseurl: "/laravel-korean-docs" # the subpath of your site, e.g. /blog/
6 | url: "http://www.xpressengine.com" # the base hostname & protocol for your site
7 | github_username: xpressengine
8 |
9 | # markdown settings
10 | markdown: redcarpet
11 | redcarpet:
12 | extensions: ["no_intra_emphasis", "no_highlighter", "fenced_code_blocks", "autolink", "strikethrough", "superscript", "with_toc_data", "tables"]
13 |
14 | # Build settings
15 | excerpt_separator: ""
16 |
--------------------------------------------------------------------------------
/gh-pages/_includes/footer.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
15 |
19 |
25 |
52 |
59 |
--------------------------------------------------------------------------------
/gh-pages/_includes/head.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | {% if page.title %}{{ page.title }}{% else %}{{ site.title }}{% endif %}
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/gh-pages/_includes/header.html:
--------------------------------------------------------------------------------
1 |
30 |
31 |
32 | ## 기본 사용법
33 |
34 | #### 컬렉션 생성하기
35 |
36 | 앞서 설명한대로 `collect` 헬퍼 함수는 주어진 배열 대신 새로운 `Illuminate\Support\Collection` 인스턴스를 반환합니다. 또는, `Collection` 클래스의 `make`를 사용할 수도 있습니다:
37 |
38 | $collection = collect([1, 2, 3]);
39 |
40 | $collection = Collection::make([1, 2, 3]);
41 |
42 | 당연하게도 [Eloquent](/laravel-korean-docs/docs/5.0/eloquent)객체의 컬렉션은 항상 `Collection` 인스턴스를 반환합니다. 하지만 어플리케이션의 어디에서라도 `Collection`을 편하게 사용할 수 있습니다.
43 |
44 | #### 컬렉션 둘러보기
45 |
46 | 컬렉션에서 사용 가능한 메소드를 여기에 모두 나열하는 것보다(상당히 많으므로) [API 문서](http://laravel.com/api/master/Illuminate/Support/Collection.html)를 살펴보시기 바랍니다!
47 |
48 |
클릭하여 의견을 공유할 수 있습니다. ( 총 개의 의견이 있습니다. )
49 |
--------------------------------------------------------------------------------
/gh-pages/docs/commands.md:
--------------------------------------------------------------------------------
1 | ---
2 | layout: default
3 | title: "아티즌 명령어 개발하기(Artisan Development)"
4 | permalink: /docs/5.0/commands/
5 | ---
6 |
7 | # 아티즌 명령어 개발하기(Artisan Development)
8 |
9 | - [소개](#introduction)
10 | - [명령어 만들기](#building-a-command)
11 | - [명령어 등록하기](#registering-commands)
12 |
13 |
14 |
15 | ## 소개
16 |
17 | 아티즌에서 제공하는 명령어에 추가로 어플리케이션에서 동작하는 자신의 고유한 명령어를 만들 수 있습니다. 여러분의 고유한 명령어는 `app/Console/Commands` 디렉토리에 저장하면 됩니다만, 실제로는 명령어가 `composer.json` 세팅을 기반하여 오토로딩 될 수 있다면 어느 위치에 넣어도 상관없습니다.
18 |
19 |
클릭하여 의견을 공유할 수 있습니다. ( 총 개의 의견이 있습니다. )
20 |
21 |
22 | ## 명령어 만들기
23 |
24 | ### 클래스 생성하기
25 |
26 | 새로운 명령어를 생성하기 위해 아티즌 명령어 `make:console`을 사용합니다:
27 |
28 | #### 새로운 명령어 클래스 생성하기
29 |
30 | php artisan make:console FooCommand
31 |
32 | 이 명령어는 `app/Console/Commands/FooCommand.php`파일을 생성할 것입니다.
33 |
34 | 명령어를 생성할 때 `--command` 옵션을 사용하면 터미널에서 사용할 명령어 이름을 지정할 수 있습니다:
35 |
36 | php artisan make:console AssignUsers --command=users:assign
37 |
38 | ### 명령어 작성하기
39 |
40 | 명령어가 생성되면 클래스의 `name`과 `description`을 입력합니다. 이것들은 `list` 화면에 커맨드를 표시 할 때 사용됩니다.
41 |
42 | `file` 메소드는 명령이 실행될 때 호출됩니다. 수행할 로직을 이 메소드 안에 작성하면 됩니다.
43 |
44 | ### 인자 & 옵션
45 |
46 | 명령어가 입력받는 인자와 옵션을 `getArguments`와 `getOptions` 메소드에 정의합니다. 이 두 메소드는 배열 옵션 목록에서 표시되는 커맨드의 배열을 반환합니다.
47 |
48 | `arguments`를 정의하는 정의 배열은 다음과 같은 형식입니다:
49 |
50 | [$name, $mode, $description, $defaultValue]
51 |
52 | 인자의 `mode`는 `InputArgument::REQUIRED` 또는 `InputArgument::OPTIONAL` 중 하나의 값을 가집니다.
53 |
54 | `options`를 정의하는 배열은 다음과 같은 형식입니다:
55 |
56 | [$name, $shortcut, $mode, $description, $defaultValue]
57 |
58 | 옵션에서 `mode`는 `InputOption:REQUIRED`, `InputOption::OPTIONAL`, `InputOption::VALUE_IS_ARRAY`, `InputOption::VALUE_NONE` 중 하나의 값을 가집니다.
59 |
60 | `VALUE_IS_ARRAY` 모드는 명령 실행 시 여러 번 사용되는 스위치를 나타냅니다:
61 |
62 | InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY
63 |
64 | 위의 모드는 다음의 커맨드를 허용합니다:
65 |
66 | php artisan foo --option=bar --option=baz
67 |
68 | `VALUE_NONE` 옵션은 이 옵션이 단순히 스위치로 사용된다는 것을 나타냅니다:
69 |
70 | php artisan foo --option
71 |
72 | ### Retrieving Input 입력값 조회하기
73 |
74 | 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: 이 경우 `argument`와 `option`메소드를 사용하면 됩니다.
75 |
76 | #### 명령어 인자 값 조회
77 |
78 | $value = $this->argument('name');
79 |
80 | #### 모든 인자 값을 조회하기
81 |
82 | $arguments = $this->argument();
83 |
84 | #### 명령어 옵션 값 조회하기
85 |
86 | $value = $this->option('name');
87 |
88 | #### 모든 옵션 값 조회하기
89 |
90 | $options = $this->option();
91 |
92 | ### 출력 작성하기
93 |
94 | 콘솔에 출력하려면 `info`, `comment`, `question`과 `error` 메소드를 사용하면 됩니다. 각 메소드는 용도에 따라 적절한 ANSI 컬러로 표시됩니다.
95 |
96 | #### 콘솔에 정보 표시하기
97 |
98 | $this->info('Display this on the screen');
99 |
100 | #### 콘솔에 에러 메세지 표시하기
101 |
102 | $this->error('Something went wrong!');
103 |
104 | ### 질문하기
105 |
106 | 사용자 입력을 요청하는 `ask`와 `confirm` 메소드도 사용할 수 있습니다:
107 |
108 | #### 사용자에게 입력을 요구하기
109 |
110 | $name = $this->ask('What is your name?');
111 |
112 | #### 사용자에게 비밀 문자열 입력을 요구하기
113 |
114 | $password = $this->secret('What is the password?');
115 |
116 | #### 사용자에게 확인을 요구하기
117 |
118 | if ($this->confirm('Do you wish to continue? [yes|no]'))
119 | {
120 | //
121 | }
122 |
123 | `confirm` 메소드에 대한 기본값을 `true`와 `false`로 지정할 수 있습니다:
124 |
125 | $this->confirm($question, true);
126 |
127 | ### 다른 명령어 호출하기
128 |
129 | 때로는 해당 명령어가 다른 명령어를 호출해야 할 때가 있습니다. 이 경우에 `call` 메소드를 사용하면 됩니다:
130 |
131 | $this->call('command:name', ['argument' => 'foo', '--option' => 'bar']);
132 |
133 |
클릭하여 의견을 공유할 수 있습니다. ( 총 개의 의견이 있습니다. )
134 |
135 |
136 | ## 명령어 등록하기
137 |
138 | #### 아티즌 명령어 등록하기
139 |
140 | 명령어 작성이 완료되면 명령어를 사용가능하도록 아티즌에 등록해야 합니다. 이 작업은 일반적으로 `app/Console/Kernel.php` 파일에서 이루어 집니다. 이 파일에서 명령어들의 목록을 담고 있는 `command` 변수를 찾을 수 있을 것입니다. 여러분이 작성한 명령어를 등록하려면 해당 배열에 생성한 명령어 클래스를 추가하십시오.
141 |
142 | protected $commands = [
143 | 'App\Console\Commands\FooCommand'
144 | ];
145 |
146 | 아티즌이 구동되면서 변수 내의 모든 명령어의 목록을 참고하여 [service container](/laravel-korean-docs/docs/5.0/container)들이 자동으로 실행 가능한 상태로 아티즌에 등록됩니다.
147 |
148 |
클릭하여 의견을 공유할 수 있습니다. ( 총 개의 의견이 있습니다. )
149 |
--------------------------------------------------------------------------------
/gh-pages/docs/contributing.md:
--------------------------------------------------------------------------------
1 | ---
2 | layout: default
3 | title: "기여 가이드라인(Contribution Guidelines)"
4 | permalink: /docs/5.0/contributing/
5 | ---
6 |
7 | # 기여 가이드라인(Contribution Guidelines)
8 |
9 | **현재 안정릴리즈 버전**의 문서에 기여하려는 경우에는 해당 버전 브랜치에 보내주시기 바랍니다. 예를 들어, 라라벨 5.0의 문서라면 `5.0` 브랜치에 보내주시기 바랍니다. 다음 릴리즈 버전의 문서로 보내는 경우에는 `master` 브랜치로 보내 주시기 바랍니다.
10 |
--------------------------------------------------------------------------------
/gh-pages/docs/contributions.md:
--------------------------------------------------------------------------------
1 | ---
2 | layout: default
3 | title: "기여 가이드(Contribution Guide)"
4 | permalink: /docs/5.0/contributions/
5 | ---
6 |
7 | # 기여 가이드(Contribution Guide)
8 |
9 | - [버그 리포트](#bug-reports)
10 | - [핵심기능에 대한 개발 논의](#core-development-discussion)
11 | - [브랜치 선택](#which-branch)
12 | - [보안 취약점](#security-vulnerabilities)
13 | - [코딩 스타일](#coding-style)
14 |
15 |
16 | ## 버그 리포트
17 |
18 | 활발한 협력을 장려하기 위해, 라라벨은 버그 리포트가 아니라 PR을 권장하고 있습니다. "버그 리포트"는 실패한 단위 테스트를 포함한 PR로 보내져야 합니다.
19 |
20 | 버그 리포트를 작성하는 경우, 이슈는 제목과 이슈에 대한 명확한 설명을 포함해야 합니다. 또한, 해당 이슈에 대한 가능한 많은 관련 정보와 데모 코드 샘플을 포함해야 합니다. 버그 리포트의 목적은 여러분 자신과 그리고 다른 사람들도 쉽게 버그를 재현 할 수 있도록 하고 버그가 수정되도록 하는 것입니다.
21 |
22 | 명심할 것은 버그 리포트가 같은 문제에 있던 다른 사람들과 문제를 해결하기 위해 협력 할 수 있는 기회을 만든다는 것입니다. 버그 리포트를 통해 자동으로 뭔가가 일어나고, 다른 누군가가 문제를 해결하기를 기대하지 마십시오. 버그 리포트 제출은 여러분 자신과 다른 사람이 문제를 해결하는 길을 시작하는 계기가 되는 것입니다.
23 |
24 | 라라벨의 소스 코드는 GitHub에서 관리되며 각각의 라라벨 프로젝트의 저장소가 있습니다:
25 |
26 | - [Laravel Framework 라라벨 프레임워크](https://github.com/laravel/framework)
27 | - [Laravel Application 라라벨 어플리케이션](https://github.com/laravel/laravel)
28 | - [Laravel Documentation 라라벨 매뉴얼](https://github.com/laravel/docs)
29 | - [Laravel Cashier 라라벨 캐셔](https://github.com/laravel/cashier)
30 | - [Laravel Envoy 라라벨 Envoy](https://github.com/laravel/envoy)
31 | - [Laravel Homestead 라라벨 Homestead](https://github.com/laravel/homestead)
32 | - [Laravel Homestead Build Scripts 라라벨 Homestead 빌드 스크립트](https://github.com/laravel/settler)
33 | - [Laravel Website 라라벨 웹사이트](https://github.com/laravel/website)
34 | - [Laravel Art 라라벨 아트웤](https://github.com/laravel/art)
35 |
36 |
클릭하여 의견을 공유할 수 있습니다. ( 총 개의 의견이 있습니다. )
37 |
38 |
39 | ## 핵심기능에 대한 개발 논의
40 |
41 | 버그에 대한, 새로운 기능 및 기존 기능의 구현에 대한 논의는 Freenode의 `#laravel-dev` IRC 채널에서 진행하고 있습니다. 라라벨의 메인 관리자 인 Taylor Otwell는 일반적으로 평일 오전 8시부 터5 시까 지 (America / Chicago 표준시 UTC-06 : 00 기준) 접속해 있고, 그외에 다른 시간대에는 가끔 접속합니다.
42 |
43 | `#laravel-dev` IRC 채널은 모든 사람에게 개방되어 있습니다. 토론에 참여하거나, 혹은 그냥보고 있는 것만으로도 괜찮습니다, 채널에 많이 참가하세요!
44 |
45 |
클릭하여 의견을 공유할 수 있습니다. ( 총 개의 의견이 있습니다. )
46 |
47 |
48 | ## 브랜치 선택
49 |
50 | **모든** 버그 수정은 최신 안정 브랜치에 보내져야 합니다. 다음 릴리스에만 존재하는 기능에 대한 수정사항이 아니라면 버그 수정사항을 `master` 브랜치에 **절대** 보내지 마십시오.
51 |
52 | 현재 라라벨 릴리스와 **완전히 거꾸로 겸용성**을 가진 **작은** 기능은 최신 안정 브랜치로 보내 주시기 바랍니다.
53 |
54 | 다음 라라벨 릴리즈에 포함될, 새로운 기능들은 항상 `master` 브랜치로 보내 주시기 바랍니다.
55 |
56 | 만약 여러분의 새로운 기능이 메이저인지 마이너인지 명확하지 않다면 Freenode의 `#laravel-dev` IRC 채널에서 Taylor Otwell에 문의 하길바랍니다.
57 |
58 |
클릭하여 의견을 공유할 수 있습니다. ( 총 개의 의견이 있습니다. )
59 |
60 |
61 | ## 보안 취약점
62 |
63 | 만약 라라벨에서 보안 취약점을 발견했다면 테일러 오트웰 taylor@laravel.com에게 이메일을 보내주시길 바랍니다. 모든 보안 취약점은 신속하게 해결될 것입니다.
64 |
65 |
클릭하여 의견을 공유할 수 있습니다. ( 총 개의 의견이 있습니다. )
66 |
67 |
68 | ## 코딩 스타일
69 |
70 | 라라벨은 [PSR-4](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-4-autoloader.md)와 [PSR-1](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-1-basic-coding-standard.md) 코딩 표준을 따르고 있습니다. 이러한 기준에 더하여, 다음과 같은 코딩 표준을 따라야 합니다.
71 |
72 | - 클래스 네임스페이스는 반드시 `
클릭하여 의견을 공유할 수 있습니다. ( 총 개의 의견이 있습니다. )
78 |
--------------------------------------------------------------------------------
/gh-pages/docs/encryption.md:
--------------------------------------------------------------------------------
1 | ---
2 | layout: default
3 | title: "암호화(Encryption)"
4 | permalink: /docs/5.0/encryption/
5 | ---
6 |
7 | # 암호화(Encryption)
8 |
9 | - [소개](#introduction)
10 | - [기본 사용법](#basic-usage)
11 |
12 |
13 | ## 소개
14 |
15 | 라라벨은 Mcrypt PHP 확장을 이용한 강력한 AES 암호화 기능을 제공합니다.
16 |
17 |
18 | ## 기본 사용법
19 |
20 | #### 주어진 값 암호화하기
21 |
22 | $encrypted = Crypt::encrypt('secret');
23 |
24 | > **참고:** `config/app.php` 파일의 `key` 옵션에 16,24 또는 32 자리의 임의의 문자열을 정확히 지정하십시오. 이를 설정하지 않으면 암호화된 결과값은 안전하지 않습니다.
25 |
26 | #### 값 복호화하기
27 |
28 | $decrypted = Crypt::decrypt($encryptedValue);
29 |
30 | #### 암호 & 모드 설정하기
31 |
32 | 암호화에 사용하는 방법과 모드를 지정할 수 있습니다;
33 |
34 | Crypt::setMode('ctr');
35 |
36 | Crypt::setCipher($cipher);
37 |
38 |
클릭하여 의견을 공유할 수 있습니다. ( 총 개의 의견이 있습니다. )
39 |
--------------------------------------------------------------------------------
/gh-pages/docs/hashing.md:
--------------------------------------------------------------------------------
1 | ---
2 | layout: default
3 | title: "해시(Hashing)"
4 | permalink: /docs/5.0/hashing/
5 | ---
6 |
7 | # 해시(Hashing)
8 |
9 | - [소개](#introduction)
10 | - [기본 사용법](#basic-usage)
11 |
12 |
13 | ## 소개
14 |
15 | 라라벨의 `Hash` 파사드는 사용자의 암호를 저장하는 데 필요한 안전한 Bcrypt 해싱을 제공합니다. 만약 라라벨 어플리케이션에 포함되어 있는 `AuthController` 컨트롤러를 사용하고 있다면 사용자로부터 입력받은 해시되지 않은 암호를 Bcrypt 된 암호와 비교하여 확인할 수 있습니다.
16 |
17 | 마찬가지로, 라라벨과 함께 제공되는 사용자 `Registrar` 서비스는 저장된 패스워드를 해시하기 위한 `bcrypt` 함수를 제공합니다.
18 |
19 |
23 |
24 |
25 | ## 라이프사이클 개요
26 |
27 | #### 시작
28 |
29 | 라라벨 어플리케이션의 모든 요청에 대한 시작점은 `public/index.php` 파일입니다. 웹서버 (Apache / Nginx)의 설정에 따라 모든 요청은 이 파일에 전달됩니다. `index.php` 파일은 그다지 많은 코드를 가지고 있지 않습니다. 대신 프레임 워크의 나머지를 로딩하기 위한 시작점이 됩니다.
30 |
31 | `index.php` 파일은 컴포저가 생성 한 오토로더 정의를 로딩합니다. 그리고, `bootstrap/app.php` 스크립트에서 라라벨 어플리케이션의 인스턴스를 가져옵니다. 라라벨 자신의 첫 번째 동작은 [서비스 컨테이너](/laravel-korean-docs/docs/5.0/container) 인스턴스를 생성하는 것입니다.
32 |
33 | #### HTTP / Console 커널
34 |
35 | 다음으로 어플리케이션이 시작된 유형에 따라 전송된 요청을 HTTP 커널이나 콘솔 커널 둘 중 하나로 보냅니다. 이 두 가지의 커널은 모든 요청의 흐름 중심에서 작동하게 됩니다. 여기에서는 `app/Http/Kernel.php` 에있는 HTTP 커널에 초점을 맞춰 봅시다.
36 |
37 | HTTP 커널은 `Illuminate\Foundation\Http\Kernel` 클래스를 상속하고 있으며, 요청을 실행하기 전에 처리되는 `bootstrappers` (시작 코드)의 배열을 정의하고 있습니다. 이 시작 코드들은 에러 처리, 로그 설정, 어플리케이션 동작 환경의 감지 등 실제로 요청이 처리되기 전에 수행해야 되는 작업들을 의미합니다.
38 |
39 | 또한, HTTP 커널은 어플리케이션에서 요청이 처리되기 전에 통과해야하는 HTTP [미들웨어](/laravel-korean-docs/docs/5.0/middleware)의 목록을 정의하고 있습니다. 이 미들웨어들은 HTTP 세션 읽고/쓰고, 어플리케이션이 유지 관리 모드인지 확인하고, CSRF 토큰을 확인 하는 작업들을 처리합니다.
40 |
41 | HTTP 커널의 `handle` 메소드의 사용법은 매우 간단합니다. 단순하게는 `Request`를 받고 `Response`를 반환합니다. 커널을 어플리케이션 전체를 나타내는 하나의 큰 블랙 박스라고 생각해봅시다. HTTP 요청이 입력되면 HTTP 응답이 반환됩니다.
42 |
43 | #### 서비스 프로바이더
44 |
45 | 커널 부팅(부트스트래핑) 과정의 가장 중요한 것 중의 하나는 어플리케이션의 서비스 프로바이더를 로딩하는 것입니다. 어플리케이션의 모든 서비스 프로바이더는 `config/app.php` 파일의 `providers` 배열에 설정되어 있습니다. 먼저, 모든 서비스 프로바이더의 `register` 메소드가 호출되고, 이후에 등록 된 모든 서비스 프로바이더의 `boot` 메소드가 호출되어 집니다.
46 |
47 | #### 요청 처리-디스패칭
48 |
49 | 어플리케이션이 부팅(부트스트래핑)되고 모든 서비스 프로바이더가 등록된 후, `Request`는 라우터 처리리를 위해서 전달될 것입니다. 라우터는 라우팅 또는 컨트롤러로 요청-request을 전달할뿐만 아니라, 임의의 특정 라우트에 지정된 미들웨어도 실행합니다.
50 |
51 |
클릭하여 의견을 공유할 수 있습니다. ( 총 개의 의견이 있습니다. )
52 |
53 |
54 | ## 서비스 프로바이더
55 |
56 | 서비스 프로바이더는 라라벨 어플리케이션의 부팅(부트스트래핑) 단계의 주요한 핵심입니다. 어플리케이션의 인스턴스가 생성되고, 서비스 프로바이더가 등록된후 부트스트래핑 과정을 마친 프로그램이 요청을 처리합니다. 매우 간단합니다!
57 |
58 | 라라벨 어플리케이션이 어떻게 구성되어 있는지, 서비스 프로바이더를 통해 부트스트랩되는 과정을 구체적으로 이해하는 것은 매우 중요합니다. 물론 여러분의 어플리케이션을 위한 기본 서비스 프로바이더는 `app/Providers` 디렉토리에 있습니다.
59 |
60 | 기본적으로 `AppServiceProvider`는 거의 비어 있습니다. 이 프로바이더는 여러분의 고유한 부트스트래핑과 서비스 컨테이너 바인딩 코드를 추가하기 위한 곳입니다. 물론 보다 큰 어플리케이션의 경우, 보다 세부적인 유형으로 구분된 종류별로 서비스 프로바이더를 만들 수도 있습니다.
61 |
62 |
클릭하여 의견을 공유할 수 있습니다. ( 총 개의 의견이 있습니다. )
63 |
--------------------------------------------------------------------------------
/gh-pages/docs/migrations.md:
--------------------------------------------------------------------------------
1 | ---
2 | layout: default
3 | title: "마이그레이션 & 시딩(Migrations & Seeding)"
4 | permalink: /docs/5.0/migrations/
5 | ---
6 |
7 | # 마이그레이션 & 시딩(Migrations & Seeding)
8 |
9 | - [소개](#introduction)
10 | - [마이그레이션 생성하기](#creating-migrations)
11 | - [마이그레이션 실행하기](#running-migrations)
12 | - [마이그레이션 롤백하기](#rolling-back-migrations)
13 | - [데이터베이스 시딩(초기값 입력하기)](#database-seeding)
14 |
15 |
16 | ## 소개
17 |
18 | 마이그레이션은 데이터베이스용 버전 컨트롤러의 일종입니다. 마이그레이션은 여러분의 팀이 데이터베이스 스키마를 수정하고 현재의 스키마 상태를 유지할 수 있도록 해줍니다. 마이그레이션은 일반적으로 어플리케이션의 스키마를 쉽게 관리할 수 있는 [스키마 빌더](/laravel-korean-docs/docs/5.0/schema)와 함께 사용됩니다.
19 |
20 |
클릭하여 의견을 공유할 수 있습니다. ( 총 개의 의견이 있습니다. )
21 |
22 |
23 | ## 마이그레이션 생성하기
24 |
25 | 마이그레이션을 생성하기 위해서는 `make:migration`아티즌 CLI 명령어를 사용합니다:
26 |
27 | php artisan make:migration create_users_table
28 |
29 | 마이그레이션 파일들은 `database/migrations` 폴더에 저장되고 프레임워크가 마이그레이션의 순서를 알 수 있도록 타임스탬프를 포함하고 있습니다.
30 |
31 | `--table`과 `--create`옵션은 테이블의 이름과 마이그레이션 하면서 새 테이블을 만들 것인지를 결정하는 데 사용할 수 있습니다.
32 |
33 | php artisan make:migration add_votes_to_users_table --table=users
34 |
35 | php artisan make:migration create_users_table --create=users
36 |
37 |
클릭하여 의견을 공유할 수 있습니다. ( 총 개의 의견이 있습니다. )
38 |
39 |
40 | ## 마이그레이션 실행하기
41 |
42 | #### 실행되지 않은 전체 마이그레이션 실행
43 |
44 | php artisan migrate
45 |
46 | > **참고 :** 마이그레이션 실행 시 "class not found" 에러 메세지가 출력된다면 `composer dump-autoload` 명령어를 실행해보십시오.
47 |
48 | ### 실제 제품 서버에서 강제로 마이그레이션 실행하기
49 |
50 | 일부의 마이그레이션 작업은 구조 변경이 있을 수 있으며 이로 인해 데이터를 잃을 수도 있습니다. 이러한 위험들로부터 실제 제품 서버의 데이터베이스를 보호하기 위해 마이그레이션 명령어를 실행하기 전에 확인 메시지가 출력됩니다. 확인 메시지 없이 명령어을 실행시키기 위해서는 `--force` 플래그를 사용하면 됩니다:
51 |
52 | php artisan migrate --force
53 |
54 |
클릭하여 의견을 공유할 수 있습니다. ( 총 개의 의견이 있습니다. )
55 |
56 |
57 | ## 마이그레이션 롤백하기
58 |
59 | #### 가장 최근의 마이그레이션 작업 롤백하기
60 |
61 | php artisan migrate:rollback
62 |
63 | #### 모든 마이그레이션 작업 롤백하기
64 |
65 | php artisan migrate:reset
66 |
67 | #### 모든 마이그레이션 작업을 롤백하고 다시 실행하기
68 |
69 | php artisan migrate:refresh
70 |
71 | php artisan migrate:refresh --seed
72 |
73 |
클릭하여 의견을 공유할 수 있습니다. ( 총 개의 의견이 있습니다. )
74 |
75 |
76 | ## 데이터베이스 시딩
77 |
78 | 라라벨에서는 시드(seed) 클래스를 사용해서 테스트 데이터를 데이터베이스에 설정하는 간단한 방법을 제공합니다. 모든 시드 클래스는 `database/seeds` 폴더에 저장됩니다. 시드 클래스의 이름은 원하는 대로 작성할 수 있지만 될 수 있으면 `UserTableSeeder`등과 같이 직관적인 이름 규칙을 따르는 것이 좋습니다. 기본값으로 `DatabaseSeeder`클래스가 정의되어 있습니다. 이 클래스에서 `call` 메소드로 다른 시드 클래스를 호출해서 시딩(seeding) 순서를 조정할 수 있습니다.
79 |
80 | #### 데이터베이스 시드(seed) 클래스 예제
81 |
82 | class DatabaseSeeder extends Seeder {
83 |
84 | public function run()
85 | {
86 | $this->call('UserTableSeeder');
87 |
88 | $this->command->info('User table seeded!');
89 | }
90 |
91 | }
92 |
93 | class UserTableSeeder extends Seeder {
94 |
95 | public function run()
96 | {
97 | DB::table('users')->delete();
98 |
99 | User::create(['email' => 'foo@bar.com']);
100 | }
101 |
102 | }
103 |
104 | 데이터베이스에 초기값을 설정(seed)하려면 `db:seed` 아티즌 CLI 명령어를 사용하면 됩니다:
105 |
106 | php artisan db:seed
107 |
108 | 기본적으로 `db:seed` 명령어는 다른 시드(seed) 클래스들을 호출하는 `DatabaseSeeder`클래스를 실행합니다. 하지만 `--class`옵션을 사용해서 특정 시더(seeder) 클래스가 개별적으로 실행되도록 지정할 수 있습니다:
109 |
110 | php artisan db:seed --class=UserTableSeeder
111 |
112 | `migrate:refresh`명령어를 사용하면 데이터베이스 초기값을 설정할 때 모든 마이그레이션들을 롤백한 다음 다시 실행 할 것입니다:
113 |
114 | php artisan migrate:refresh --seed
115 |
116 |
클릭하여 의견을 공유할 수 있습니다. ( 총 개의 의견이 있습니다. )
117 |
--------------------------------------------------------------------------------
/gh-pages/docs/pagination.md:
--------------------------------------------------------------------------------
1 | ---
2 | layout: default
3 | title: "페이지네이션(Pagination)"
4 | permalink: /docs/5.0/pagination/
5 | ---
6 |
7 | # 페이지네이션(Pagination)
8 |
9 | - [설정하기](#configuration)
10 | - [사용법](#usage)
11 | - [페이지 링크에 추가하기](#appending-to-pagination-links)
12 | - [JSON으로 변환](#converting-to-json)
13 |
14 |
15 | ## 설정
16 |
17 | 다른 프레임 워크에서는 페이지 출력 처리를 하는것은 굉장히 성가신 일입니다. 하지만 라라벨에서 페이징 처리는 식은 죽 먹기입니다. 라라벨에서는 현재 페이지를 기준으로 페이지 링크들의 “범위”를 손쉽게 생성할 수 있습니다.
18 |
19 |
클릭하여 의견을 공유할 수 있습니다. ( 총 개의 의견이 있습니다. )
20 |
21 |
22 | ## 사용법
23 |
24 | 데이터들의 페이징을 처리 할 수 있는 몇 가지 방법이 있습니다. 가장 쉬운 방법은 `paginate` 메소드를 쿼리빌더 혹은 Eloquent model에서 사용하는 것입니다.
25 |
26 | #### 데이터베이스 결과에 페이징하기
27 |
28 | $users = DB::table('users')->paginate(15);
29 |
30 | > **참고** 현재 라라벨에서`groupBy` 문을 사용하는 경우 페이지를 생성하는 것은 효율적으로 실행될 수 없습니다. 만약 `groupBy` 문의 결과값에 페이징 처리를 사용하고 싶다면 여러분이 직접 데이터베이스를 조회하고 paginator를 만드는 것을 추천합니다.
31 |
32 | #### 직접 Paginator 만들기
33 |
34 | 때때로 여러분은 항목들의 배열을 전달하는 pagination 인스턴스를 직접 만들고자 할 수도 있습니다. 이러한 요구사항에 따라 `Illuminate\Pagination\Paginator` 혹은 `Illuminate\Pagination\LengthAwarePaginator`의 인스턴스를 직접 생성하여 paginator를 수동으로 만들 수도 있습니다.
35 |
36 | #### Eloquent Model에서의 페이징
37 |
38 | 또한, 여러분은 [Eloquent](/laravel-korean-docs/docs/5.0/eloquent) models에서도 페이징 처리를 할 수 있습니다:
39 |
40 | $allUsers = User::paginate(15);
41 |
42 | $someUsers = User::where('votes', '>', 100)->paginate(15);
43 |
44 | `paginate` 메소드에 넘겨지는 인자는 여러분이 한 페이지 당 표시하고 싶어하는 항목들의 개수입니다. 여러분은 결과들을 검색하고 `render` 메소드를 사용하여 데이터들을 view에 표시하고 페이지번호와 링크를 만들 수 있습니다:
45 |
46 |
47 |
48 | name; ?>
49 |
50 |
51 |
52 | render(); ?>
53 |
54 | 지금까지 보신것들이 페이징 시스템에 필요한 전부입니다! 복잡하게 현재 페이지를 프레임워크에게 알릴 필요가 없다는 것을 기억하세요. 라라벨은 현재 페이지를 자동으로 결정할 것입니다.
55 |
56 | 아래의 메소드들로 추가적인 페이징 관련 정보들을 가져올 수 있습니다:
57 |
58 | - `currentPage`
59 | - `lastPage`
60 | - `perPage`
61 | - `hasMorePages`
62 | - `firstItem`
63 | - `lastItem`
64 | - `url`
65 | - `nextPageUrl`
66 | - `firstItem`
67 | - `lastItem`
68 | - `total`
69 | - `count`
70 |
71 | #### “간단한 Pagination"
72 |
73 | 만약 페이지 번호 없이 “다음”과 “이전” 링크 만을 pagination view에서 보여준다면, 더 효율적으로 쿼리를 수행하는 옵션인`simplePaginate` 메소드를 사용할 수 있습니다:
74 |
75 | $someUsers = User::where('votes', '>', 100)->simplePaginate(15);
76 |
77 | #### Paginator URI 커스터마이징
78 |
79 | paginator에서 제공하는 `setPath` 메소드를 통해 URI를 변경 할 수 있습니다:
80 |
81 | $users = User::paginate();
82 |
83 | $users->setPath('custom/url');
84 |
85 | 위의 예제는 다음과 같은 URLs를 만듭니다: http://example.com/custom/url?page=2
86 |
87 |
클릭하여 의견을 공유할 수 있습니다. ( 총 개의 의견이 있습니다. )
88 |
89 |
90 | ## 페이지 링크에 추가하기
91 |
92 | Paginator의 `appends` 메소드를 사용하면 페이지 링크에 쿼리 스트링을 추가할 수 있습니다:
93 |
94 | appends(['sort' => 'votes'])->render(); ?>
95 |
96 | 위의 예제는 아래와 같은 형태의 URLs를 만들것입니다:
97 |
98 | http://example.com/something?page=2&sort=votes
99 |
100 | 만약 “hash fragment”를 페이지 번호의 링크에 추가하고 싶다면 `fragment` 메소드를 사용하면 됩니다:
101 |
102 | fragment('foo')->render(); ?>
103 |
104 | 위의 예제와 같이 메소드를 사용하면 아래와 같은 형태의 URLs를 만들것입니다:
105 |
106 | http://example.com/something?page=2#foo
107 |
108 |
클릭하여 의견을 공유할 수 있습니다. ( 총 개의 의견이 있습니다. )
109 |
110 |
111 | ## JSON으로 변환하기
112 |
113 | `Paginator` 클래스는 `Illuminate\Contracts\Support\JsonableInterface` contract을 구현하고`toJson` 메소드를 제공합니다. 따라서 라우트로부터 `Paginator` 객체를 JSON으로 변환할 수 있습니다. 변환된 JSON의 형태는 `total`, `current_page`, 그리고 `last_page`와 같은 메타정보를 포함하고 있습니다. 인스턴스의 데이터는 JSON 배열의 `data` 키를 통해 사용할 수 있습니다.
114 |
115 |
클릭하여 의견을 공유할 수 있습니다. ( 총 개의 의견이 있습니다. )
116 |
--------------------------------------------------------------------------------
/gh-pages/docs/readme.md:
--------------------------------------------------------------------------------
1 | ---
2 | layout: default
3 | title: "Laravel Documentation"
4 | permalink: /docs/5.0/readme/
5 | ---
6 |
7 | # Laravel Documentation
8 |
9 | ## Contribution Guidelines
10 |
11 | If you are submitting documentation for the **current stable release**, submit it to the corresponding branch. For example, documentation for Laravel 5.0 would be submitted to the `5.0` branch. Documentation intended for the next release of Laravel should be submitted to the `master` branch.
12 |
--------------------------------------------------------------------------------
/gh-pages/docs/redis.md:
--------------------------------------------------------------------------------
1 | ---
2 | layout: default
3 | title: "레디스(Redis)"
4 | permalink: /docs/5.0/redis/
5 | ---
6 |
7 | # 레디스(Redis)
8 |
9 | - [소개](#introduction)
10 | - [설정](#configuration)
11 | - [사용법](#usage)
12 | - [파이프라이닝](#pipelining)
13 |
14 |
15 | ## 소개
16 |
17 | [레디스](http://redis.io)는 키-밸류 기반의 오픈소스 저장소입니다. 레디스는 키에 [문자열](http://redis.io/topics/data-types#strings), [해쉬](http://redis.io/topics/data-types#hashes), [리스트](http://redis.io/topics/data-types#lists), [세트](http://redis.io/topics/data-types#sets), 그리고 [정렬 세트](http://redis.io/topics/data-types#sorted-sets)를 사용할 수 있으므로 데이터 구조 서버로 자주 거론되고 있습니다.
18 |
19 | 라라벨에서 레디스를 사용하기전에 컴포저로 `predis/predis` 패키지를 설치해주어야 합니다.
20 |
21 | > **주의:** 이미 PECL을 통해서 레디스 PHP 익스텐션을 설치하였다면, `config/app.php`에서 Redis 별칭-alias를 수정해야 합니다.
22 |
23 |
클릭하여 의견을 공유할 수 있습니다. ( 총 개의 의견이 있습니다. )
24 |
25 |
26 | ## 설정
27 |
28 | 어플리케이션에서 사용할 레디스의 설정은 `config/database.php` 파일에서 지정할 수 있습니다. 파일 내부의 `redis` 배열이 어플리케이션에서 사용할 레디스 서버의 설정 정보를 담고 있습니다:
29 |
30 | 'redis' => [
31 |
32 | 'cluster' => true,
33 |
34 | 'default' => ['host' => '127.0.0.1', 'port' => 6379],
35 |
36 | ],
37 |
38 | 기본적으로 설정된 서버는 개발시에는 충분할 수 있습니다. 하지만 환경에 맞게 설정을 변경할 수도 있습니다. 간단하게 레디스 서버의 이름과 그에 맞는 호스트 및 포트번호를 설정하면 됩니다.
39 |
40 | 옵션은 라라벨 레디스 클라이언트에게 레디스 노드에 클라이언트 측 샤딩을 수행 할 수 있도록 하여 노드를 풀링하고 사용 가능한 RAM을 가능한 많이 생성할 수 있도록 합니다. 하지만 클라이언트 샤딩은 페일오버를 처리하지는 않기 때문에 다른 기본 저장소를 위해 사용할 캐시 데이터를 취급하는 데 주로 적합합니다.
41 |
42 | 만약 레디스 서버에 인증이 필요하다면 레디스 서버 설정 배열에 `password` 키/밸류 값을 추가하면 됩니다.
43 |
44 |
클릭하여 의견을 공유할 수 있습니다. ( 총 개의 의견이 있습니다. )
45 |
46 |
47 | ## 사용법
48 |
49 | `Redis::connection` 메소드를 호출하여 레디스 인스턴스를 가져올 수 있습니다:
50 |
51 | $redis = Redis::connection();
52 |
53 | 이 구문은 기본 레디스 서버의 인스턴스를 반환 합니다. 만약 클러스터링을 사용하지 않고 있으면서, 레디스 설정에서 정의되어 있는 특정 서버 인스턴스를 가져오려면 미리 지정된 서버의 이름을 `connection` 메소드에 파라미터로 넘겨주면 됩니다:
54 |
55 | $redis = Redis::connection('other');
56 |
57 | 레디스 클라이언트의 인스턴스를 가져왔다면 이를 통해서 어떤 [레디스 명령어](http://redis.io/commands)라도 실행할 수 있습니다. 라라벨은 매직 메소드를 통해서 레디스 서버에 명령어를 전달합니다:
58 |
59 | $redis->set('name', 'Taylor');
60 |
61 | $name = $redis->get('name');
62 |
63 | $values = $redis->lrange('names', 5, 10);
64 |
65 | 메소드의 매개 변수가 매직 메소드를 통해서 전달된다는 것에 주의 하십시오. 물론 `command` 메소드를 사용하여 명령어를 서버에 직접 전달 할 수도 있습니다:
66 |
67 | $values = $redis->command('lrange', [5, 10]);
68 |
69 | 만약 기본 커넥션을 통해서 명령어를 실행 시키는 것이라면 간단하게 `Redis` 클래스의 스태틱 매직 메소드를 통해서 실행할 수 있습니다:
70 |
71 | Redis::set('name', 'Taylor');
72 |
73 | $name = Redis::get('name');
74 |
75 | $values = Redis::lrange('names', 5, 10);
76 |
77 | > **참고:** 레디스 [캐시](/laravel-korean-docs/docs/5.0/cache)와 [세션](/laravel-korean-docs/docs/5.0/session) 드라이버가 라라벨에 포함되어 있습니다.
78 |
79 |
클릭하여 의견을 공유할 수 있습니다. ( 총 개의 의견이 있습니다. )
80 |
81 |
82 | ## 파이프라이닝
83 |
84 | 파이프라이닝은 다수의 명령어를 한번에 서버로 보내야 할 때 사용되어집니다. `pipeline` 명령어를 통해서 시작할 수 있습니다:
85 |
86 | #### 서버에 다수의 명령어들 파이핑하기
87 |
88 | Redis::pipeline(function($pipe)
89 | {
90 | for ($i = 0; $i < 1000; $i++)
91 | {
92 | $pipe->set("key:$i", $i);
93 | }
94 | });
95 |
96 |
20 |
21 |
22 | ## 루트 디렉토리
23 |
24 | 새롭게 설치한 라라벨의 루트 디렉토리는 다양한 폴더를 가지고 있습니다.
25 |
26 | `app` 디렉토리는 예상하는바와 같이 어플리케이션의 핵심 코드들을 포함하고 있습니다. 더 자세한 내용은 뒤에서 살펴보겠습니다.
27 |
28 | `bootstrap` 폴더는 프레임워크가 부팅하고 오토로딩을 설정하는 몇몇 파일을 가지고 있습니다.
29 |
30 | `config` 디렉토리는 이름에서 알 수 있듯이 어플리케이션의 모든 설정파일을 가지고 있습니다.
31 |
32 | `database` 폴더는 데이터베이스의 마이그레이션과 시드 파일들을 가지고 있습니다.
33 |
34 | `public` 디렉토리는 프론트엔드를 관리하고 assets(image, javascript, CSS, 기타..) 파일들을 가지고 있습니다.
35 |
36 | `resources` 디렉토리는 뷰파일들과 raw assets(LESS, SASS, CoffeeScript) 그리고 “언어” 파일들을 가지고 있습니다.
37 |
38 | `storage` 디렉토리는 컴파일된 블레이드 템플릿, 파일 세션들, 파일 캐시들 그리고 프레임워크에서 생성한 파일들을 포함하고 있습니다.
39 |
40 | `tests` 디렉토리는 자동화된 테스트 파일을 가지고 있습니다.
41 |
42 | `vendor` 디렉토리는 컴포저의 의존성 폴더입니다.
43 |
44 |
클릭하여 의견을 공유할 수 있습니다. ( 총 개의 의견이 있습니다. )
45 |
46 |
47 | ## App 디렉토리
48 |
49 | 어플리케이션의 가장 핵심적인 부분은 `app` 디렉토리에 있습니다. 기본적으로 이 디렉토리의 네임스페이스는 컴포저가 [PSR-4 autoloading standard](http://www.php-fig.org/psr/psr-4/)방식으로 오토로딩될 수 있게 설정된 `App`으로 설정되어 있습니다. ** `app:name` 아티즌 명령어를 통해서 네임스페이스를 변경할 수 있습니다**.
50 |
51 | `app` 디렉토리는 `Console`, `Http` 그리고 `Providers`와 같은 추가적인 디렉토리들을 가지고 있습니다. `Console`과 `Http` 디렉토리는 어플리케이션의 "코어"에 API를 제공한다고 생각합니다. HTTP 프로토콜과 CLI 모두 모두 어플리케이션과 상호 관계 메커니즘이지만, 실제 어플리케이션 로직은 포함하지 않습니다. 다시 말해 어플리케이션에 명령을 지시하는 두 가지 방법이라는 것입니다. `Console` 디렉토리는 모든 아티즌 명령어를 가지고 있으며 `Http` 디렉토리는 컨트롤러, 필터, 그리고 requests-요청들을 가지고 있습니다.
52 |
53 | `Commands` 디렉토리는 당연하게도, 응용 프로그램의 명령어를 모아놓은 곳입니다. 각각의 명령어는 응용 프로그램이 큐에 삽입하는 작업을 나타내는 동시에 현재 요청에 대한 라이프 사이클 동안 수행 할 수있는 작업을 나타냅니다.
54 |
55 | `Events` 디렉토리는 예상할 수 있듯이 이벤트 클래스를 모아놓은 곳입니다. 물론 이벤트를 표현하기 위해서 꼭 클래스를 사용할 필요는 없습니다. 그러나 새로운 이벤트를 사용하기 위해서, 아티즌 명령어를 통해서 생성 된 클래스는 기본적으로 이 디렉토리에 위치합니다.
56 |
57 | `Handlers` 디렉토리는 커맨드와 이벤트들을 처리하는 클래스들을 포함하고 있습니다. 핸들러는 커맨드 또는 이벤트를 받아서 해당 명령 또는 발생한 이벤트에 따라 수행 로직을 실행합니다.
58 |
59 | `Services` 디렉토리는 어플리케이션에서 필요한 다양한 다양한 “헬퍼” 서비스들을 포함하고 있습니다. 예를 들어, 라라벨에 포함된 `Registrar` 서비스는 어플리케이션에 새로운 사용자의 생성과 검증하는 역할을 수행합니다. 다른 예로는 서비스가 외부 API들과 연결하거나, 다른 시스템 또는 어플리케이션에서 필요한 통계 데이터들을 수집하는 역할을 수행할 수 있습니다.
60 |
61 | `Exceptions` 디렉토리는 어플리케이션의 예외 핸들러를 포함하고 있으며, 또한, 응용프로그램에서 발생하는 예외들을 선언해 두기에 적당한 곳입니다.
62 |
63 | > **참고:** `app` 디렉토리 중에 많은 클래스들이 아티즌 명령어에 의해 생성되어 집니다. 사용 가능한 명령어를 확인하려면 터미널에서 `php artisan list make` 명령을 실행하십시오.
64 |
65 |
클릭하여 의견을 공유할 수 있습니다. ( 총 개의 의견이 있습니다. )
66 |
67 |
68 | ## 어플리케이션에 네임스페이스 지정하기
69 |
70 | 앞서 이야기한대로 어플리케이션의 네임스페이스는 기본값으로 `App`으로 지정되어 있습니다. 하지만 이 네임스페이스를 여러분이 고유한 값으로 변경하고자 한다면 `app:name` 아티즌 명령어를 통해서 손쉽게 할 수 있습니다. 예를 들어, 어플리케이션이 “SocialNet”으로 이름을 지정하고자 한다면 다음과 같이 명령어를 실행하면 됩니다:
71 |
72 | php artisan app:name SocialNet
73 |
74 |
50 | @stop
51 |
52 | 블레이드 레이아웃을 `extend`하면 레이아웃의 섹션영역을 재지정하게 됩니다. 자식 뷰에서 부모의 콘텐츠를 포함하려면 `@@ parent` 지시문을 섹션에서 사용하면 됩니다. 주로 사이드 바 또는 하단 글 레이아웃에 내용을 추가할 때 유용합니다.
53 |
54 | 때로는 섹션을 정의해야 할지 정확하게 판단하지 못할 수도 있는데, 이 경우에는 기본값을 `@yield`에 직접 지정할 수도 있습니다. 다음과 같이 두 번째 인자에 기본값을 지정하면 됩니다.
55 |
56 | @yield('section', 'Default Content')
57 |
58 |
클릭하여 의견을 공유할 수 있습니다. ( 총 개의 의견이 있습니다. )
59 |
60 |
61 | ## 기타 블레이드 컨트롤 구조
62 |
63 | #### 데이터 출력하기
64 |
65 | Hello, {% raw %}{{{% endraw %} $name {% raw %}}}{% endraw %}.
66 |
67 | The current UNIX timestamp is {% raw %}{{{% endraw %} time() {% raw %}}}{% endraw %}.
68 |
69 | #### 데이터가 존재하는지 확인후에 출력하기
70 |
71 | 때로는 변수를 출력하고자 할 때 해당 변수가 존재하는지 정확하게 알지 못할 때가 있습니다. 이런경우 여러분은 아마 다음처럼 하기를 원할 것입니다:
72 |
73 | {% raw %}{{{% endraw %} isset($name) ? $name : 'Default' {% raw %}}}{% endraw %}
74 |
75 | 하지만 삼항연산자를 작성하는 대신 블레이드에서는 짧게 축약해서 표현할 수 있습니다:
76 |
77 | {% raw %}{{{% endraw %} $name or 'Default' {% raw %}}}{% endraw %}
78 |
79 | #### 중괄호를 그대로 표시하기
80 |
81 | 중괄호로 둘러싸인 문자열을 그대로 출력 할 필요가 있는 경우에는 `@`를 앞에 붙이는 것으로, Blade의 처리를 무시 할 수 있습니다:
82 |
83 | @{% raw %}{{{% endraw %} This will not be processed by Blade {% raw %}}}{% endraw %}
84 |
85 | 데이터 escape 처리를 하지 않으려면 다음과 같이 작성하면됩니다:
86 |
87 | Hello, {!! $name !!}.
88 |
89 | > ** 주의:** 어플리케이션의 사용자로부터 입력 된 내용을 표시 할 때에는 escape에 대한 주의가 필요합니다. 컨텐츠의 HTML 엔티티를 escape 하기위해 항상 이중 중괄호 표기법을 사용하십시오.
90 |
91 | #### 조건문
92 |
93 | @if (count($records) === 1)
94 | I have one record!
95 | @elseif (count($records) > 1)
96 | I have multiple records!
97 | @else
98 | I don't have any records!
99 | @endif
100 |
101 | @unless (Auth::check())
102 | You are not signed in.
103 | @endunless
104 |
105 | #### 반복
106 |
107 | @for ($i = 0; $i < 10; $i++)
108 | The current value is {% raw %}{{{% endraw %} $i {% raw %}}}{% endraw %}
109 | @endfor
110 |
111 | @foreach ($users as $user)
112 |
This is user {% raw %}{{{% endraw %} $user->id {% raw %}}}{% endraw %}
{% raw %}{{{% endraw %} $user->name {% raw %}}}{% endraw %}
117 | @empty
118 |
No users
119 | @endforelse
120 |
121 | @while (true)
122 |
I'm looping forever.
123 | @endwhile
124 |
125 | #### 하위 뷰 포함하기
126 |
127 | @include('view.name')
128 |
129 | 포함하게될 하위 뷰에 데이터 배열을 전달할 수 있습니다:
130 |
131 | @include('view.name', ['some' => 'data'])
132 |
133 | #### 섹션 재정의하기
134 |
135 | 섹션 전체를 다시 재정의하려면 `overwrite` 문을 사용하십시오:
136 |
137 | @extends('list.item.container')
138 |
139 | @section('list.item.content')
140 |
This is an item of type {% raw %}{{{% endraw %} $item->type {% raw %}}}{% endraw %}
141 | @overwrite
142 |
143 | #### 다국어에 대응 된 행 표시
144 |
145 | @lang('language.line')
146 |
147 | @choice('language.line', 1)
148 |
149 | #### 주석
150 |
151 | {% raw %}{{{% endraw %}-- This comment will not be in the rendered HTML --{% raw %}}}{% endraw %}
152 |
153 |
라라벨은 PHP 에서 사용할 수 있는 가장 모던하고 세련된 프레임워크이며, 유연하고 세련된 기능을 제공합니다. 라라벨은 php개발이 즐겁고 좀더 창의적일 수 있도록 하기 위해서 만들어졌습니다. 라라벨을 사용하면 php로 진행하는 웹개발에서 필요한 사용자 인증, 라우팅, 세션, Job 큐, 캐싱과 같은 작업들을 보다 손쉽게 구성할 수 있습니다.
15 |
16 |
라라벨은 개발자가 비지니스 로직을 구현하는데 보다 집중할 수 있도록 하는 목표를 가지고 태어났으며, 루비온 레일즈, ASP.NET MVC, 그리고 Sinatra에게서 영감을 받았습니다.
45 |
46 | render(); ?>
47 |
48 | 지금까지 보신것들이 페이징 시스템에 필요한 전부입니다! 복잡하게 현재 페이지를 프레임워크에게 알릴 필요가 없다는 것을 기억하세요. 라라벨은 현재 페이지를 자동으로 결정할 것입니다.
49 |
50 | 아래의 메소드들로 추가적인 페이징 관련 정보들을 가져올 수 있습니다:
51 |
52 | - `currentPage`
53 | - `lastPage`
54 | - `perPage`
55 | - `hasMorePages`
56 | - `firstItem`
57 | - `lastItem`
58 | - `url`
59 | - `nextPageUrl`
60 | - `firstItem`
61 | - `lastItem`
62 | - `total`
63 | - `count`
64 |
65 | #### “간단한 Pagination"
66 |
67 | 만약 페이지 번호 없이 “다음”과 “이전” 링크 만을 pagination view에서 보여준다면, 더 효율적으로 쿼리를 수행하는 옵션인`simplePaginate` 메소드를 사용할 수 있습니다:
68 |
69 | $someUsers = User::where('votes', '>', 100)->simplePaginate(15);
70 |
71 | #### Paginator URI 커스터마이징
72 |
73 | paginator에서 제공하는 `setPath` 메소드를 통해 URI를 변경 할 수 있습니다:
74 |
75 | $users = User::paginate();
76 |
77 | $users->setPath('custom/url');
78 |
79 | 위의 예제는 다음과 같은 URLs를 만듭니다: http://example.com/custom/url?page=2
80 |
81 |
82 |
83 |
84 | ## 페이지 링크에 추가하기
85 |
86 | Paginator의 `appends` 메소드를 사용하면 페이지 링크에 쿼리 스트링을 추가할 수 있습니다:
87 |
88 | appends(['sort' => 'votes'])->render(); ?>
89 |
90 | 위의 예제는 아래와 같은 형태의 URLs를 만들것입니다:
91 |
92 | http://example.com/something?page=2&sort=votes
93 |
94 | 만약 “hash fragment”를 페이지 번호의 링크에 추가하고 싶다면 `fragment` 메소드를 사용하면 됩니다:
95 |
96 | fragment('foo')->render(); ?>
97 |
98 | 위의 예제와 같이 메소드를 사용하면 아래와 같은 형태의 URLs를 만들것입니다:
99 |
100 | http://example.com/something?page=2#foo
101 |
102 |
103 |
104 |
105 | ## JSON으로 변환하기
106 |
107 | `Paginator` 클래스는 `Illuminate\Contracts\Support\JsonableInterface` contract을 구현하고`toJson` 메소드를 제공합니다. 따라서 라우트로부터 `Paginator` 객체를 JSON으로 변환할 수 있습니다. 변환된 JSON의 형태는 `total`, `current_page`, 그리고 `last_page`와 같은 메타정보를 포함하고 있습니다. 인스턴스의 데이터는 JSON 배열의 `data` 키를 통해 사용할 수 있습니다.
108 |
109 |
110 |
--------------------------------------------------------------------------------
/kr/readme.md:
--------------------------------------------------------------------------------
1 | # Laravel Documentation
2 |
3 | ## Contribution Guidelines
4 |
5 | If you are submitting documentation for the **current stable release**, submit it to the corresponding branch. For example, documentation for Laravel 5.0 would be submitted to the `5.0` branch. Documentation intended for the next release of Laravel should be submitted to the `master` branch.
6 |
--------------------------------------------------------------------------------
/kr/redis.md:
--------------------------------------------------------------------------------
1 | # 레디스(Redis)
2 |
3 | - [소개](#introduction)
4 | - [설정](#configuration)
5 | - [사용법](#usage)
6 | - [파이프라이닝](#pipelining)
7 |
8 |
9 | ## 소개
10 |
11 | [레디스](http://redis.io)는 키-밸류 기반의 오픈소스 저장소입니다. 레디스는 키에 [문자열](http://redis.io/topics/data-types#strings), [해쉬](http://redis.io/topics/data-types#hashes), [리스트](http://redis.io/topics/data-types#lists), [세트](http://redis.io/topics/data-types#sets), 그리고 [정렬 세트](http://redis.io/topics/data-types#sorted-sets)를 사용할 수 있으므로 데이터 구조 서버로 자주 거론되고 있습니다.
12 |
13 | 라라벨에서 레디스를 사용하기전에 컴포저로 `predis/predis` 패키지를 설치해주어야 합니다.
14 |
15 | > **주의:** 이미 PECL을 통해서 레디스 PHP 익스텐션을 설치하였다면, `config/app.php`에서 Redis 별칭-alias를 수정해야 합니다.
16 |
17 |
18 |
19 |
20 | ## 설정
21 |
22 | 어플리케이션에서 사용할 레디스의 설정은 `config/database.php` 파일에서 지정할 수 있습니다. 파일 내부의 `redis` 배열이 어플리케이션에서 사용할 레디스 서버의 설정 정보를 담고 있습니다:
23 |
24 | 'redis' => [
25 |
26 | 'cluster' => true,
27 |
28 | 'default' => ['host' => '127.0.0.1', 'port' => 6379],
29 |
30 | ],
31 |
32 | 기본적으로 설정된 서버는 개발시에는 충분할 수 있습니다. 하지만 환경에 맞게 설정을 변경할 수도 있습니다. 간단하게 레디스 서버의 이름과 그에 맞는 호스트 및 포트번호를 설정하면 됩니다.
33 |
34 | 옵션은 라라벨 레디스 클라이언트에게 레디스 노드에 클라이언트 측 샤딩을 수행 할 수 있도록 하여 노드를 풀링하고 사용 가능한 RAM을 가능한 많이 생성할 수 있도록 합니다. 하지만 클라이언트 샤딩은 페일오버를 처리하지는 않기 때문에 다른 기본 저장소를 위해 사용할 캐시 데이터를 취급하는 데 주로 적합합니다.
35 |
36 | 만약 레디스 서버에 인증이 필요하다면 레디스 서버 설정 배열에 `password` 키/밸류 값을 추가하면 됩니다.
37 |
38 |
39 |
40 |
41 | ## 사용법
42 |
43 | `Redis::connection` 메소드를 호출하여 레디스 인스턴스를 가져올 수 있습니다:
44 |
45 | $redis = Redis::connection();
46 |
47 | 이 구문은 기본 레디스 서버의 인스턴스를 반환 합니다. 만약 클러스터링을 사용하지 않고 있으면서, 레디스 설정에서 정의되어 있는 특정 서버 인스턴스를 가져오려면 미리 지정된 서버의 이름을 `connection` 메소드에 파라미터로 넘겨주면 됩니다:
48 |
49 | $redis = Redis::connection('other');
50 |
51 | 레디스 클라이언트의 인스턴스를 가져왔다면 이를 통해서 어떤 [레디스 명령어](http://redis.io/commands)라도 실행할 수 있습니다. 라라벨은 매직 메소드를 통해서 레디스 서버에 명령어를 전달합니다:
52 |
53 | $redis->set('name', 'Taylor');
54 |
55 | $name = $redis->get('name');
56 |
57 | $values = $redis->lrange('names', 5, 10);
58 |
59 | 메소드의 매개 변수가 매직 메소드를 통해서 전달된다는 것에 주의 하십시오. 물론 `command` 메소드를 사용하여 명령어를 서버에 직접 전달 할 수도 있습니다:
60 |
61 | $values = $redis->command('lrange', [5, 10]);
62 |
63 | 만약 기본 커넥션을 통해서 명령어를 실행 시키는 것이라면 간단하게 `Redis` 클래스의 스태틱 매직 메소드를 통해서 실행할 수 있습니다:
64 |
65 | Redis::set('name', 'Taylor');
66 |
67 | $name = Redis::get('name');
68 |
69 | $values = Redis::lrange('names', 5, 10);
70 |
71 | > **참고:** 레디스 [캐시](/docs/5.0/cache)와 [세션](/docs/5.0/session) 드라이버가 라라벨에 포함되어 있습니다.
72 |
73 |
74 |
75 |
76 | ## 파이프라이닝
77 |
78 | 파이프라이닝은 다수의 명령어를 한번에 서버로 보내야 할 때 사용되어집니다. `pipeline` 명령어를 통해서 시작할 수 있습니다:
79 |
80 | #### 서버에 다수의 명령어들 파이핑하기
81 |
82 | Redis::pipeline(function($pipe)
83 | {
84 | for ($i = 0; $i < 1000; $i++)
85 | {
86 | $pipe->set("key:$i", $i);
87 | }
88 | });
89 |
90 |
91 |
--------------------------------------------------------------------------------
/kr/session.md:
--------------------------------------------------------------------------------
1 | # 세션(Session)
2 |
3 | - [설정](#configuration)
4 | - [세션 사용법](#session-usage)
5 | - [임시 데이터](#flash-data)
6 | - [데이터베이스 세션](#database-sessions)
7 | - [세션 드라이버](#session-drivers)
8 |
9 |
10 | ## 설정
11 |
12 | HTTP 기반의 어플리케이션은 상태를 저장할수 없기 때문에, HTTP 요청들에 관계없이 사용자의 정보를 저장하기위해서 세션이 사용됩니다. 라라벨은 다양한 벡엔드 세션들에 관계없이 간결하고 통일된 API를 제공합니다. 많이 알려진 [Memcached](http://memcached.org), [Redis](http://redis.io) 그리고 데이터베이스를 별다른 설정 없이 세션 시스템으로 사용할 수 있습니다.
13 |
14 | 세션의 설정은 `config/session.php` 파일에 있습니다. 이 파일에는 각각의 옵션에 대한 정리된 문서가 포함되어 있으므로 잘 확인하시기 바랍니다. 대부분의 어플리케이션에서 작동이 가능하도록 기본적으로 라라벨은 `file` 세션 드라이버를 사용합니다.
15 |
16 | 라라벨에서 Redis 세션을 사용하기 위해서는 컴포저를 통해서 `predis/predis (~1.0)` 패키지를 설치해야만 합니다.
17 |
18 | > **참고:** 세션을 암호화하여 저장하고자 한다면 `encrypt` 설정 옵션을 `true`로 지정하십시오.
19 |
20 | > **주의** `cookie` 세션 드라이버를 사용할 때에는 HTTP 커널에서 **절대로** `EncryptCookie` 미들웨어를 제거해서는 안됩니다. 이 미들웨어를 제거하게 되면, 어플리케이션이 원격으로부터 코드를 실행하는 취약점이 존재합니다.
21 |
22 | #### 예약어
23 |
24 | 라라벨 프레임워크는 내부적으로 `flash`라는 세션키를 사용하고 있으므로 이 이름으로 세션을 추가하지 말아야 합니다.
25 |
26 |
27 |
28 |
29 | ## 세션 사용법
30 |
31 | 세션에 엑세스하기 위해서는 여러 가지 방법이 있습니다. HTTP 요청-request의 `session` 메소드를 사용하는 방법, `Session` 파사드를 사용하는 방법, 그리고 `session` 헬퍼함수를 사용할 수 있습니다. 아무런 전달 인자 없이 `session` 헬퍼함수를 호출할 때에는 전체 세션 객체가 반환됩니다. 예를 들어:
32 |
33 | session()->regenerate();
34 |
35 | #### 아이템 세션에 저장하기
36 |
37 | Session::put('key', 'value');
38 |
39 | session(['key' => 'value']);
40 |
41 | #### 배열 세션값으로 저장하기
42 |
43 | Session::push('user.teams', 'developers');
44 |
45 | #### 세션에서 특정 아이템 가져오기
46 |
47 | $value = Session::get('key');
48 |
49 | $value = session('key');
50 |
51 | #### 특정 아이템을 찾거나 기본값 반환받기
52 |
53 | $value = Session::get('key', 'default');
54 |
55 | $value = Session::get('key', function() { return 'default'; });
56 |
57 | #### 아이템 값 가져온 후 삭제하기
58 |
59 | $value = Session::pull('key', 'default');
60 |
61 | #### 세션의 모든 데이터 가져오기
62 |
63 | $data = Session::all();
64 |
65 | #### 세션에 아이템이 존재하는지 확인하기
66 |
67 | if (Session::has('users'))
68 | {
69 | //
70 | }
71 |
72 | #### 세션에서 특정 아이템 삭제하기
73 |
74 | Session::forget('key');
75 |
76 | #### 세션의 모든 아이템 삭제하기
77 |
78 | Session::flush();
79 |
80 | #### 세션 ID 재생성하기
81 |
82 | Session::regenerate();
83 |
84 |
85 |
86 |
87 | ## 임시 데이터
88 |
89 | 때로는 바로 다음번의 요청에서만 사용하기 위해서 세션에 아이템을 저장할 수 있습니다. 바로 `Session::flash` 메소드를 사용하는 것입니다:
90 |
91 | Session::flash('key', 'value');
92 |
93 | #### 현재의 임시 데이터를 다른 요청에서 사용하기 위해서 다시 임시 저장하기
94 |
95 | Session::reflash();
96 |
97 | #### 임시 데이터의 일부 값만 다시 임시 저장하기
98 |
99 | Session::keep(['username', 'email']);
100 |
101 |
102 |
103 |
104 | ## 데이터베이스 세션
105 |
106 | `database` 세션 드라이버를 사용하는 경우 세션 아이템들이 저장될 테이블을 생성해야 합니다. 다음의 `Schema` 예제를 통해서 테이블을 생성할 수 있습니다.
107 |
108 | Schema::create('sessions', function($table)
109 | {
110 | $table->string('id')->unique();
111 | $table->text('payload');
112 | $table->integer('last_activity');
113 | });
114 |
115 | 물론, `session:table` 아티즌 명령어를 통해서 이 마이그레이션을 생성할 수 있습니다!
116 |
117 | php artisan session:table
118 |
119 | composer dump-autoload
120 |
121 | php artisan migrate
122 |
123 |
124 |
125 |
126 | ## 세션 드라이버
127 |
128 | 세션 “드라이버”는 각각의 요청에 따라 세션이 어디에 저장될지를 결정합니다. 라라벨은 별다른 설정 없이 다양한 드라이버를 사용할 수 있습니다:
129 |
130 | - `file` - 세션이 `storage/framework/sessions` 폴더에 저장됩니다.
131 | - `cookie` - 암호화된 쿠키를 사용하여 안전하게 세션을 저장할 것입니다.
132 | - `database` - 세션은 어플리케이션에 의해서 데이터베이스에 저장됩니다.
133 | - `memcached` / `redis` - 세션은 캐시 기반의 드라이버들에 의해 빠르게 저장됩니다.
134 | - `array` - 세션은 간단한 PHP 배열에 저장되지만 요청들간에 지속되지 않습니다.
135 |
136 | > **주의:** 배열 드라이버의 경우에는 실제로 세션은 유지되지 않기 때문에 [unit tests](/docs/5.0/testing)를 수행하는 데에만 사용하시기 바랍니다.
137 |
138 |
139 |
--------------------------------------------------------------------------------
/kr/structure.md:
--------------------------------------------------------------------------------
1 | # 어플리케이션 구조(Application Structure)
2 |
3 | - [소개](#introduction)
4 | - [루트 디렉토리](#the-root-directory)
5 | - [App 디렉토리](#the-app-directory)
6 | - [어플리케이션에 네임스페이스 지정하기](#namespacing-your-application)
7 |
8 |
9 | ## 소개
10 |
11 | 기본적인 라라벨 어플리케이션의 구조는 어플리케이션이 크건, 작건 좋은 시작점이 되는것을 의도하고 있습니다. 당연히 어플리케이션을 원하는대로 구성해도 됩니다. 컴포저가 클래스를 오토로딩할 수 있는 한 클래스를 어디에 위치시키는가에 대한 제약사항은 없습니다.
12 |
13 |
14 |
15 |
16 | ## 루트 디렉토리
17 |
18 | 새롭게 설치한 라라벨의 루트 디렉토리는 다양한 폴더를 가지고 있습니다.
19 |
20 | `app` 디렉토리는 예상하는바와 같이 어플리케이션의 핵심 코드들을 포함하고 있습니다. 더 자세한 내용은 뒤에서 살펴보겠습니다.
21 |
22 | `bootstrap` 폴더는 프레임워크가 부팅하고 오토로딩을 설정하는 몇몇 파일을 가지고 있습니다.
23 |
24 | `config` 디렉토리는 이름에서 알 수 있듯이 어플리케이션의 모든 설정파일을 가지고 있습니다.
25 |
26 | `database` 폴더는 데이터베이스의 마이그레이션과 시드 파일들을 가지고 있습니다.
27 |
28 | `public` 디렉토리는 프론트엔드를 관리하고 assets(image, javascript, CSS, 기타..) 파일들을 가지고 있습니다.
29 |
30 | `resources` 디렉토리는 뷰파일들과 raw assets(LESS, SASS, CoffeeScript) 그리고 “언어” 파일들을 가지고 있습니다.
31 |
32 | `storage` 디렉토리는 컴파일된 블레이드 템플릿, 파일 세션들, 파일 캐시들 그리고 프레임워크에서 생성한 파일들을 포함하고 있습니다.
33 |
34 | `tests` 디렉토리는 자동화된 테스트 파일을 가지고 있습니다.
35 |
36 | `vendor` 디렉토리는 컴포저의 의존성 폴더입니다.
37 |
38 |
39 |
40 |
41 | ## App 디렉토리
42 |
43 | 어플리케이션의 가장 핵심적인 부분은 `app` 디렉토리에 있습니다. 기본적으로 이 디렉토리의 네임스페이스는 컴포저가 [PSR-4 autoloading standard](http://www.php-fig.org/psr/psr-4/)방식으로 오토로딩될 수 있게 설정된 `App`으로 설정되어 있습니다. ** `app:name` 아티즌 명령어를 통해서 네임스페이스를 변경할 수 있습니다**.
44 |
45 | `app` 디렉토리는 `Console`, `Http` 그리고 `Providers`와 같은 추가적인 디렉토리들을 가지고 있습니다. `Console`과 `Http` 디렉토리는 어플리케이션의 "코어"에 API를 제공한다고 생각합니다. HTTP 프로토콜과 CLI 모두 모두 어플리케이션과 상호 관계 메커니즘이지만, 실제 어플리케이션 로직은 포함하지 않습니다. 다시 말해 어플리케이션에 명령을 지시하는 두 가지 방법이라는 것입니다. `Console` 디렉토리는 모든 아티즌 명령어를 가지고 있으며 `Http` 디렉토리는 컨트롤러, 필터, 그리고 requests-요청들을 가지고 있습니다.
46 |
47 | `Commands` 디렉토리는 당연하게도, 응용 프로그램의 명령어를 모아놓은 곳입니다. 각각의 명령어는 응용 프로그램이 큐에 삽입하는 작업을 나타내는 동시에 현재 요청에 대한 라이프 사이클 동안 수행 할 수있는 작업을 나타냅니다.
48 |
49 | `Events` 디렉토리는 예상할 수 있듯이 이벤트 클래스를 모아놓은 곳입니다. 물론 이벤트를 표현하기 위해서 꼭 클래스를 사용할 필요는 없습니다. 그러나 새로운 이벤트를 사용하기 위해서, 아티즌 명령어를 통해서 생성 된 클래스는 기본적으로 이 디렉토리에 위치합니다.
50 |
51 | `Handlers` 디렉토리는 커맨드와 이벤트들을 처리하는 클래스들을 포함하고 있습니다. 핸들러는 커맨드 또는 이벤트를 받아서 해당 명령 또는 발생한 이벤트에 따라 수행 로직을 실행합니다.
52 |
53 | `Services` 디렉토리는 어플리케이션에서 필요한 다양한 다양한 “헬퍼” 서비스들을 포함하고 있습니다. 예를 들어, 라라벨에 포함된 `Registrar` 서비스는 어플리케이션에 새로운 사용자의 생성과 검증하는 역할을 수행합니다. 다른 예로는 서비스가 외부 API들과 연결하거나, 다른 시스템 또는 어플리케이션에서 필요한 통계 데이터들을 수집하는 역할을 수행할 수 있습니다.
54 |
55 | `Exceptions` 디렉토리는 어플리케이션의 예외 핸들러를 포함하고 있으며, 또한, 응용프로그램에서 발생하는 예외들을 선언해 두기에 적당한 곳입니다.
56 |
57 | > **참고:** `app` 디렉토리 중에 많은 클래스들이 아티즌 명령어에 의해 생성되어 집니다. 사용 가능한 명령어를 확인하려면 터미널에서 `php artisan list make` 명령을 실행하십시오.
58 |
59 |
60 |
61 |
62 | ## 어플리케이션에 네임스페이스 지정하기
63 |
64 | 앞서 이야기한대로 어플리케이션의 네임스페이스는 기본값으로 `App`으로 지정되어 있습니다. 하지만 이 네임스페이스를 여러분이 고유한 값으로 변경하고자 한다면 `app:name` 아티즌 명령어를 통해서 손쉽게 할 수 있습니다. 예를 들어, 어플리케이션이 “SocialNet”으로 이름을 지정하고자 한다면 다음과 같이 명령어를 실행하면 됩니다:
65 |
66 | php artisan app:name SocialNet
67 |
68 |
69 |
--------------------------------------------------------------------------------
/kr/templates.md:
--------------------------------------------------------------------------------
1 | # 템플릿(Templates)
2 |
3 | - [블레이드 템플릿](#blade-templating)
4 | - [기타 블레이드 컨트롤 구조](#other-blade-control-structures)
5 |
6 |
7 | ## 블레이드 템플릿
8 |
9 | 블레이드는 라라벨에서 제공하는 간단하지만 강력한 템플릿 엔진입니다. 컨트롤러 레이아웃과는 다르게 블레이드는 _템플릿 상속_과 _섹션_을 통해서 처리됩니다. 모든 블레이드 템플릿 파일은 `.blade.php` 확장자를 가져야 합니다.
10 |
11 | #### 블레이드 레이아웃 정의하기
12 |
13 |
14 |
15 |
16 |
17 | App Name - @yield('title')
18 |
19 |
20 | @section('sidebar')
21 | This is the master sidebar.
22 | @show
23 |
24 |
44 | @stop
45 |
46 | 블레이드 레이아웃을 `extend`하면 레이아웃의 섹션영역을 재지정하게 됩니다. 자식 뷰에서 부모의 콘텐츠를 포함하려면 `@@ parent` 지시문을 섹션에서 사용하면 됩니다. 주로 사이드 바 또는 하단 글 레이아웃에 내용을 추가할 때 유용합니다.
47 |
48 | 때로는 섹션을 정의해야 할지 정확하게 판단하지 못할 수도 있는데, 이 경우에는 기본값을 `@yield`에 직접 지정할 수도 있습니다. 다음과 같이 두 번째 인자에 기본값을 지정하면 됩니다.
49 |
50 | @yield('section', 'Default Content')
51 |
52 |
53 |
54 |
55 | ## 기타 블레이드 컨트롤 구조
56 |
57 | #### 데이터 출력하기
58 |
59 | Hello, {{ $name }}.
60 |
61 | The current UNIX timestamp is {{ time() }}.
62 |
63 | #### 데이터가 존재하는지 확인후에 출력하기
64 |
65 | 때로는 변수를 출력하고자 할 때 해당 변수가 존재하는지 정확하게 알지 못할 때가 있습니다. 이런경우 여러분은 아마 다음처럼 하기를 원할 것입니다:
66 |
67 | {{ isset($name) ? $name : 'Default' }}
68 |
69 | 하지만 삼항연산자를 작성하는 대신 블레이드에서는 짧게 축약해서 표현할 수 있습니다:
70 |
71 | {{ $name or 'Default' }}
72 |
73 | #### 중괄호를 그대로 표시하기
74 |
75 | 중괄호로 둘러싸인 문자열을 그대로 출력 할 필요가 있는 경우에는 `@`를 앞에 붙이는 것으로, Blade의 처리를 무시 할 수 있습니다:
76 |
77 | @{{ This will not be processed by Blade }}
78 |
79 | 데이터 escape 처리를 하지 않으려면 다음과 같이 작성하면됩니다:
80 |
81 | Hello, {!! $name !!}.
82 |
83 | > ** 주의:** 어플리케이션의 사용자로부터 입력 된 내용을 표시 할 때에는 escape에 대한 주의가 필요합니다. 컨텐츠의 HTML 엔티티를 escape 하기위해 항상 이중 중괄호 표기법을 사용하십시오.
84 |
85 | #### 조건문
86 |
87 | @if (count($records) === 1)
88 | I have one record!
89 | @elseif (count($records) > 1)
90 | I have multiple records!
91 | @else
92 | I don't have any records!
93 | @endif
94 |
95 | @unless (Auth::check())
96 | You are not signed in.
97 | @endunless
98 |
99 | #### 반복
100 |
101 | @for ($i = 0; $i < 10; $i++)
102 | The current value is {{ $i }}
103 | @endfor
104 |
105 | @foreach ($users as $user)
106 |
43 |
44 | render(); ?>
45 |
46 | This is all it takes to create a pagination system! Note that we did not have to inform the framework of the current page. Laravel will determine this for you automatically.
47 |
48 | You may also access additional pagination information via the following methods:
49 |
50 | - `currentPage`
51 | - `lastPage`
52 | - `perPage`
53 | - `hasMorePages`
54 | - `url`
55 | - `nextPageUrl`
56 | - `firstItem`
57 | - `lastItem`
58 | - `total`
59 | - `count`
60 |
61 | #### "Simple Pagination"
62 |
63 | If you are only showing "Next" and "Previous" links in your pagination view, you have the option of using the `simplePaginate` method to perform a more efficient query. This is useful for larger datasets when you do not require the display of exact page numbers on your view:
64 |
65 | $someUsers = User::where('votes', '>', 100)->simplePaginate(15);
66 |
67 | #### Customizing The Paginator URI
68 |
69 | You may also customize the URI used by the paginator via the `setPath` method:
70 |
71 | $users = User::paginate();
72 |
73 | $users->setPath('custom/url');
74 |
75 | The example above will create URLs like the following: http://example.com/custom/url?page=2
76 |
77 |
78 | ## Appending To Pagination Links
79 |
80 | You can add to the query string of pagination links using the `appends` method on the Paginator:
81 |
82 | appends(['sort' => 'votes'])->render(); ?>
83 |
84 | This will generate URLs that look something like this:
85 |
86 | http://example.com/something?page=2&sort=votes
87 |
88 | If you wish to append a "hash fragment" to the paginator's URLs, you may use the `fragment` method:
89 |
90 | fragment('foo')->render(); ?>
91 |
92 | This method call will generate URLs that look something like this:
93 |
94 | http://example.com/something?page=2#foo
95 |
96 |
97 | ## Converting To JSON
98 |
99 | The `Paginator` class implements the `Illuminate\Contracts\Support\JsonableInterface` contract and exposes the `toJson` method. You may also convert a `Paginator` instance to JSON by returning it from a route. The JSON'd form of the instance will include some "meta" information such as `total`, `current_page`, and `last_page`. The instance's data will be available via the `data` key in the JSON array.
100 |
--------------------------------------------------------------------------------
/readme.md:
--------------------------------------------------------------------------------
1 | # Laravel Documentation
2 |
3 | ## Contribution Guidelines
4 |
5 | If you are submitting documentation for the **current stable release**, submit it to the corresponding branch. For example, documentation for Laravel 5.0 would be submitted to the `5.0` branch. Documentation intended for the next release of Laravel should be submitted to the `master` branch.
6 |
--------------------------------------------------------------------------------
/redis.md:
--------------------------------------------------------------------------------
1 | # Redis
2 |
3 | - [Introduction](#introduction)
4 | - [Configuration](#configuration)
5 | - [Usage](#usage)
6 | - [Pipelining](#pipelining)
7 |
8 |
9 | ## Introduction
10 |
11 | [Redis](http://redis.io) is an open source, advanced key-value store. It is often referred to as a data structure server since keys can contain [strings](http://redis.io/topics/data-types#strings), [hashes](http://redis.io/topics/data-types#hashes), [lists](http://redis.io/topics/data-types#lists), [sets](http://redis.io/topics/data-types#sets), and [sorted sets](http://redis.io/topics/data-types#sorted-sets).
12 |
13 | Before using Redis with Laravel, you will need to install the `predis/predis` package (~1.0) via Composer.
14 |
15 | > **Note:** If you have the Redis PHP extension installed via PECL, you will need to rename the alias for Redis in your `config/app.php` file.
16 |
17 |
18 | ## Configuration
19 |
20 | The Redis configuration for your application is stored in the `config/database.php` file. Within this file, you will see a `redis` array containing the Redis servers used by your application:
21 |
22 | 'redis' => [
23 |
24 | 'cluster' => true,
25 |
26 | 'default' => ['host' => '127.0.0.1', 'port' => 6379],
27 |
28 | ],
29 |
30 | The default server configuration should suffice for development. However, you are free to modify this array based on your environment. Simply give each Redis server a name, and specify the host and port used by the server.
31 |
32 | The `cluster` option will tell the Laravel Redis client to perform client-side sharding across your Redis nodes, allowing you to pool nodes and create a large amount of available RAM. However, note that client-side sharding does not handle failover; therefore, is primarily suited for cached data that is available from another primary data store.
33 |
34 | If your Redis server requires authentication, you may supply a password by adding a `password` key / value pair to your Redis server configuration array.
35 |
36 |
37 | ## Usage
38 |
39 | You may get a Redis instance by calling the `Redis::connection` method:
40 |
41 | $redis = Redis::connection();
42 |
43 | This will give you an instance of the default Redis server. If you are not using server clustering, you may pass the server name to the `connection` method to get a specific server as defined in your Redis configuration:
44 |
45 | $redis = Redis::connection('other');
46 |
47 | Once you have an instance of the Redis client, we may issue any of the [Redis commands](http://redis.io/commands) to the instance. Laravel uses magic methods to pass the commands to the Redis server:
48 |
49 | $redis->set('name', 'Taylor');
50 |
51 | $name = $redis->get('name');
52 |
53 | $values = $redis->lrange('names', 5, 10);
54 |
55 | Notice the arguments to the command are simply passed into the magic method. Of course, you are not required to use the magic methods, you may also pass commands to the server using the `command` method:
56 |
57 | $values = $redis->command('lrange', [5, 10]);
58 |
59 | When you are simply executing commands against the default connection, just use static magic methods on the `Redis` class:
60 |
61 | Redis::set('name', 'Taylor');
62 |
63 | $name = Redis::get('name');
64 |
65 | $values = Redis::lrange('names', 5, 10);
66 |
67 | > **Note:** Redis [cache](/docs/{{version}}/cache) and [session](/docs/{{version}}/session) drivers are included with Laravel.
68 |
69 |
70 | ## Pipelining
71 |
72 | Pipelining should be used when you need to send many commands to the server in one operation. To get started, use the `pipeline` command:
73 |
74 | #### Piping Many Commands To Your Servers
75 |
76 | Redis::pipeline(function($pipe)
77 | {
78 | for ($i = 0; $i < 1000; $i++)
79 | {
80 | $pipe->set("key:$i", $i);
81 | }
82 | });
83 |
--------------------------------------------------------------------------------
/session.md:
--------------------------------------------------------------------------------
1 | # Session
2 |
3 | - [Configuration](#configuration)
4 | - [Session Usage](#session-usage)
5 | - [Flash Data](#flash-data)
6 | - [Database Sessions](#database-sessions)
7 | - [Session Drivers](#session-drivers)
8 |
9 |
10 | ## Configuration
11 |
12 | Since HTTP driven applications are stateless, sessions provide a way to store information about the user across requests. Laravel ships with a variety of session back-ends available for use through a clean, unified API. Support for popular back-ends such as [Memcached](http://memcached.org), [Redis](http://redis.io), and databases is included out of the box.
13 |
14 | The session configuration is stored in `config/session.php`. Be sure to review the well documented options available to you in this file. By default, Laravel is configured to use the `file` session driver, which will work well for the majority of applications.
15 |
16 | Before using Redis sessions with Laravel, you will need to install the `predis/predis` package (~1.0) via Composer.
17 |
18 | > **Note:** If you need all stored session data to be encrypted, set the `encrypt` configuration option to `true`.
19 |
20 | > **Note:** When using the `cookie` session driver, you should **never** remove the `EncryptCookie` middleware from your HTTP kernel. If you remove this middleware, your application will be vulnerable to remote code injection.
21 |
22 | #### Reserved Keys
23 |
24 | The Laravel framework uses the `flash` session key internally, so you should not add an item to the session by that name.
25 |
26 |
27 | ## Session Usage
28 |
29 | The session may be accessed in several ways, via the HTTP request's `session` method, the `Session` facade, or the `session` helper function. When the `session` helper is called without arguments, it will return the entire session object. For example:
30 |
31 | session()->regenerate();
32 |
33 | #### Storing An Item In The Session
34 |
35 | Session::put('key', 'value');
36 |
37 | session(['key' => 'value']);
38 |
39 | #### Push A Value Onto An Array Session Value
40 |
41 | Session::push('user.teams', 'developers');
42 |
43 | #### Retrieving An Item From The Session
44 |
45 | $value = Session::get('key');
46 |
47 | $value = session('key');
48 |
49 | #### Retrieving An Item Or Returning A Default Value
50 |
51 | $value = Session::get('key', 'default');
52 |
53 | $value = Session::get('key', function() { return 'default'; });
54 |
55 | #### Retrieving An Item And Forgetting It
56 |
57 | $value = Session::pull('key', 'default');
58 |
59 | #### Retrieving All Data From The Session
60 |
61 | $data = Session::all();
62 |
63 | #### Determining If An Item Exists In The Session
64 |
65 | if (Session::has('users'))
66 | {
67 | //
68 | }
69 |
70 | #### Removing An Item From The Session
71 |
72 | Session::forget('key');
73 |
74 | #### Removing All Items From The Session
75 |
76 | Session::flush();
77 |
78 | #### Regenerating The Session ID
79 |
80 | Session::regenerate();
81 |
82 |
83 | ## Flash Data
84 |
85 | Sometimes you may wish to store items in the session only for the next request. You may do so using the `Session::flash` method:
86 |
87 | Session::flash('key', 'value');
88 |
89 | #### Reflashing The Current Flash Data For Another Request
90 |
91 | Session::reflash();
92 |
93 | #### Reflashing Only A Subset Of Flash Data
94 |
95 | Session::keep(['username', 'email']);
96 |
97 |
98 | ## Database Sessions
99 |
100 | When using the `database` session driver, you will need to setup a table to contain the session items. Below is an example `Schema` declaration for the table:
101 |
102 | Schema::create('sessions', function($table)
103 | {
104 | $table->string('id')->unique();
105 | $table->text('payload');
106 | $table->integer('last_activity');
107 | });
108 |
109 | Of course, you may use the `session:table` Artisan command to generate this migration for you!
110 |
111 | php artisan session:table
112 |
113 | composer dump-autoload
114 |
115 | php artisan migrate
116 |
117 |
118 | ## Session Drivers
119 |
120 | The session "driver" defines where session data will be stored for each request. Laravel ships with several great drivers out of the box:
121 |
122 | - `file` - sessions will be stored in `storage/framework/sessions`.
123 | - `cookie` - sessions will be stored in secure, encrypted cookies.
124 | - `database` - sessions will be stored in a database used by your application.
125 | - `memcached` / `redis` - sessions will be stored in one of these fast, cached based stores.
126 | - `array` - sessions will be stored in a simple PHP array and will not be persisted across requests.
127 |
128 | > **Note:** The array driver is typically used for running [unit tests](/docs/{{version}}/testing), so no session data will be persisted.
129 |
--------------------------------------------------------------------------------
/structure.md:
--------------------------------------------------------------------------------
1 | # Application Structure
2 |
3 | - [Introduction](#introduction)
4 | - [The Root Directory](#the-root-directory)
5 | - [The App Directory](#the-app-directory)
6 | - [Namespacing Your Application](#namespacing-your-application)
7 |
8 |
9 | ## Introduction
10 |
11 | The default Laravel application structure is intended to provide a great starting point for both large and small applications. Of course, you are free to organize your application however you like. Laravel imposes almost no restrictions on where any given class is located - as long as Composer can autoload the class.
12 |
13 |
14 | ## The Root Directory
15 |
16 | The root directory of a fresh Laravel installation contains a variety of folders:
17 |
18 | The `app` directory, as you might expect, contains the core code of your application. We'll explore this folder in more detail soon.
19 |
20 | The `bootstrap` folder contains a few files that bootstrap the framework and configure autoloading.
21 |
22 | The `config` directory, as the name implies, contains all of your application's configuration files.
23 |
24 | The `database` folder contains your database migration and seeds.
25 |
26 | The `public` directory contains the front controller and your assets (images, JavaScript, CSS, etc.).
27 |
28 | The `resources` directory contains your views, raw assets (LESS, SASS, CoffeeScript), and "language" files.
29 |
30 | The `storage` directory contains compiled Blade templates, file based sessions, file caches, and other files generated by the framework.
31 |
32 | The `tests` directory contains your automated tests.
33 |
34 | The `vendor` directory contains your Composer dependencies.
35 |
36 |
37 | ## The App Directory
38 |
39 | The "meat" of your application lives in the `app` directory. By default, this directory is namespaced under `App` and is autoloaded by Composer using the [PSR-4 autoloading standard](http://www.php-fig.org/psr/psr-4/). **You may change this namespace using the `app:name` Artisan command**.
40 |
41 | The `app` directory ships with a variety of additional directories such as `Console`, `Http`, and `Providers`. Think of the `Console` and `Http` directories as providing an API into the "core" of your application. The HTTP protocol and CLI are both mechanisms to interact with your application, but do not actually contain application logic. In other words, they are simply two ways of issuing commands to your application. The `Console` directory contains all of your Artisan commands, while the `Http` directory contains your controllers, filters, and requests.
42 |
43 | The `Commands` directory, of course, houses the commands for your application. Commands represent jobs that can be queued by your application, as well as tasks that you can run synchronously within the current request lifecycle.
44 |
45 | The `Events` directory, as you might expect, houses event classes. Of course, using classes to represent events is not required; however, if you choose to use them, this directory is the default location they will be created by the Artisan command line.
46 |
47 | The `Handlers` directory contains the handler classes for both commands and events. Handlers receive a command or event and perform logic in response to that command or event being fired.
48 |
49 | The `Services` directory contains various "helper" services your application needs to function. For example, the `Registrar` service included with Laravel is responsible for validating and creating new users of your application. Other examples might be services to interact with external APIs, metrics systems, or even services that aggregate data from your own application.
50 |
51 | The `Exceptions` directory contains your application's exception handler and is also a good place to stick any exceptions thrown by your application.
52 |
53 | > **Note:** Many of the classes in the `app` directory can be generated by Artisan via commands. To review the available commands, run the `php artisan list make` command in your terminal.
54 |
55 |
56 | ## Namespacing Your Application
57 |
58 | As discussed above, the default application namespace is `App`; however, you may change this namespace to match the name of your application, which is easily done via the `app:name` Artisan command. For example, if your application is named "SocialNet", you would run the following command:
59 |
60 | php artisan app:name SocialNet
61 |
--------------------------------------------------------------------------------
/templates.md:
--------------------------------------------------------------------------------
1 | # Templates
2 |
3 | - [Blade Templating](#blade-templating)
4 | - [Other Blade Control Structures](#other-blade-control-structures)
5 |
6 |
7 | ## Blade Templating
8 |
9 | Blade is a simple, yet powerful templating engine provided with Laravel. Unlike controller layouts, Blade is driven by _template inheritance_ and _sections_. All Blade templates should use the `.blade.php` extension.
10 |
11 | #### Defining A Blade Layout
12 |
13 |
14 |
15 |
16 |
17 | App Name - @yield('title')
18 |
19 |
20 | @section('sidebar')
21 | This is the master sidebar.
22 | @show
23 |
24 |
44 | @stop
45 |
46 | Note that views which `extend` a Blade layout simply override sections from the layout. Content of the layout can be included in a child view using the `@@parent` directive in a section, allowing you to append to the contents of a layout section such as a sidebar or footer.
47 |
48 | Sometimes, such as when you are not sure if a section has been defined, you may wish to pass a default value to the `@yield` directive. You may pass the default value as the second argument:
49 |
50 | @yield('section', 'Default Content')
51 |
52 |
53 | ## Other Blade Control Structures
54 |
55 | #### Echoing Data
56 |
57 | Hello, {{ $name }}.
58 |
59 | The current UNIX timestamp is {{ time() }}.
60 |
61 | #### Echoing Data After Checking For Existence
62 |
63 | Sometimes you may wish to echo a variable, but you aren't sure if the variable has been set. Basically, you want to do this:
64 |
65 | {{ isset($name) ? $name : 'Default' }}
66 |
67 | However, instead of writing a ternary statement, Blade allows you to use the following convenient short-cut:
68 |
69 | {{ $name or 'Default' }}
70 |
71 | #### Displaying Raw Text With Curly Braces
72 |
73 | If you need to display a string that is wrapped in curly braces, you may escape the Blade behavior by prefixing your text with an `@` symbol:
74 |
75 | @{{ This will not be processed by Blade }}
76 |
77 | If you don't want the data to be escaped, you may use the following syntax:
78 |
79 | Hello, {!! $name !!}.
80 |
81 | > **Note:** Be very careful when echoing content that is supplied by users of your application. Always use the double curly brace syntax to escape any HTML entities in the content.
82 |
83 | #### If Statements
84 |
85 | @if (count($records) === 1)
86 | I have one record!
87 | @elseif (count($records) > 1)
88 | I have multiple records!
89 | @else
90 | I don't have any records!
91 | @endif
92 |
93 | @unless (Auth::check())
94 | You are not signed in.
95 | @endunless
96 |
97 | #### Loops
98 |
99 | @for ($i = 0; $i < 10; $i++)
100 | The current value is {{ $i }}
101 | @endfor
102 |
103 | @foreach ($users as $user)
104 |
115 | @endwhile
116 |
117 | #### Including Sub-Views
118 |
119 | @include('view.name')
120 |
121 | You may also pass an array of data to the included view:
122 |
123 | @include('view.name', ['some' => 'data'])
124 |
125 | #### Overwriting Sections
126 |
127 | To overwrite a section entirely, you may use the `overwrite` statement:
128 |
129 | @extends('list.item.container')
130 |
131 | @section('list.item.content')
132 |
This is an item of type {{ $item->type }}
133 | @overwrite
134 |
135 | #### Displaying Language Lines
136 |
137 | @lang('language.line')
138 |
139 | @choice('language.line', 1)
140 |
141 | #### Comments
142 |
143 | {{-- This comment will not be in the rendered HTML --}}
144 |
145 |
--------------------------------------------------------------------------------