{"id":9817,"date":"2021-12-13T07:00:13","date_gmt":"2021-12-12T22:00:13","guid":{"rendered":"https:\/\/blog.capilano-fw.com\/?p=9817"},"modified":"2021-11-12T06:14:44","modified_gmt":"2021-11-11T21:14:44","slug":"laravel%e3%81%a7php%e3%81%ae%e9%9d%9e%e5%90%8c%e6%9c%9f%e9%80%9a%e4%bf%a1%e3%82%92%e3%81%99%e3%82%8b%ef%bc%88guzzle%e3%81%a7%e7%b0%a1%e5%8d%98%ef%bc%81%ef%bc%89","status":"publish","type":"post","link":"https:\/\/blog.capilano-fw.com\/?p=9817","title":{"rendered":"\u3010Laravel\u3011PHP\u3067\u975e\u540c\u671f\u901a\u4fe1\u3092\u3059\u308b\uff08Guzzle\u3067\u7c21\u5358\uff01\uff09"},"content":{"rendered":"<p>\u3055\u3066\u3055\u3066\u3001\u6700\u8fd1\u3067\u306f\u300c<strong>\u30af\u30e9\u30a6\u30c9<\/strong>\u300d\u3068\u3044\u3046\u8a00\u8449\u306f\u6280\u8853\u8005\u306a\u3089\u8ab0\u3067\u3082\u77e5\u3063\u3066\u3044\u308b\u3082\u306e\u306b\u306a\u308a\u307e\u3057\u305f\u3002<\/p>\n<p>\u521d\u3081\u3066\u3053\u306e\u8a00\u8449\u3092\u805e\u3044\u305f\u3068\u304d\u306f\u300c<strong>\u30af\u30e9\u30a6\u30c9 \u2192 \u96f2 \u2192 \u96e8\u304c\u964d\u308b \u2192 \u3044\u3084\u3001\u305d\u308c\u4e0d\u5409\u3058\u3083\u306a\u3044\uff1f\uff1f<\/strong>\u300d\u3068\u601d\u3063\u305f\u3082\u306e\u3067\u3059\u304c\ud83d\ude02\u3001\u30a4\u30f3\u30bf\u30fc\u30cd\u30c3\u30c8\u3092\u4ecb\u3057\u3066\u5fc5\u8981\u306a\u51e6\u7406\u3060\u3051\u3092\u884c\u3046\u3068\u3044\u3046\u3084\u308a\u65b9\u306f\u3001\u5e02\u5834\u898f\u6a21\u306e\u63a8\u79fb\u3092\u898b\u308b\u3068\u3069\u308c\u3060\u3051\u4eba\u6c17\u304b\u5206\u304b\u308a\u307e\u3059\u3002<\/p>\n<p>\u305d\u3057\u3066\u3001\u79c1\u306e\u5834\u5408\u3082\u4f8b\u306b\u6f0f\u308c\u305a<code>AWS<\/code>\u3092\u6d3b\u7528\u3059\u308b\u958b\u767a\u3082\u3054\u4f9d\u983c\u3044\u305f\u3060\u304f\u3088\u3046\u306b\u306a\u3063\u305f\u306e\u3067\u3059\u304c\u3001\u305d\u306e\u7d50\u679c\u5fc5\u8981\u3068\u306a\u3063\u3066\u304d\u305f\u3053\u3068\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<p>\u305d\u308c\u304c\u30fb\u30fb\u30fb\u30fb\u30fb\u30fb<\/p>\n<p><strong style=\"font-size: 35px;\">\uff08PHP\u306e\uff09\u975e\u540c\u671f\u901a\u4fe1<\/strong><\/p>\n<p>\u3067\u3059\u3002<\/p>\n<p>\u975e\u540c\u671f\u901a\u4fe1\u3068\u3044\u3046\u306e\u306f\u3001\u30b7\u30f3\u30d7\u30eb\u306b\u8a00\u3046\u3068\u300c<strong>\u305d\u308c\u3092\u5f85\u3063\u3066\u306a\u304f\u3066\u3082OK<\/strong>\u300d\u306a\u901a\u4fe1\u306e\u3053\u3068\u3067\u3001\u3053\u308c\u306f<code>JavaScript<\/code>\u306e<code>axios<\/code>\u306a\u3069\u3067\u3088\u304f\u4f7f\u308f\u308c\u308b\u8a00\u8449\u3058\u3083\u306a\u3044\u3067\u3057\u3087\u3046\u304b\uff08<code>JavaScript<\/code>\u3068<code>PHP<\/code>\u306e\u975e\u540c\u671f\u306f\u30cb\u30e5\u30a2\u30f3\u30b9\u304c\u3061\u3087\u3063\u3068\u9055\u3044\u307e\u3059\u304c\uff09<\/p>\n<p>\u3064\u307e\u308a\u3001\u300c<strong>\u3072\u3068\u308a\u3067\u3084\u308b\u306e\u306f\u3057\u3093\u3069\u3044\u304b\u3089\u3001\u307f\u3093\u306a\u3067\u5b8c\u4e86\u3055\u305b\u3088\u3046\uff01<\/strong>\u300d\u3068\u3044\u3046\u300c<strong>One for all All for one<\/strong>\u300d\u306e\u7cbe\u795e\u3067\u3059\u306d\uff08\u7b11\uff09<\/p>\n<p>\u30e1\u30ea\u30c3\u30c8\u3068\u3057\u3066\u306f\u3001\u3082\u3061\u308d\u3093\u51e6\u7406\u306e\u9ad8\u901f\u5316\u3067\u3059\u3002<\/p>\n<p>\u4f8b\u3048\u3070\u3001\uff12\u3064\u306eURL\u306b\u30a2\u30af\u30bb\u30b9\u3059\u308b\u5834\u5408\u3092\u8003\u3048\u3066\u307f\u307e\u3057\u3087\u3046\u3002<br \/>\n\u307e\u305a\u306f\u3001\u975e\u540c\u671f<strong>\u3067\u306f\u306a\u3044<\/strong>\u5834\u5408\u3067\u3059\u3002<\/p>\n<ol>\n<li>URL\uff08\u305d\u306e\uff11\uff09\u306b\u30a2\u30af\u30bb\u30b9<\/li>\n<li>\u5f85\u3061<\/li>\n<li>\u5b8c\u4e86\u2728<\/li>\n<li>URL\uff08\u305d\u306e\uff12\uff09\u306b\u30a2\u30af\u30bb\u30b9<\/li>\n<li>\u5f85\u3061<\/li>\n<li>\u5b8c\u4e86\u2728<\/li>\n<\/ol>\n<p>\u3068\uff11\u3064\u305a\u3064\u300c<strong>\u30a2\u30af\u30bb\u30b9\uff06\u5f85\u3061<\/strong>\u300d\u3092\u7e70\u308a\u8fd4\u3059\u305f\u3081\u3001\u6642\u9593\u304c\u304b\u304b\u308a\u307e\u3059\u3002<\/p>\n<p>\u3057\u304b\u3057\u3001\u975e\u540c\u671f\u306e\u5834\u5408\u306f\u6b21\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<ol>\n<li>URL \u305d\u306e\uff11\u306b\u30a2\u30af\u30bb\u30b9<\/li>\n<li>\u5f85\u305f\u305a\u306bURL\uff08\u305d\u306e\uff12\uff09\u306b\u30a2\u30af\u30bb\u30b9<\/li>\n<li>\u3059\u3079\u3066\u306e\u30a2\u30af\u30bb\u30b9\u304c\u5b8c\u4e86\u3059\u308b<\/li>\n<li>\u5b8c\u4e86\u2728\u2728<\/li>\n<\/ol>\n<p>\u3069\u3046\u3067\u3057\u3087\u3046\u3002<\/p>\n<p>\u300c<strong>\u3088\u30fc\u3044\u30c9\u30f3<\/strong>\u300d\u3067\u30a2\u30af\u30bb\u30b9\u3059\u308b\u306e\u3067\u3001\u300c\u5f85\u3061\u300d\u306e\u90e8\u5206\u304c\u91cd\u306a\u308a\u3001\u305d\u306e\u5206\u65e9\u304f\u51e6\u7406\u3067\u304d\u308b\u3068\u3044\u3046\u308f\u3051\u3067\u3059\u306d\u3002<\/p>\n<p>\u305d\u3046\u3067\u3059\u2757<\/p>\n<p>\u3053\u306e\u975e\u540c\u671f\u901a\u4fe1\u304c\u4f7f\u3046\u3068\u3001\u30af\u30e9\u30a6\u30c9\u3078\u306e<strong>HTTP\u30a2\u30af\u30bb\u30b9\u304c\u91cd\u8907\u3057\u3066\u3082\u3001\u51e6\u7406\u3092\u65e9\u304f\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u308b<\/strong>\u3068\u3044\u3046\u308f\u3051\u3067\u3059\u3002<\/p>\n<p>\u3068\u3044\u3046\u3053\u3068\u3067\u3001\u4eca\u56de\u306f<code>Laravel<\/code>+<code>Guzzle<\/code>\u3067\u3053\u306e\u975e\u540c\u671f\u901a\u4fe1\u3092\u5b9f\u88c5\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<p>\u4f55\u304b\u306e\u53c2\u8003\u306b\u306a\u308a\u307e\u3057\u305f\u3089\u5b09\u3057\u3044\u3067\u3059\u3002\ud83d\ude04\u2728<\/p>\n<p style=\"text-align: center;\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-9809 aligncenter\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2021\/11\/no_9.png\" alt=\"\" width=\"370\" height=\"220\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2021\/11\/no_9.png 370w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2021\/11\/no_9-300x178.png 300w\" sizes=\"auto, (max-width: 370px) 100vw, 370px\" \/>\u300c\u30e6\u30fc\u30b6\u30fc\u306f\u5f85\u3063\u3066\u304f\u308c\u306a\u3044\u3001<br \/>\n\u304c\u539f\u5247\u3067\u3059\uff01\u300d<\/p>\n<p><strong>\u958b\u767a\u74b0\u5883\uff1a<\/strong> Laravel 8.x\u3001Guzzle 7.4<\/p>\n<h1>\u3084\u308a\u305f\u3044\u3053\u3068<\/h1>\n<p>\u4eca\u56de\u5b9f\u88c5\u3059\u308b\u5185\u5bb9\u306f\u3001\u300c<strong>\u8907\u6570\u3042\u308bURL\u306b\u975e\u540c\u671f\u901a\u4fe1\u3059\u308b<\/strong>\u300d\u3067\u3059\u3002<\/p>\n<p>\u3057\u304b\u3057\u3001<code>JavaScript<\/code>\u306e\u975e\u540c\u671f\u3068\u306f\u9055\u3063\u3066<code>PHP<\/code>\u306f\uff11\u56de\u306e\u30a2\u30af\u30bb\u30b9\u3067\u5b8c\u7d50\u3059\u308b\u306e\u3067\u3001\u5c11\u3057\u9055\u3063\u3066\u304d\u307e\u3059\u3002<\/p>\n<p>\u4f8b\u3048\u3070\u6b21\u306e\u5834\u5408\u3092\u307f\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<ul>\n<li>URL\uff08\u305d\u306e\uff11\uff09\uff1a \u51e6\u7406\u306b\uff11\u79d2\u304b\u304b\u308b<\/li>\n<li>URL\uff08\u305d\u306e\uff12\uff09\uff1a \u51e6\u7406\u306b\uff14\u79d2\u304b\u304b\u308b<\/li>\n<li>URL\uff08\u305d\u306e\uff13\uff09\uff1a \u51e6\u7406\u306b\uff19\u79d2\u304b\u304b\u308b<\/li>\n<\/ul>\n<p>\u3053\u306e\u5834\u5408\u3001\uff08PHP\u306e\uff09\u975e\u540c\u671f\u901a\u4fe1\u3060\u3068\u5168\u90e8\u3067\uff19\u79d2\u304b\u304b\u308a\u307e\u3059\u3002<\/p>\n<p>\u3064\u307e\u308a\u3001\u4e00\u756a\u9577\u3044\u79d2\u6570\u306f\u6700\u4f4e\u3067\u3082\u5fc5\u8981\u306b\u306a\u3063\u3066\u304f\u308b\u3068\u3044\u3046\u308f\u3051\u3067\u3059\u306d\u3002\uff08\u9006\u306b\u3072\u3068\u3064\u305a\u3064\u5f85\u3063\u3066\u3044\u308b\u3068\u3001\u5168\uff11\uff14\u79d2\u304b\u304b\u308a\u307e\u3059\uff09<\/p>\n<p>\u3053\u308c\u306f\u3001\u4f8b\u3048\u3070<code>AWS<\/code>\u3068<code>Google Cloud<\/code>\u4e21\u65b9\u306b\u753b\u50cf\u3092\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9\u3057\u3066\u7269\u4f53\u691c\u51fa\u3059\u308b\u3088\u3046\u306a\u30a4\u30e1\u30fc\u30b8\u3067\u3059\u3002<\/p>\n<h1>Guzzle \u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b<\/h1>\n<p><code>Laravel 7.x<\/code>\u4ee5\u964d\u306f<code>HTTP Client<\/code>\u3068\u3057\u3066<code>Guzzle<\/code>\u3092\u4f7f\u3046\u3088\u3046\u306b\u306a\u3063\u305f\u305f\u3081\u3001\u521d\u671f\u72b6\u614b\u3067\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3055\u308c\u3066\u3044\u308b\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<p>\u305d\u306e\u305f\u3081\u3001\u3082\u3057<code>Laravel 6.x<\/code>\u4ee5\u524d\u306e\u65b9\u306f\u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3057\u3066<code>Guzzle<\/code>\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<pre><strong>composer require guzzlehttp\/guzzle<\/strong><\/pre>\n<h1>\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u30fc\u3092\u3064\u304f\u308b<\/h1>\n<p>\u3067\u306f\u3001\u3082\u3046<code>Guzzle<\/code>\u3092\u4f7f\u3063\u3066\u975e\u540c\u671f\u901a\u4fe1\u3059\u308b\u30b3\u30fc\u30c9\u3092\u3064\u304f\u3063\u3066\u3044\u304d\u307e\u3059\u3002<br \/>\n\u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u3067\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u30fc\u3092\u3064\u304f\u3063\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<pre><strong>php artisan make:controller AsyncController<\/strong><\/pre>\n<p>\u3059\u308b\u3068\u3001\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u30fc\u304c\u4f5c\u6210\u3055\u308c\u308b\u306e\u3067\u4e2d\u8eab\u3092\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u3057\u307e\u3059\u3002<\/p>\n<p><strong>app\/Http\/Controllers\/AsyncController.php<\/strong><\/p>\n<pre>&lt;?php\r\n\r\nnamespace App\\Http\\Controllers;\r\n\r\nuse Illuminate\\Http\\Request;\r\n<strong>use GuzzleHttp\\Promise;<\/strong>\r\n<strong>use GuzzleHttp\\Client;<\/strong>\r\n<strong>use GuzzleHttp\\Exception\\RequestException;<\/strong>\r\n<strong>use Aws\\Rekognition\\RekognitionClient;<\/strong>\r\n\r\n<strong>class AsyncController extends Controller<\/strong>\r\n<strong>{<\/strong>\r\n<strong>    public function request()<\/strong>\r\n<strong>    {<\/strong>\r\n<strong>        $start_time = microtime(true);<\/strong>\r\n<strong>        dump('\u958b\u59cb');<\/strong>\r\n\r\n<strong>        $client = new Client();<\/strong>\r\n<strong>        $promises = [];<\/strong>\r\n\r\n<strong>        for($i = 1 ; $i &lt;= 4; $i++) {<\/strong>\r\n\r\n<strong>            $url = route('async.response', $i); \/\/ \uff14\u3064\u306eURL\u3092\u4f5c\u6210<\/strong>\r\n<strong>            $promises[] = $client-&gt;getAsync($url) \/\/ Promise\uff08\u975e\u540c\u671f\u901a\u4fe1\u306e\u305f\u3081\u306e\u30a2\u30af\u30bb\u30b9\u60c5\u5831\uff09\u3092\u3064\u304f\u308b<\/strong>\r\n<strong>                -&gt;then(<\/strong>\r\n<strong>                    function($response) use($i, $start_time) { \/\/ \u30a2\u30af\u30bb\u30b9\u306b\u6210\u529f\u3057\u305f\u6642<\/strong>\r\n\r\n<strong>                        $end_time = microtime(true) - $start_time;<\/strong>\r\n<strong>                        dump('\u975e\u540c\u671f\u901a\u4fe1\u306e\u7d42\u4e86 \u305d\u306e'. $i .'\uff1a '. $end_time .' \u79d2');<\/strong>\r\n\r\n<strong>                    },<\/strong>\r\n<strong>                    function(RequestException $e) { \/\/ \u30a2\u30af\u30bb\u30b9\u306b\u5931\u6557\u3057\u305f\u3068\u304d<\/strong>\r\n\r\n<strong>                        dump($e-&gt;getMessage());<\/strong>\r\n\r\n<strong>                    }<\/strong>\r\n<strong>                );<\/strong>\r\n\r\n<strong>        }<\/strong>\r\n\r\n<strong>        $responses = Promise\\Utils::settle($promises)-&gt;wait();<\/strong>\r\n<strong>        dump('\u7d42\u4e86\uff1a'. microtime(true) - $start_time .' \u79d2');<\/strong>\r\n<strong>    }<\/strong>\r\n\r\n<strong>    public function response($id) { \/\/ \u91cd\u305f\u3044\u51e6\u7406\u306e\u30c6\u30b9\u30c8<\/strong>\r\n\r\n<strong>        $id = intval($id);<\/strong>\r\n\r\n<strong>        if($id === 4) {<\/strong>\r\n\r\n<strong>            abort(404); \/\/ $id \u304c 4 \u306e\u5834\u5408\u3060\u3051 404 \u30a8\u30e9\u30fc\u3092\u8fd4\u3059<\/strong>\r\n\r\n<strong>        }<\/strong>\r\n\r\n<strong>        $seconds = pow($id, 2); \/\/ $id \u30922\u4e57\u3057\u3066\u79d2\u6570\u306b\u3059\u308b<\/strong>\r\n<strong>        sleep($seconds);<\/strong>\r\n\r\n<strong>    }<\/strong>\r\n<strong>}<\/strong><\/pre>\n<p>\u3053\u306e\u4e2d\u3067\u3084\u3063\u3066\u3044\u308b\u306e\u306f\u6b21\u306e\u3068\u304a\u308a\u3067\u3059\u3002<\/p>\n<h2>request()<\/h2>\n<p>\u3053\u306e\u4e2d\u3067\u3084\u3063\u3066\u3044\u308b\u624b\u9806\u306f\u6b21\u306e\u3068\u304a\u308a\u3067\u3059\u3002<\/p>\n<ol>\n<li>URL\u3092\u3064\u304f\u308b<\/li>\n<li>Promise\uff08\u975e\u540c\u671f\u901a\u4fe1\u306e\u305f\u3081\u306e\u30a2\u30af\u30bb\u30b9\u60c5\u5831\uff09\u3092\u3064\u304f\u308a\u3001\u914d\u5217\u3078\u8caf\u3081\u3066\u3044\u304f<\/li>\n<li>\u8caf\u307e\u3063\u305f Promise \u3092 settle() \u3078\u30bb\u30c3\u30c8\u3057\u3001\u975e\u540c\u671f\u901a\u4fe1\u3092\u958b\u59cb<\/li>\n<li>\u30a2\u30af\u30bb\u30b9\u304c\u5168\u3066\u7d42\u308f\u3063\u305f\u3089\u5b8c\u4e86<\/li>\n<\/ol>\n<p>\u306a\u304a\u3001\u4eca\u56de\u306f\u30b3\u30fc\u30c9\u304c\u77ed\u3044\u306e\u3067\u3001\u30a2\u30af\u30bb\u30b9\u306b\u5931\u6557\u3057\u305f\u5834\u5408\u306e\u51e6\u7406\u3082\u3064\u3051\u3066\u3044\u307e\u3059\u3002\u5b9f\u969b\u306b\u306f\u3001<code>$i<\/code>\u304c<code>4<\/code>\u306e\u3068\u304d\u3067\u3059\u3002<\/p>\n<p>\u3064\u307e\u308a\u3001<code>then()<\/code>\u306b\u306f\uff11\u3064\u76ee\u304c\u30a2\u30af\u30bb\u30b9\u306b\u6210\u529f\u3057\u305f\u6642\u3067\u3001\uff12\u3064\u76ee\u306f\u5931\u6557\u3057\u305f\u3068\u304d\u306e\u51e6\u7406\u3092\u66f8\u304f\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<h2>response()<\/h2>\n<p>\u3053\u306e\u30e1\u30bd\u30c3\u30c9\u306f\u975e\u540c\u671f\u901a\u4fe1\u306e\u30a2\u30af\u30bb\u30b9\u5148\u3067\u3001<span style=\"font-size: 1rem;\">\u53d7\u3051\u53d6\u3063\u305fID\u3092\uff12\u4e57\u3057\u305f\u79d2\u6570\u3092\u5f85\u6a5f\u3059\u308b\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u3002<\/span><\/p>\n<p>\u3064\u307e\u308a\u3001<\/p>\n<ul>\n<li>$i \u304c 1 \u306e\u5834\u5408\uff1a 1 \u79d2\u5f85\u3064<\/li>\n<li>$i \u304c 2 \u306e\u5834\u5408\uff1a 4 \u79d2\u5f85\u3064<\/li>\n<li>$i \u304c 3 \u306e\u5834\u5408\uff1a 9 \u79d2\u5f85\u3064<\/li>\n<\/ul>\n<p>\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\u307e\u305f\u3001<code>$i<\/code>\u304c<code>4<\/code>\u306e\u3068\u304d\u306e\u51e6\u7406\u306f\u5148\u307b\u3069\u8aac\u660e\u3057\u305f\u3068\u304a\u308a\u3067\u3059\u3002<\/p>\n<h1>\u30eb\u30fc\u30c8\u3092\u3064\u304f\u308b<\/h1>\n<p>\u3067\u306f\u3001\u5148\u307b\u3069\u306e\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u30fc\u3092\u30eb\u30fc\u30c8\u306b\u30bb\u30c3\u30c8\u3057\u307e\u3057\u3087\u3046\u3002<\/p>\n<p><strong>routes\/web.php<\/strong><\/p>\n<pre>\/\/ \u7701\u7565<strong>\r\n\r\nuse App\\Http\\Controllers\\AsyncController;<\/strong>\r\n\r\n\/\/ \u7701\u7565\r\n\r\n<strong>Route::get('async\/request', [AsyncController::class, 'request'])-&gt;name('async.request');<\/strong>\r\n<strong>Route::get('async\/response\/{id}', [AsyncController::class, 'response'])-&gt;name('async.response');<\/strong><\/pre>\n<p>\u4f5c\u696d\u306f\u305f\u3063\u305f\u3053\u308c\u3060\u3051\u3067\u5b8c\u4e86\u3067\u3059\u3002\uff08<code>Guzzle<\/code>\u69d8\u3005\u3067\u3059\u306d\ud83d\udc4d\uff09<\/p>\n<p>\u304a\u75b2\u308c\u69d8\u3067\u3057\u305f\ud83d\ude04\u2728<\/p>\n<h1>\u3061\u306a\u307f\u306b\uff1a AWS\u306e\u30d1\u30c3\u30b1\u30fc\u30b8\u306b\u306f\u975e\u540c\u671f\u578b\u304c\u7528\u610f\u3055\u308c\u3066\u3044\u307e\u3059<\/h1>\n<p><code>AWS<\/code>\u304c\u7528\u610f\u3057\u3066\u304f\u308c\u3066\u3044\u308b<code>aws\/aws-sdk-php<\/code>\u3068\u3044\u3046PHP\u7528\u30d1\u30c3\u30b1\u30fc\u30b8\u306b\u306f\u3001\u3044\u308d\u3044\u308d\u306a\u30af\u30e9\u30b9\u304c\u3042\u308a\u307e\u3059\u304c\u3001\u305d\u306e\u4e2d\u306b\u306f<strong>Guzzle\u306e\u975e\u540c\u671f\u901a\u4fe1\u306b\u5bfe\u5fdc\u3057\u3066\u3044\u308b\u3082\u306e\u3082\u3042\u308a\u307e\u3059\u3002<\/strong><\/p>\n<p>\u4f8b\u3048\u3070\u3001<code>Amazon Rekognition<\/code>\u306e\u5834\u5408\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306b<code>detectCustomLabelsAsync()<\/code>\u306e\u3088\u3046\u306a\u30e1\u30bd\u30c3\u30c9\u3092\u4f7f\u3046\u3068<code>Promise<\/code>\u3092\u53d6\u5f97\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<pre><strong>$client = new RekognitionClient([<\/strong>\r\n<strong>    'region' =&gt; 'ap-northeast-1',<\/strong>\r\n<strong>    'version' =&gt; 'latest'<\/strong>\r\n<strong>]);<\/strong>\r\n<strong>$promises[] = $client-&gt;detectCustomLabelsAsync([<\/strong>\r\n<strong>    'Image' =&gt; [<\/strong>\r\n<strong>        'Bytes' =&gt; $bytes,<\/strong>\r\n<strong>    ],<\/strong>\r\n<strong>    'ProjectVersionArn' =&gt; env('AWS_REKOGNITION_ARN')<\/strong>\r\n<strong>]);<\/strong><\/pre>\n<p>\u3064\u307e\u308a\u3001\u308f\u3056\u308f\u3056\u81ea\u524d\u3067URL\u3068\u30d1\u30e9\u30e1\u30fc\u30bf\u3092\u7528\u610f\u3057\u306a\u304f\u3066\u3082\u3044\u3044\u3068\u3044\u3046\u308f\u3051\u3067\u3059\u306d\u3002\u3055\u3059\u304c<code>AWS<\/code>\u3067\u3059\ud83d\udc4d<\/p>\n<h1>\u30c6\u30b9\u30c8\u3057\u3066\u307f\u308b<\/h1>\n<p>\u3067\u306f\u5b9f\u969b\u306b\u30c6\u30b9\u30c8\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u2757<br \/>\n\u30d6\u30e9\u30a6\u30b6\u3067\u300c<strong>https:\/\/*****\/async\/request<\/strong>\u300d\u306b\u30a2\u30af\u30bb\u30b9\u3057\u307e\u3059\u3002<\/p>\n<p>\u3059\u308b\u3068\u30fb\u30fb\u30fb\u30fb\u30fb\u30fb<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-9821\" style=\"border: 3px solid #000;\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2021\/11\/laravel_async_request_1.png\" alt=\"\" width=\"597\" height=\"291\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2021\/11\/laravel_async_request_1.png 597w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2021\/11\/laravel_async_request_1-300x146.png 300w\" sizes=\"auto, (max-width: 597px) 100vw, 597px\" \/><\/p>\n<p>\u5c11\u3057\u308f\u304b\u308a\u306b\u304f\u3067\u3059\u304c\u3001\u307e\u3068\u3081\u308b\u3068\u6b21\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p><strong>\u3010\u5404URL\u304c\u5b8c\u4e86\u3057\u305f\u6642\u9593\u3011<\/strong><\/p>\n<ul>\n<li>1\u3064\u76ee\u306eURL\uff1a \u958b\u59cb\u304b\u3089 \u7d04 1.09 \u79d2\u3067\u5b8c\u4e86<\/li>\n<li>2\u3064\u76ee\u306eURL\uff1a \u958b\u59cb\u304b\u3089 \u7d04 4.08 \u79d2\u3067\u5b8c\u4e86<\/li>\n<li>3\u3064\u76ee\u306eURL\uff1a \u958b\u59cb\u304b\u3089 \u7d04 9.95 \u79d2\u3067\u5b8c\u4e86<\/li>\n<\/ul>\n<p><strong>\u3010\u5168\u3066\u304c\u5b8c\u4e86\u3057\u305f\u6642\u9593\u3011<\/strong><\/p>\n<p>\u7d04<code>9.953<\/code>\u79d2\u3067\u5b8c\u4e86<\/p>\n<p>\u3064\u307e\u308a\u3001\u3072\u3068\u3064\u305a\u3064\u300c<strong>\u30a2\u30af\u30bb\u30b9\uff06\u5f85\u3064<\/strong>\u300d\u3067\u5b9f\u884c\u3059\u308b\u3068\u3057\u305f\u3089\u6700\u4f4e\u3067\u3082\u958b\u59cb\u304b\u3089<code>15<\/code>\u79d2\u306f\u304b\u304b\u308b\u8a08\u7b97\u306b\u306a\u308a\u307e\u3059\u304c\u3001\u975e\u540c\u671f\u901a\u4fe1\u3092\u4f7f\u3063\u305f\u304a\u304b\u3052\u3067<code>9.953<\/code>\u79d2\u3067\u5b8c\u4e86\u3057\u305f\u3068\u3044\u3046\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\u9ad8\u901f\u5316\u3001\u6210\u529f\u3067\u3059 \u2728\ud83d\ude04\ud83d\udc4d<\/p>\n<h1>\u4f01\u696d\u69d8\u3078\u306e\u3054\u63d0\u6848<\/h1>\n<p>\u4eca\u56de\u306e\u975e\u540c\u671f\u901a\u4fe1\u3092\u4f7f\u3046\u3068\u3001<code>AWS<\/code>\u3084<code>Google Cloud<\/code>\u306a\u3069\u306e\u30af\u30e9\u30a6\u30c9\u3078\u306e\u30a2\u30af\u30bb\u30b9\u304c\u91cd\u8907\u3059\u308b\u5834\u5408\u3067\u3082\u6700\u4f4e\u9650\u306e\u6642\u9593\u3067\u5b8c\u4e86\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\u307e\u305f\u3001\u5b9f\u884c\u74b0\u5883\u306e\u5f71\u97ff\u3067\u3069\u3046\u3057\u3066\u3082\u5916\u90e8\u30b5\u30fc\u30d0\u30fc\u304b\u3089\u30c7\u30fc\u30bf\u3092\u53d6\u5f97\u3059\u308b\u5fc5\u8981\u304c\u3042\u308b\u5834\u5408\u3084\u3001\u3044\u304f\u3064\u304b\u306e\u74b0\u5883\u306b\u51e6\u7406\u3092\u5206\u6563\u3059\u308b\u5834\u5408\u306b\u3082\u6709\u52b9\u3067\u3059\u3002<\/p>\n<p>\u3082\u3057\u305d\u3046\u3044\u3063\u305f\u9ad8\u901f\u5316\u3092\u5b9f\u88c5\u3055\u308c\u305f\u3044\u5834\u5408\u306f\u3001\u305c\u3072\u304a\u554f\u3044\u5408\u308f\u305b\u304b\u3089\u3054\u9023\u7d61\u304f\u3060\u3055\u3044\u3002\u304a\u5f85\u3061\u3057\u3066\u304a\u308a\u307e\u3059\u3002\ud83d\ude04\u2728<\/p>\n<h1>\u304a\u308f\u308a\u306b<\/h1>\n<p>\u3068\u3044\u3046\u3053\u3068\u3067\u3001\u4eca\u56de\u306f<code>Laravel + Guzzle<\/code>\u3067\u975e\u540c\u671f\u901a\u4fe1\u3092\u5b9f\u88c5\u3057\u3066\u307f\u307e\u3057\u305f\u3002<\/p>\n<p>\u300c<strong>\u975e\u540c\u671f\u901a\u4fe1<\/strong>\u300d\u3068\u3044\u3046\u8a00\u8449\u304c\u3061\u3087\u3063\u3068\u3053\u3080\u3064\u304b\u3057\u3044\u97ff\u304d\u3067\u3059\u304c\u3001<code>Guzzle<\/code>\u3092\u4f7f\u3048\u3070\u3068\u3066\u3082\u30b7\u30f3\u30d7\u30eb\u306b\u5b9f\u88c5\u3067\u304d\u308b\u3053\u3068\u304c\u5206\u304b\u3063\u3066\u3044\u305f\u3060\u3051\u305f\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<p>\u3061\u306a\u307f\u306b\u3001<code>Guzzle<\/code>\u306f\u3068\u3066\u3082\u3088\u304f\u3067\u304d\u305f\u30d1\u30c3\u30b1\u30fc\u30b8\u306a\u306e\u3067\u30d5\u30a1\u30a4\u30eb\u306e\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9\u3084\u3001\u30d8\u30c3\u30c0\u30fc\u306e\u30bb\u30c3\u30c8\u306a\u3069\u3082\u30b7\u30f3\u30d7\u30eb\u306b\u5b9f\u88c5\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>\u6614\u306e\u3053\u3068\u3092\u8003\u3048\u308b\u3068\u3001\u958b\u767a\u8005\u306b\u611f\u8b1d\u306e\u6c17\u6301\u3061\u3067\u4e00\u676f\u3067\u3059\u306d\u3002<br \/>\n\u307e\u3055\u306b\u300c<strong>You saved my day!<\/strong>\u300d\u3067\u3059\u3002<\/p>\n<p>\u3067\u304d\u305f\u3089\u3001\u79c1\u306e\u30b3\u30fc\u30c9\u3082\u4e16\u306e\u305f\u3081\u306b\u306a\u308c\u3070\u5b09\u3057\u3044\u3067\u3059\u3002<\/p>\n<p>\u3067\u306f\u3067\u306f\u301c\u2757<\/p>\n<p style=\"text-align: center;\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-3344 aligncenter\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/04\/no_22.png\" alt=\"\" width=\"320\" height=\"320\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/04\/no_22.png 320w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/04\/no_22-150x150.png 150w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/04\/no_22-300x300.png 300w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/04\/no_22-100x100.png 100w\" sizes=\"auto, (max-width: 320px) 100vw, 320px\" \/>\u300c\u30e9\u30f3\u30c1\u30a7\u30b9\u30bf\u30fc\u6226\u7565\u306e\u672c\u8cb7\u3044\u307e\u3057\u305f\u3002<br \/>\n\u30aa\u30ea\u30e9\u30b8\u3042\u3063\u3061\u3083\u3093\u306e\u5f71\u97ff\u3067\ud83d\ude02\u300d<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u3055\u3066\u3055\u3066\u3001\u6700\u8fd1\u3067\u306f\u300c\u30af\u30e9\u30a6\u30c9\u300d\u3068\u3044\u3046\u8a00\u8449\u306f\u6280\u8853\u8005\u306a\u3089\u8ab0\u3067\u3082\u77e5\u3063\u3066\u3044\u308b\u3082\u306e\u306b\u306a\u308a\u307e\u3057\u305f\u3002 \u521d\u3081\u3066\u3053\u306e\u8a00\u8449\u3092\u805e\u3044\u305f\u3068\u304d\u306f\u300c\u30af\u30e9\u30a6\u30c9 \u2192 \u96f2 \u2192 \u96e8\u304c\u964d\u308b \u2192 \u3044\u3084\u3001 &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/blog.capilano-fw.com\/?p=9817\" class=\"more-link\"><span class=\"screen-reader-text\">&#8220;\u3010Laravel\u3011PHP\u3067\u975e\u540c\u671f\u901a\u4fe1\u3092\u3059\u308b\uff08Guzzle\u3067\u7c21\u5358\uff01\uff09&#8221; \u306e<\/span>\u7d9a\u304d\u3092\u8aad\u3080<\/a><\/p>\n","protected":false},"author":1,"featured_media":9825,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-9817","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-laravel"],"_links":{"self":[{"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/posts\/9817","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=9817"}],"version-history":[{"count":8,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/posts\/9817\/revisions"}],"predecessor-version":[{"id":9826,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/posts\/9817\/revisions\/9826"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/media\/9825"}],"wp:attachment":[{"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=9817"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=9817"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=9817"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}