PHP code example of decodelabs / hydro
1. Go to this page and download the library: Download decodelabs/hydro library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
decodelabs / hydro example snippets
use DecodeLabs\Hydro;
$memoryFile = Hydro::get('https://example.com/file.txt'); // Atlas file
$string = Hydro::getString('https://example.com/file.txt'); // String
$file = Hydro::getFile('https://example.com/file.txt', '/path/to/save/file.txt'); // Local file
$tempFile = Hydro::getTempFile('https://example.com/file.txt'); // Temp file
$json = Hydro::getJson('https://example.com/file.json'); // Decoded JSON array
$tree = Hydro::getJsonTree('https://example.com/file.json'); // Decoded JSON Collections/Tree
Hydro::get([
'url' => 'https://example.com/file.txt',
'timeout' => 10
]);
$file = Hydro::get('https://example.com/file.txt', function($response) {
switch($response->getStatusCode()) {
case 404:
throw Exceptional::Notfound('File not found');
case 500:
throw Exceptional::Runtime('Server error');
default:
return Hydro::request('GET', 'https://example.com/other.txt');
}
});