{"id":112,"date":"2024-03-22T07:42:27","date_gmt":"2024-03-22T07:42:27","guid":{"rendered":"http:\/\/localhost\/w643\/?p=112"},"modified":"2024-03-25T07:38:09","modified_gmt":"2024-03-25T07:38:09","slug":"bai-5-service-container-phan-3","status":"publish","type":"post","link":"https:\/\/blog.hnk90.com\/?p=112","title":{"rendered":"B\u00e0i 5. Service Container \u2013 Ph\u1ea7n 3 &#8211; Instance And Scoped"},"content":{"rendered":"\n<p>I. Zero Configuration Resolution<br>II. Binding<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Basic Binding<br>1.1 Simple Binding<br>1.2 Binding a Singleton<br>1.3 Binding Scoped Singletons<br>1.4 Binding Instances<\/li>\n\n\n\n<li>Binding Interfaces to Implementations<\/li>\n\n\n\n<li>Contextual Binding<\/li>\n\n\n\n<li>Binding Primitives<\/li>\n\n\n\n<li>Binding Typed Variadics<br>5.1 Variadic Tag Dependencies<\/li>\n\n\n\n<li>Tagging<\/li>\n\n\n\n<li>Extending Bindings<\/li>\n<\/ol>\n\n\n\n<p>III. Resolving<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>Trong ph\u1ea7n tr\u01b0\u1edbc ch\u00fang ta \u0111\u00e3 t\u00ecm hi\u1ec3u v\u1ec1 Simple Binding, Binding a Singleton. Trong b\u00e0i n\u00e0y ch\u00fang ta s\u1ebd t\u00ecm hi\u1ec3u ti\u1ebfp v\u1ec1 Binding Scoped Singletons v\u00e0 Binding Instances<\/p>\n\n\n\n<p><strong>1.3 Binding Scoped Singletons<\/strong><\/p>\n\n\n\n<p>C\u00e1c bind nh\u01b0 sau<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#2e3440ff\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" data-code=\"use App\\Services\\Transistor;\nuse App\\Services\\PodcastParser;\nuse Illuminate\\Contracts\\Foundation\\Application;\n \n$this-&gt;app-&gt;scoped(Transistor::class, function (Application $app) {\n    return new Transistor($app-&gt;make(PodcastParser::class));\n});\" style=\"color:#d8dee9ff;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki nord\" style=\"background-color: #2e3440ff\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #D8DEE9\">use<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #D8DEE9\">App<\/span><span style=\"color: #D8DEE9FF\">\\<\/span><span style=\"color: #D8DEE9\">Services<\/span><span style=\"color: #D8DEE9FF\">\\<\/span><span style=\"color: #D8DEE9\">Transistor<\/span><span style=\"color: #81A1C1\">;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9\">use<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #D8DEE9\">App<\/span><span style=\"color: #D8DEE9FF\">\\<\/span><span style=\"color: #D8DEE9\">Services<\/span><span style=\"color: #D8DEE9FF\">\\<\/span><span style=\"color: #D8DEE9\">PodcastParser<\/span><span style=\"color: #81A1C1\">;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9\">use<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #D8DEE9\">Illuminate<\/span><span style=\"color: #D8DEE9FF\">\\<\/span><span style=\"color: #D8DEE9\">Contracts<\/span><span style=\"color: #D8DEE9FF\">\\<\/span><span style=\"color: #D8DEE9\">Foundation<\/span><span style=\"color: #D8DEE9FF\">\\<\/span><span style=\"color: #D8DEE9\">Application<\/span><span style=\"color: #81A1C1\">;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\"> <\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9\">$this<\/span><span style=\"color: #81A1C1\">-&gt;<\/span><span style=\"color: #D8DEE9\">app<\/span><span style=\"color: #81A1C1\">-&gt;<\/span><span style=\"color: #88C0D0\">scoped<\/span><span style=\"color: #D8DEE9FF\">(<\/span><span style=\"color: #D8DEE9\">Transistor<\/span><span style=\"color: #D8DEE9FF\">::<\/span><span style=\"color: #D8DEE9\">class<\/span><span style=\"color: #ECEFF4\">,<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #81A1C1\">function<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #ECEFF4\">(<\/span><span style=\"color: #D8DEE9\">Application<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #D8DEE9\">$app<\/span><span style=\"color: #ECEFF4\">)<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #ECEFF4\">{<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9FF\">    <\/span><span style=\"color: #81A1C1\">return<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #81A1C1\">new<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #88C0D0\">Transistor<\/span><span style=\"color: #D8DEE9FF\">(<\/span><span style=\"color: #D8DEE9\">$app<\/span><span style=\"color: #81A1C1\">-&gt;<\/span><span style=\"color: #88C0D0\">make<\/span><span style=\"color: #D8DEE9FF\">(<\/span><span style=\"color: #D8DEE9\">PodcastParser<\/span><span style=\"color: #D8DEE9FF\">::<\/span><span style=\"color: #D8DEE9\">class<\/span><span style=\"color: #D8DEE9FF\">))<\/span><span style=\"color: #81A1C1\">;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #ECEFF4\">}<\/span><span style=\"color: #D8DEE9FF\">)<\/span><span style=\"color: #81A1C1\">;<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p>Scoped t\u01b0\u01a1ng t\u1ef1 nh\u01b0 Singleton. Tuy nhi\u00ean, object instance s\u1ebd \u0111\u01b0\u1ee3c l\u00e0m m\u1edbi sau m\u1ed7i lifecycle. Hi\u1ec3u \u0111\u01a1n gi\u1ea3n l\u00e0 khi m\u1ed9t request (ho\u1eb7c m\u1ed9t job) \u0111ang \u0111\u01b0\u1ee3c x\u1eed l\u00fd th\u00ec object instance s\u1ebd l\u00e0 gi\u1ed1ng nhau. Nh\u01b0ng khi request\/job \u0111\u00f3 k\u1ebft th\u1ee5c, b\u1eaft \u0111\u1ea7u m\u1ed9t lifecycle m\u1edbi th\u00ec object instance s\u1ebd \u0111\u01b0\u1ee3c constructed l\u1ea1i.<\/p>\n\n\n\n<p><strong>1.4 Binding Instances<\/strong><\/p>\n\n\n\n<p>C\u00e1ch d\u00f9ng<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#2e3440ff\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" data-code=\"use App\\Services\\Transistor;\nuse App\\Services\\PodcastParser;\n\n\/\/ \u0110\u00e2y l\u00e0 m\u1ed9t instance &quot;c\u00f3 s\u1eb5n&quot;\n$service = new Transistor(new PodcastParser);\n\/\/ V\u00e0 b\u1ea1n mu\u1ed1n bind n\u00f3 v\u00e0o Container\n$this-&gt;app-&gt;instance(Transistor::class, $service);\" style=\"color:#d8dee9ff;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki nord\" style=\"background-color: #2e3440ff\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #D8DEE9\">use<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #D8DEE9\">App<\/span><span style=\"color: #D8DEE9FF\">\\<\/span><span style=\"color: #D8DEE9\">Services<\/span><span style=\"color: #D8DEE9FF\">\\<\/span><span style=\"color: #D8DEE9\">Transistor<\/span><span style=\"color: #81A1C1\">;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9\">use<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #D8DEE9\">App<\/span><span style=\"color: #D8DEE9FF\">\\<\/span><span style=\"color: #D8DEE9\">Services<\/span><span style=\"color: #D8DEE9FF\">\\<\/span><span style=\"color: #D8DEE9\">PodcastParser<\/span><span style=\"color: #81A1C1\">;<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #616E88\">\/\/ \u0110\u00e2y l\u00e0 m\u1ed9t instance &quot;c\u00f3 s\u1eb5n&quot;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9\">$service<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #81A1C1\">=<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #81A1C1\">new<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #88C0D0\">Transistor<\/span><span style=\"color: #D8DEE9FF\">(<\/span><span style=\"color: #81A1C1\">new<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #D8DEE9\">PodcastParser<\/span><span style=\"color: #D8DEE9FF\">)<\/span><span style=\"color: #81A1C1\">;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #616E88\">\/\/ V\u00e0 b\u1ea1n mu\u1ed1n bind n\u00f3 v\u00e0o Container<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9\">$this<\/span><span style=\"color: #81A1C1\">-&gt;<\/span><span style=\"color: #D8DEE9\">app<\/span><span style=\"color: #81A1C1\">-&gt;<\/span><span style=\"color: #88C0D0\">instance<\/span><span style=\"color: #D8DEE9FF\">(<\/span><span style=\"color: #D8DEE9\">Transistor<\/span><span style=\"color: #D8DEE9FF\">::<\/span><span style=\"color: #D8DEE9\">class<\/span><span style=\"color: #ECEFF4\">,<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #D8DEE9\">$service<\/span><span style=\"color: #D8DEE9FF\">)<\/span><span style=\"color: #81A1C1\">;<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p><\/p>\n\n\n\n<p>B\u1ea1n d\u00f9ng instance khi b\u1ea1n c\u00f3 m\u1ed9t object instance c\u00f3 s\u1eb5n, v\u00e0 b\u1ea1n mu\u1ed1n bind n\u00f3 v\u00e0o Container<br>V\u00ed d\u1ee5 ti\u1ebfp theo<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#2e3440ff\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" data-code=\"\/*\n* V\u00ed d\u1ee5 n\u00e0y l\u1ea5y t\u1eeb ngu\u1ed3n: https:\/\/viblo.asia\/p\/laravel-beauty-tim-hieu-ve-service-container-3KbvZ1wLGmWB\n*\/\n\n\/\/ $now l\u00e0 m\u1ed9t instance c\u00f3 s\u1eb5n\n$now = time();\n\/\/ bind n\u00f3 v\u00e0o trong Container\napp()-&gt;instance('now', $now);\n\/\/ Nh\u01b0 v\u1eady instance &quot;c\u00f3 s\u1eb5n&quot; s\u1ebd gi\u1ed1ng nh\u01b0 instance resolve t\u1eeb Container\n$now === app('now'); \/\/ true\" style=\"color:#d8dee9ff;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki nord\" style=\"background-color: #2e3440ff\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #616E88\">\/*<\/span><\/span>\n<span class=\"line\"><span style=\"color: #616E88\">* V\u00ed d\u1ee5 n\u00e0y l\u1ea5y t\u1eeb ngu\u1ed3n: https:\/\/viblo.asia\/p\/laravel-beauty-tim-hieu-ve-service-container-3KbvZ1wLGmWB<\/span><\/span>\n<span class=\"line\"><span style=\"color: #616E88\">*\/<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #616E88\">\/\/ $now l\u00e0 m\u1ed9t instance c\u00f3 s\u1eb5n<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9\">$now<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #81A1C1\">=<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #88C0D0\">time<\/span><span style=\"color: #D8DEE9FF\">()<\/span><span style=\"color: #81A1C1\">;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #616E88\">\/\/ bind n\u00f3 v\u00e0o trong Container<\/span><\/span>\n<span class=\"line\"><span style=\"color: #88C0D0\">app<\/span><span style=\"color: #D8DEE9FF\">()<\/span><span style=\"color: #81A1C1\">-&gt;<\/span><span style=\"color: #88C0D0\">instance<\/span><span style=\"color: #D8DEE9FF\">(<\/span><span style=\"color: #ECEFF4\">&#39;<\/span><span style=\"color: #A3BE8C\">now<\/span><span style=\"color: #ECEFF4\">&#39;<\/span><span style=\"color: #ECEFF4\">,<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #D8DEE9\">$now<\/span><span style=\"color: #D8DEE9FF\">)<\/span><span style=\"color: #81A1C1\">;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #616E88\">\/\/ Nh\u01b0 v\u1eady instance &quot;c\u00f3 s\u1eb5n&quot; s\u1ebd gi\u1ed1ng nh\u01b0 instance resolve t\u1eeb Container<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D8DEE9\">$now<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #81A1C1\">===<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #88C0D0\">app<\/span><span style=\"color: #D8DEE9FF\">(<\/span><span style=\"color: #ECEFF4\">&#39;<\/span><span style=\"color: #A3BE8C\">now<\/span><span style=\"color: #ECEFF4\">&#39;<\/span><span style=\"color: #D8DEE9FF\">)<\/span><span style=\"color: #81A1C1\">;<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #616E88\">\/\/ true<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p><\/p>\n\n\n\n<p>Binding Instance t\u01b0\u01a1ng t\u1ef1 nh\u01b0 Binding Singleton \u1edf \u0111i\u1ec3m instance ch\u1ec9 \u0111\u01b0\u1ee3c t\u1ea1o ra m\u1ed9t l\u1ea7n duy nh\u1ea5t, v\u00e0 s\u1ebd gi\u1eef l\u1ea1i trong su\u1ed1t qu\u00e1 tr\u00ecnh s\u1eed d\u1ee5ng (gi\u1ed1ng nhau \u1edf m\u1ecdi th\u1eddi \u0111i\u1ec3m resolve binding)<\/p>\n\n\n\n<p>Nh\u01b0 v\u1eady ch\u00fang ta \u0111\u00e3 \u0111i qua 4 kh\u00e1i n\u1ec7m v\u1ec1 Basic binding. <\/p>\n\n\n\n<p>Ch\u00fang ta ngh\u1ec9 tay \u1edf \u0111\u00e2y v\u00e0 c\u00f9ng suy ng\u1eabm l\u1ea1i v\u1ec1 Basic binding nh\u00e9. N\u00f3 l\u00e0 Basic nh\u01b0ng n\u00f3 c\u0169ng r\u1ea5t quan tr\u1ecdng, sau n\u00e0y s\u1ebd s\u1eed d\u1ee5ng th\u01b0\u1eddng xuy\u00ean trong qu\u00e1 tr\u00ecnh code. <\/p>\n\n\n\n<p>Ch\u00fac c\u00e1c b\u1ea1n m\u1ed9t ng\u00e0y t\u1ed1t l\u00e0nh ! \ud83d\ude42<br><\/p>\n","protected":false},"excerpt":{"rendered":"<p>I. Zero Configuration ResolutionII. Binding III. Resolving Trong ph\u1ea7n tr\u01b0\u1edbc ch\u00fang ta \u0111\u00e3 t\u00ecm hi\u1ec3u v\u1ec1 Simple Binding, Binding a Singleton. Trong b\u00e0i n\u00e0y ch\u00fang ta s\u1ebd t\u00ecm hi\u1ec3u ti\u1ebfp v\u1ec1 Binding Scoped Singletons v\u00e0 Binding Instances 1.3 Binding Scoped Singletons C\u00e1c bind nh\u01b0 sau Scoped t\u01b0\u01a1ng t\u1ef1 nh\u01b0 Singleton. Tuy nhi\u00ean, object instance s\u1ebd [&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-112","post","type-post","status-publish","format-standard","hentry","category-laravel"],"_links":{"self":[{"href":"https:\/\/blog.hnk90.com\/index.php?rest_route=\/wp\/v2\/posts\/112","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=112"}],"version-history":[{"count":9,"href":"https:\/\/blog.hnk90.com\/index.php?rest_route=\/wp\/v2\/posts\/112\/revisions"}],"predecessor-version":[{"id":157,"href":"https:\/\/blog.hnk90.com\/index.php?rest_route=\/wp\/v2\/posts\/112\/revisions\/157"}],"wp:attachment":[{"href":"https:\/\/blog.hnk90.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=112"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.hnk90.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=112"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.hnk90.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=112"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}