{"id":85,"date":"2024-03-21T10:06:08","date_gmt":"2024-03-21T10:06:08","guid":{"rendered":"http:\/\/localhost\/w643\/?p=85"},"modified":"2024-03-21T10:29:46","modified_gmt":"2024-03-21T10:29:46","slug":"bai-4-laravel-request-lifecycle","status":"publish","type":"post","link":"https:\/\/blog.hnk90.com\/?p=85","title":{"rendered":"B\u00e0i 4. Laravel Request Lifecycle"},"content":{"rendered":"\n<p>Laravel Request Lifecycle n\u00f4m na d\u1ecbch l\u00e0 v\u00f2ng \u0111\u1eddi c\u1ee7a m\u1ed9t request, t\u1eeb khi request \u0111\u01b0\u1ee3c kh\u1edfi t\u1ea1o cho \u0111\u1ebfn khi h\u1ec7 th\u1ed1ng tr\u1ea3 v\u1ec1 k\u1ebft qu\u1ea3.<\/p>\n\n\n\n<p>ngu\u1ed3n tham kh\u1ea3o<\/p>\n\n\n\n<p><a href=\"https:\/\/laravel.com\/docs\/11.x\/lifecycle#introduction\">https:\/\/laravel.com\/docs\/11.x\/lifecycle#introduction<\/a><\/p>\n\n\n\n<p><a href=\"https:\/\/dev.to\/patelparixit07\/laravel-request-lifecycle-195e\">https:\/\/dev.to\/patelparixit07\/laravel-request-lifecycle-195e<\/a><\/p>\n\n\n\n<p>\u1ea2nh minh h\u1ecda<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"414\" src=\"http:\/\/localhost\/w643\/wp-content\/uploads\/2024\/03\/image-17-1024x414.png\" alt=\"\" class=\"wp-image-86\" srcset=\"https:\/\/blog.hnk90.com\/wp-content\/uploads\/2024\/03\/image-17-1024x414.png 1024w, https:\/\/blog.hnk90.com\/wp-content\/uploads\/2024\/03\/image-17-300x121.png 300w, https:\/\/blog.hnk90.com\/wp-content\/uploads\/2024\/03\/image-17-768x310.png 768w, https:\/\/blog.hnk90.com\/wp-content\/uploads\/2024\/03\/image-17.png 1081w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>N\u00f3i chung \u0111\u00e2y l\u00e0 ki\u1ebfn th\u1ee9c &#8220;high level&#8221; &#8211; t\u1ed5ng quan v\u1ec1 h\u1ec7 th\u1ed1ng, s\u1ebd h\u01a1i kh\u00f3 \u0111\u1ec3 hi\u1ec3u c\u1eb7n k\u1ebd cho ng\u01b0\u1eddi m\u1edbi b\u1eaft \u0111\u1ea7u. V\u1eady n\u00ean ch\u00fang ta ch\u1ec9 hi\u1ec3u s\u01a1 l\u01b0\u1ee3c, \u0111\u00fang nh\u01b0 tinh th\u1ea7n &#8220;high level&#8221; &#8211; tinh th\u1ea7n hi\u1ec3u \u1edf m\u1ee9c \u0111\u1ed9 kh\u00e1i qu\u00e1t.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u0110\u1ea7u ti\u00ean th\u00ec ng\u01b0\u1eddi d\u00f9ng g\u1eedi m\u1ed9t request (V\u00ed d\u1ee5 nh\u01b0 load trang home page)<\/li>\n\n\n\n<li>File \u0111\u1ea7u ti\u00ean s\u1ebd \u0111\u01b0\u1ee3c g\u1ecdi l\u00e0 pub\/index.php<\/li>\n\n\n\n<li>Ti\u1ebfp \u0111\u1ebfn l\u00e0 bootstrap\/app.php<\/li>\n\n\n\n<li>Ti\u1ebfp theo s\u1ebd t\u1edbi app\/http\/kernel.php<br>Kernel &#8211; &#8220;h\u1ea1t nh\u00e2n&#8221;, \u0111\u00f3ng vai tr\u00f2 nh\u01b0: x\u00e1c \u0111\u1ecbnh c\u00e1c configuration, m\u00f4i tr\u01b0\u1eddng, c\u1ea5u h\u00ecnh x\u1eed l\u00fd l\u1ed7i, &#8230; <br>\u0110\u1eb7c bi\u1ec7t l\u00e0 n\u00f3 kh\u1edfi \u0111\u1ed9ng Service Providers &#8211; m\u1ed9t th\u00e0nh ph\u1ea7n t\u1ed1i quan tr\u1ecdng trong laravel.<br><br>C\u00f3 hai d\u1ea1ng Kernel ch\u00ednh l\u00e0 : Http Kernel v\u00e0 Console Kernel (tham kh\u1ea3o trong file bootstrap\/app.php), t\u00f9y thu\u1ed9c v\u00e0o request l\u00e0 g\u00ec m\u00e0 Kernel t\u01b0\u01a1ng \u1ee9ng s\u1ebd \u0111\u01b0\u1ee3c g\u1ecdi t\u1edbi \u0111\u1ec3 x\u1eed l\u00fd.<br><br><\/li>\n\n\n\n<li>Ti\u1ebfp theo l\u00e0 Service Providers<br><br>V\u00ed d\u1ee5 nh\u01b0: \u00a0<em>Database, Routing, Queueing,<\/em>&#8230;<br>N\u00f3i m\u1ed9t c\u00e1ch ng\u1eafn g\u1ecdn th\u00ec m\u1ecdi t\u00ednh n\u0103ng trong laravel \u0111\u1ec1u c\u1ea7n kh\u1edfi \u0111\u1ed9ng t\u1eeb Service Providers<br>Sau n\u00e0y khi \u0111i s\u00e2u h\u01a1n, m\u00ecnh s\u1ebd th\u1ea3o lu\u1eadn chi ti\u1ebft v\u1ec1 Seriver Providers nh\u00e9, gi\u1edd t\u1ea1m th\u1eddi hi\u1ec3u t\u1edbi \u0111\u00e2y th\u00f4i. <br><br><\/li>\n\n\n\n<li>Ti\u1ebfp theo request s\u1ebd \u0111\u01b0\u1ee3c g\u1eedi t\u1edbi router &#8211; n\u01a1i \u0111i\u1ec1u h\u01b0\u1edbng request<\/li>\n\n\n\n<li>Request s\u1ebd \u0111i qua Middleware &#8211; n\u01a1i x\u1ef7 l\u00fd m\u1ed9t s\u1ed1 t\u00e1c v\u1ee5 v\u00ed d\u1ee5 nh\u01b0 l\u00e0: Manage HTTP session, Detect maintenance mode, verify CSRF token,\u2026<\/li>\n\n\n\n<li>R\u1ed3i cu\u1ed1i c\u00f9ng l\u00e0 t\u1edbi controller v\u00e0 view tr\u1ea3 k\u1ebft qu\u1ea3 v\u1ec1 cho ng\u01b0\u1eddi d\u00f9ng<\/li>\n<\/ul>\n\n\n\n<p>OKe, n\u00f3i chung \u1edf m\u1ee9c n\u00e0y th\u00ec ch\u00fang ta hi\u1ec3u kh\u00e1i qu\u00e1t nh\u01b0 v\u1eady. Ch\u00fang ta s\u1ebd b\u00e0n s\u00e2u h\u01a1n khi \u0111\u00e3 c\u00f3 l\u01b0\u1ee3ng ki\u1ebfn th\u1ee9c nhi\u1ec1u h\u01a1n nh\u00e9.<\/p>\n\n\n\n<p>Thanks for reading \ud83d\ude42<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Laravel Request Lifecycle n\u00f4m na d\u1ecbch l\u00e0 v\u00f2ng \u0111\u1eddi c\u1ee7a m\u1ed9t request, t\u1eeb khi request \u0111\u01b0\u1ee3c kh\u1edfi t\u1ea1o cho \u0111\u1ebfn khi h\u1ec7 th\u1ed1ng tr\u1ea3 v\u1ec1 k\u1ebft qu\u1ea3. ngu\u1ed3n tham kh\u1ea3o https:\/\/laravel.com\/docs\/11.x\/lifecycle#introduction https:\/\/dev.to\/patelparixit07\/laravel-request-lifecycle-195e \u1ea2nh minh h\u1ecda N\u00f3i chung \u0111\u00e2y l\u00e0 ki\u1ebfn th\u1ee9c &#8220;high level&#8221; &#8211; t\u1ed5ng quan v\u1ec1 h\u1ec7 th\u1ed1ng, s\u1ebd h\u01a1i kh\u00f3 \u0111\u1ec3 hi\u1ec3u c\u1eb7n [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[],"class_list":["post-85","post","type-post","status-publish","format-standard","hentry","category-laravel"],"_links":{"self":[{"href":"https:\/\/blog.hnk90.com\/index.php?rest_route=\/wp\/v2\/posts\/85","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.hnk90.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.hnk90.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.hnk90.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.hnk90.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=85"}],"version-history":[{"count":6,"href":"https:\/\/blog.hnk90.com\/index.php?rest_route=\/wp\/v2\/posts\/85\/revisions"}],"predecessor-version":[{"id":92,"href":"https:\/\/blog.hnk90.com\/index.php?rest_route=\/wp\/v2\/posts\/85\/revisions\/92"}],"wp:attachment":[{"href":"https:\/\/blog.hnk90.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=85"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.hnk90.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=85"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.hnk90.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=85"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}