-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlifecycle.html
executable file
·147 lines (120 loc) · 6.37 KB
/
lifecycle.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
<!DOCTYPE html>
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>Documentation</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width">
<link rel="stylesheet" href="css/style.css">
<script src="js/vendor/modernizr-2.6.2.min.js"></script>
</head>
<body>
<!--[if lt IE 7]>
<p class="chromeframe">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade your browser</a> or <a href="http://www.google.com/chromeframe/?redirect=true">activate Google Chrome Frame</a> to improve your experience.</p>
<![endif]-->
<div class="wrapper">
<header>
<h1>Documentation</h1>
</header>
<aside class="sidebar">
<ul>
<li>Preface
<ul>
<li><a href="index.html">Introduction</a></li>
<li><a href="contributing.html">Contributing</a></li>
</ul></li>
<li>Getting Started
<ul>
<li><a href="installation.html">Installation</a></li>
<li><a href="configuration.html">Configuration</a></li>
<li><a href="lifecycle.html">Request Lifecycle</a></li>
<li><a href="routing.html">Routing</a></li>
<li><a href="requests.html">Requests & Input</a></li>
<li><a href="responses.html">Views & Responses</a></li>
<li><a href="controllers.html">Controllers</a></li>
<li><a href="errors.html">Errors & Logging</a></li>
</ul></li>
<li>Learning More
<ul>
<li><a href="cache.html">Cache</a></li>
<li><a href="events.html">Events</a></li>
<li><a href="html.html">Forms & HTML</a></li>
<li><a href="ioc.html">IoC Container</a></li>
<li><a href="localization.html">Localization</a></li>
<li><a href="mail.html">Mail</a></li>
<li><a href="packages.html">Package Development</a></li>
<li><a href="pagination.html">Pagination</a></li>
<li><a href="queues.html">Queues</a></li>
<li><a href="security.html">Security</a></li>
<li><a href="session.html">Session</a></li>
<li><a href="templates.html">Templates</a></li>
<li><a href="testing.html">Unit Testing</a></li>
<li><a href="validation.html">Validation</a></li>
</ul></li>
<li>Database
<ul>
<li><a href="database.html">Basic Usage</a></li>
<li><a href="queries.html">Query Builder</a></li>
<li><a href="eloquent.html">Eloquent ORM</a></li>
<li><a href="schema.html">Schema Builder</a></li>
<li><a href="migrations.html">Migrations & Seeding</a></li>
<li><a href="redis.html">Redis</a></li>
</ul></li>
<li>Artisan CLI
<ul>
<li><a href="artisan.html">Overview</a></li>
<li><a href="commands.html">Development</a></li>
</ul></li>
</ul>
</aside>
<section class="content">
<h1>Request Lifecycle</h1>
<ul>
<li><a href="lifecycle.html#overview">Overview</a></li>
<li><a href="lifecycle.html#start-files">Start Files</a></li>
<li><a href="lifecycle.html#application-events">Application Events</a></li>
</ul>
<p><a name="overview"></a></p>
<h2>Overview</h2>
<p>The Laravel request lifecycle is fairly simple. A request enters your application and is dispatched to the appropriate route or controller. The response from that route is then sent back to the browser and displayed on the screen. Sometimes you may wish to do some processing before or after your routes are actually called. There are several opportunities to do this, two of which are "start" files and application events.</p>
<p><a name="start-files"></a></p>
<h2>Start Files</h2>
<p>Your application's start files are stored at <code>app/start</code>. By default, three are included with your application: <code>global.php</code>, <code>local.php</code>, and <code>artisan.php</code>. For more information about <code>artisan.php</code>, refer to the documentation on the <a href="commands.html#registering-commands">Artisan command line</a>.</p>
<p>The <code>global.php</code> start file contains a few basic items by default, such as the registration of the <a href="errors.html">Logger</a> and the inclusion of your <code>app/filters.php</code> file. However, you are free to add anything to this file that you wish. It will be automatically included on <em>every</em> request to your application, regardless of environment. The <code>local.php</code> file, on the other hand, is only called when the application is executing in the <code>local</code> environment. For more information on environments, check out the <a href="configuration.html">configuration</a> documentation.</p>
<p>Of course, if you have other environments in addition to <code>local</code>, you may create start files for those environments as well. They will be automatically included when your application is running in that environment.</p>
<p><a name="application-events"></a></p>
<h2>Application Events</h2>
<p>You may also do pre and post request processing by registering <code>before</code>, <code>after</code>, <code>close</code>, <code>finish</code>, and <code>shutdown</code> application events:</p>
<p><strong>Registering Application Events</strong></p>
<pre><code>App::before(function()
{
//
});
App::after(function($request, $response)
{
//
});
</code></pre>
<p>Listeners to these events will be run <code>before</code> and <code>after</code> each request to your application.</p>
<footer>
<p><a href="http://four.laravel.com" title="Laravel 4 Documentation">Laravel 4 Documentation</a> grabbed by <a href="http://roes-wibowo.com" title="Roes Wibowo">Roes Wibowo</a>.</p>
</footer>
</section>
<div class="clearfix"></div>
</div>
<script src="js/vendor/jquery-1.8.2.min.js"></script>
<script src="js/vendor/prettify.js"></script>
<script src="js/plugins.js"></script>
<script src="js/main.js"></script>
<script>
var _gaq=[['_setAccount','UA-37104170-1'],['_trackPageview']];
(function(d,t){var g=d.createElement(t),s=d.getElementsByTagName(t)[0];
g.src=('https:'==location.protocol?'//ssl':'//www')+'.google-analytics.com/ga.js';
s.parentNode.insertBefore(g,s)}(document,'script'));
</script>
</body>
</html>