Created
July 7, 2017 07:13
-
-
Save ar-android/c5b612c47631216cb0be722ea5640627 to your computer and use it in GitHub Desktop.
Download file using guzzle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Download { | |
public function download($url, $name, $extensions){ | |
$path = __DIR__.'/download/' . $name . $extensions; | |
$file_path = fopen($path,'w'); | |
$client = new \GuzzleHttp\Client(); | |
$response = $client->get($url, ['save_to' => $file_path]); | |
return ['response_code'=>$response->getStatusCode(), 'name' => $name]; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
According to the official Guzzle doc, it seems that the
save_to
request option is deprecated since the6.5+
version has been released, and it should use thesink
option instead.The detailed deprecated message is as follows: