From 54e3e91e90f4a9289588cd1651460c55d8f70125 Mon Sep 17 00:00:00 2001 From: Kevin Roth Date: Mon, 7 Nov 2016 16:39:25 -0600 Subject: [PATCH 1/8] Added a couple wrapper functions for easy fetching of json data or file contents using cache with ttl --- lib/class.cache.php | 46 ++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 41 insertions(+), 5 deletions(-) diff --git a/lib/class.cache.php b/lib/class.cache.php index afdc135..ab95241 100644 --- a/lib/class.cache.php +++ b/lib/class.cache.php @@ -8,17 +8,17 @@ * @license * The MIT License (MIT) * Copyright (c) 2014 Jovanni Lo - * + * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE @@ -34,7 +34,7 @@ * For security reasons, it's *strongly* recommended you set your cache directory to be outside * of your web root and on a drive independent of your operating system. * - * Uses JSON, PHP native serialization and encryption/decryption + * Uses JSON, PHP native serialization and encryption/decryption * * Sample usage: * @@ -247,5 +247,41 @@ private function _make_file_key($key) { '-'), trim($key)); return $this->root.$safe_key.".cache"; } + + /** + * KJR 11/7/2016 - get file or url contents from given path + * @param string $uri The uri of the data we are fetching + * @param int $ttl The amount of time in seconds before cache should expire + * @returns the data or false on failure + */ + public function file_get_contents($uri, $ttl = 3600) { + $cacheFile = md5($uri); + if (!$data = $this->get($cacheFile)) { + // cache did not exist + if ($data = @file_get_contents($uri)) { + //got the data, store it + if (!$this->set($cacheFile, $data, $ttl)) { + return false; + } + } else { + return false; + } + } + return $data; + } + + /** + * KJR 11/7/2016 - get data we know is stored as JSON and decode it + * @param string $uri The uri of the json data we are fetching + * @param int $ttl The amount of time in seconds before cache should expire + * @returns the data or false on failure + */ + public function getJsonData($jsonUri, $ttl = 3600) { + if ($jsonData = $this->file_get_contents($jsonUri, $ttl)) { + //return decoded data + return json_decode($jsonData, true); + } + return false; + } + } -?> \ No newline at end of file From 347625637ec19c541079b3ee3adcaaa42b1c4f34 Mon Sep 17 00:00:00 2001 From: Kevin Roth Date: Mon, 26 Feb 2018 17:11:27 -0600 Subject: [PATCH 2/8] Replaced mcrypt functions with openssl for php 7.1+ --- lib/class.cache.php | 49 +++++++++++++++++++++++++++++++++++---------- 1 file changed, 38 insertions(+), 11 deletions(-) diff --git a/lib/class.cache.php b/lib/class.cache.php index ab95241..15d6fc4 100644 --- a/lib/class.cache.php +++ b/lib/class.cache.php @@ -63,10 +63,16 @@ class Cache { protected $error = null; /** - * The encryption key. This is private! set this inside this class + * The encryption method. This is private! set this inside this class * @var string */ - private $_encryption_key = "Fil3C@ch33ncryptionK3y"; + private $_encryption_method = 'aes-256-cbc'; + + /** + * The encryption key. Must be 32 characters. This is private! set this inside this class + * @var string + */ + private $_encryption_key = 'Z7w@L!r8&1Tgl*KcfD^ViB@xaHYE!sQ@'; /** * @param string $root The root of the file cache. @@ -155,7 +161,7 @@ public function get($key) { if ($file_content) { $store = json_decode($file_content, true); if ($store['ttl'] < time()) { - unlink($key); // remove the file + @unlink($key); // remove the file $this->error = "Data expired"; return false; } else return unserialize($store['data']); @@ -209,10 +215,20 @@ public function have_error() { * @return string decrypted string */ private function _encrypt($pure_string) { - $iv_size = mcrypt_get_iv_size(MCRYPT_BLOWFISH, MCRYPT_MODE_ECB); - $iv = mcrypt_create_iv($iv_size, MCRYPT_RAND); - $encrypted_string = mcrypt_encrypt(MCRYPT_BLOWFISH, $this->_encryption_key, utf8_encode($pure_string), - MCRYPT_MODE_ECB, $iv); + if (phpversion() < 7.1) { + $iv_size = mcrypt_get_iv_size(MCRYPT_BLOWFISH, MCRYPT_MODE_ECB); + $iv = mcrypt_create_iv($iv_size, MCRYPT_RAND); + $encrypted_string = mcrypt_encrypt(MCRYPT_BLOWFISH, $this->_encryption_key, utf8_encode($pure_string), MCRYPT_MODE_ECB, $iv); + } else { + //found here: https://paragonie.com/blog/2015/05/if-you-re-typing-word-mcrypt-into-your-code-you-re-doing-it-wrong + if (mb_strlen($this->_encryption_key, '8bit') !== 32) { + throw new Exception("Needs a 256-bit key!"); + } + $iv_size = openssl_cipher_iv_length($this->_encryption_method); + $iv = openssl_random_pseudo_bytes($iv_size); + $ciphertext = openssl_encrypt($pure_string, $this->_encryption_method, $this->_encryption_key, OPENSSL_RAW_DATA, $iv); + $encrypted_string = $iv.$ciphertext; + } return $encrypted_string; } @@ -222,10 +238,21 @@ private function _encrypt($pure_string) { * @return string decrypted string */ private function _decrypt($encrypted_string) { - $iv_size = mcrypt_get_iv_size(MCRYPT_BLOWFISH, MCRYPT_MODE_ECB); - $iv = mcrypt_create_iv($iv_size, MCRYPT_RAND); - $decrypted_string = mcrypt_decrypt(MCRYPT_BLOWFISH, $this->_encryption_key, $encrypted_string, - MCRYPT_MODE_ECB, $iv); + if (phpversion() < 7.1) { + $iv_size = mcrypt_get_iv_size(MCRYPT_BLOWFISH, MCRYPT_MODE_ECB); + $iv = mcrypt_create_iv($iv_size, MCRYPT_RAND); + $decrypted_string = mcrypt_decrypt(MCRYPT_BLOWFISH, $this->_encryption_key, $encrypted_string, MCRYPT_MODE_ECB, $iv); + } else { + //found here: https://paragonie.com/blog/2015/05/if-you-re-typing-word-mcrypt-into-your-code-you-re-doing-it-wrong + if (mb_strlen($this->_encryption_key, '8bit') !== 32) { + throw new Exception("Needs a 256-bit key!"); + } + $iv_size = openssl_cipher_iv_length($this->_encryption_method); + $iv = mb_substr($encrypted_string, 0, $iv_size, '8bit'); + $ciphertext = mb_substr($encrypted_string, $iv_size, null, '8bit'); + + $decrypted_string = openssl_decrypt($ciphertext, $this->_encryption_method, $this->_encryption_key, OPENSSL_RAW_DATA, $iv); + } return $decrypted_string; } From d5935a4d0da5e37b12bfad810355af2b0503c482 Mon Sep 17 00:00:00 2001 From: Kevin Roth Date: Tue, 12 Jun 2018 10:05:02 -0500 Subject: [PATCH 3/8] Composer integration --- README.md | 62 ++++++++++++++++++++++++++---- composer.json | 28 ++++++++++++++ index.php => example.php | 8 ++-- lib/{class.cache.php => Cache.php} | 5 ++- 4 files changed, 91 insertions(+), 12 deletions(-) create mode 100644 composer.json rename index.php => example.php (72%) rename lib/{class.cache.php => Cache.php} (99%) diff --git a/README.md b/README.md index 394df8e..e21ae73 100644 --- a/README.md +++ b/README.md @@ -3,22 +3,57 @@ PHP Cache Class (File base) A simple file based cache based from Erik Giberti's FileCache class. See [here](http://af-design.com/blog/2010/07/30/simple-file-based-caching-in-php/) ## Enhanced Features + * Data is serialized and JSON encoded * Cache data is encrypted by `mcrypt` * File Based Cache was explained [here](http://af-design.com/blog/2010/07/30/simple-file-based-caching-in-php/) ## Installation + +Run the following command in your command line shell in your php project + +```sh +$ composer require rothkj1022/php-cache-class +``` + +Done. + +You may also edit composer.json manually then perform ```composer update```: + +``` +"require": { + "rothkj1022/php-cache-class": "^2.1.0" +} +``` + +## Getting started + +### Example usage with composer + +```php +//load composer packages +require('vendor/autoload.php'); + +//create new instance of the class +use rothkj1022\Cache; +$cache = new Cache\Cache("tmp/"); +``` + +### Example usage without composer + ```php //require the class -require_once("lib/class.cache.php"); +require_once("lib/Cache.php"); //create new instance of the class -$cache = new Cache("tmp/"); +use rothkj1022\Cache; +$cache = new Cache\Cache("tmp/"); //... ``` ## Sample Call + ```php $cache_key = "client_list"; @@ -29,22 +64,26 @@ if (!$clients_data = $cache->get($cache_key)) { //set the cache up! $expire = 3600; //1 hour - $cache->set($cache_key, $clients_data, $expire); + $cache->set($cache_key, $clients_data, $expire); } var_dump($clients_data); ``` ## Reference + Code reference for you to get started! ### Properties + * `protected $root = '/tmp/';` - Value is pre-pended to the cache, should be the full path to the directory. * `protected $error = null;` - For holding any error messages that may have been raised * `private $_encryption_key = 'Fil3C@ch33ncryptionK3y'` - Main key used for encryption (you need to set this up inside the class) ### Methods + #### Public Methods + * `Cache::get($key)` - Reads the data from the cache specified by the cache key * `Cache::set($key [, $data, $ttl])` - Saves data to the cache. Anything that evaluates to false, null, '', boolean false, 0 will not be saved. `$ttl` Specifies the expiry time * `Cache::delete($key)` - Deletes the cache specified by the `$key` @@ -52,14 +91,23 @@ Code reference for you to get started! * `Cache::have_error()` - Can be used to inspect internal error #### Private Methods -See code to see all private methods used like `Cahce::_encrypt($pure_string)` etc. -## Feedback -All bugs, feature requests, pull requests, feedback, etc., are welcome. Visit my site at [www.lodev09.com](http://www.lodev09.com "www.lodev09.com") or email me at [lodev09@gmail.com](mailto:lodev09@gmail.com) +See code to see all private methods used like `Cache::_encrypt($pure_string)` etc. + +## Changelog + +### Version 2.1.0 + +* Added: Composer integration +* Added: changelog ## Credits -© 2011-2014 - Coded by Jovanni Lo / [@lodev09](http://twitter.com/lodev09) + +2010 - Authored by Erik Giberti +2011-2014 - Rewritten by Jovanni Lo / [@lodev09](https://twitter.com/lodev09) +2018 - Modified by Kevin Roth / [@rothkj1022](https://twitter.com/rothkj1022) ## License + Released under the [MIT License](http://opensource.org/licenses/MIT). See [LICENSE](LICENSE) file. diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..7cf3c6c --- /dev/null +++ b/composer.json @@ -0,0 +1,28 @@ +{ + "name": "rothkj1022/php-cache-class", + "description": "A simple file based cache based from Erik Giberti's FileCache class, forked from lodev09/php-cache-class.", + "type": "library", + "license": "MIT", + "authors": [ + { + "name": "Erik Giberti" + }, + { + "name": "Jovanni Lo", + "email": "lodev09@gmail.com", + "homepage": "http://www.lodev09.com/" + }, + { + "name": "Kevin Roth", + "homepage": "https://kevinroth.com/" + } + ], + "require": { + "php": "^5.2 || ^7.0" + }, + "autoload": { + "psr-4": { + "rothkj1022\\Cache\\": "lib" + } + } +} diff --git a/index.php b/example.php similarity index 72% rename from index.php rename to example.php index 9e00fec..50f21a1 100644 --- a/index.php +++ b/example.php @@ -1,10 +1,11 @@ set($cache_key, $clients_data, $expire); + $cache->set($cache_key, $clients_data, $expire); } var_dump($clients_data); -?> diff --git a/lib/class.cache.php b/lib/Cache.php similarity index 99% rename from lib/class.cache.php rename to lib/Cache.php index 15d6fc4..d516c01 100644 --- a/lib/class.cache.php +++ b/lib/Cache.php @@ -1,9 +1,12 @@ _encryption_method); $iv = mb_substr($encrypted_string, 0, $iv_size, '8bit'); $ciphertext = mb_substr($encrypted_string, $iv_size, null, '8bit'); - + $decrypted_string = openssl_decrypt($ciphertext, $this->_encryption_method, $this->_encryption_key, OPENSSL_RAW_DATA, $iv); } return $decrypted_string; From e96cc7eb2c7520557aefd59277ae6e02225a410f Mon Sep 17 00:00:00 2001 From: Kevin Roth Date: Tue, 12 Jun 2018 10:38:21 -0500 Subject: [PATCH 4/8] Renamed class Renamed class back to Erik Giberti's original name, FileCache --- README.md | 16 ++++++++++------ composer.json | 2 +- example.php | 6 +++--- lib/{Cache.php => FileCache.php} | 8 ++++---- tmp/index.html | 11 +++++++++++ 5 files changed, 29 insertions(+), 14 deletions(-) rename lib/{Cache.php => FileCache.php} (97%) create mode 100644 tmp/index.html diff --git a/README.md b/README.md index e21ae73..4f4bc79 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -PHP Cache Class (File base) +PHP FileCache Class (File base) ============================ A simple file based cache based from Erik Giberti's FileCache class. See [here](http://af-design.com/blog/2010/07/30/simple-file-based-caching-in-php/) @@ -35,19 +35,19 @@ You may also edit composer.json manually then perform ```composer update```: require('vendor/autoload.php'); //create new instance of the class -use rothkj1022\Cache; -$cache = new Cache\Cache("tmp/"); +use rothkj1022\FileCache; +$cache = new FileCache\FileCache("tmp/"); ``` ### Example usage without composer ```php //require the class -require_once("lib/Cache.php"); +require_once("lib/FileCache.php"); //create new instance of the class -use rothkj1022\Cache; -$cache = new Cache\Cache("tmp/"); +use rothkj1022\FileCache; +$cache = new FileCache\FileCache("tmp/"); //... ``` @@ -96,6 +96,10 @@ See code to see all private methods used like `Cache::_encrypt($pure_string)` et ## Changelog +### Version 2.1.1 + +* Changed: Renamed class back to Erik Giberti's original name, FileCache + ### Version 2.1.0 * Added: Composer integration diff --git a/composer.json b/composer.json index 7cf3c6c..5356630 100644 --- a/composer.json +++ b/composer.json @@ -22,7 +22,7 @@ }, "autoload": { "psr-4": { - "rothkj1022\\Cache\\": "lib" + "rothkj1022\\FileCache\\": "lib" } } } diff --git a/example.php b/example.php index 50f21a1..6e50fee 100644 --- a/example.php +++ b/example.php @@ -1,11 +1,11 @@ root = $root; // Requires the native JSON library if (!function_exists('json_decode') || !function_exists('json_encode')) { - throw new Exception('Cache needs the JSON PHP extensions.'); + throw new Exception('FileCache needs the JSON PHP extensions.'); } } diff --git a/tmp/index.html b/tmp/index.html new file mode 100644 index 0000000..b702fbc --- /dev/null +++ b/tmp/index.html @@ -0,0 +1,11 @@ + + + + 403 Forbidden + + + +

Directory access is forbidden.

+ + + From 98499d5ce25d101fce006417472049a3a2a9bfcf Mon Sep 17 00:00:00 2001 From: Kevin Roth Date: Mon, 18 Jun 2018 15:34:52 -0500 Subject: [PATCH 5/8] Guzzle integration --- .gitattributes | 22 -- .gitignore | 215 +------------------- README.md | 13 +- composer.json | 3 +- composer.lock | 251 +++++++++++++++++++++++ example.php | 8 +- lib/FileCache.php | 498 ++++++++++++++++++++++++---------------------- 7 files changed, 534 insertions(+), 476 deletions(-) delete mode 100644 .gitattributes create mode 100644 composer.lock diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 412eeda..0000000 --- a/.gitattributes +++ /dev/null @@ -1,22 +0,0 @@ -# Auto detect text files and perform LF normalization -* text=auto - -# Custom for Visual Studio -*.cs diff=csharp -*.sln merge=union -*.csproj merge=union -*.vbproj merge=union -*.fsproj merge=union -*.dbproj merge=union - -# Standard to msysgit -*.doc diff=astextplain -*.DOC diff=astextplain -*.docx diff=astextplain -*.DOCX diff=astextplain -*.dot diff=astextplain -*.DOT diff=astextplain -*.pdf diff=astextplain -*.PDF diff=astextplain -*.rtf diff=astextplain -*.RTF diff=astextplain diff --git a/.gitignore b/.gitignore index b9d6bd9..9d33e8e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,215 +1,2 @@ -################# -## Eclipse -################# - -*.pydevproject -.project -.metadata -bin/ tmp/ -*.tmp -*.bak -*.swp -*~.nib -local.properties -.classpath -.settings/ -.loadpath - -# External tool builders -.externalToolBuilders/ - -# Locally stored "Eclipse launch configurations" -*.launch - -# CDT-specific -.cproject - -# PDT-specific -.buildpath - - -################# -## Visual Studio -################# - -## Ignore Visual Studio temporary files, build results, and -## files generated by popular Visual Studio add-ons. - -# User-specific files -*.suo -*.user -*.sln.docstates - -# Build results - -[Dd]ebug/ -[Rr]elease/ -x64/ -build/ -[Bb]in/ -[Oo]bj/ - -# MSTest test Results -[Tt]est[Rr]esult*/ -[Bb]uild[Ll]og.* - -*_i.c -*_p.c -*.ilk -*.meta -*.obj -*.pch -*.pdb -*.pgc -*.pgd -*.rsp -*.sbr -*.tlb -*.tli -*.tlh -*.tmp -*.tmp_proj -*.log -*.vspscc -*.vssscc -.builds -*.pidb -*.log -*.scc - -# Visual C++ cache files -ipch/ -*.aps -*.ncb -*.opensdf -*.sdf -*.cachefile - -# Visual Studio profiler -*.psess -*.vsp -*.vspx - -# Guidance Automation Toolkit -*.gpState - -# ReSharper is a .NET coding add-in -_ReSharper*/ -*.[Rr]e[Ss]harper - -# TeamCity is a build add-in -_TeamCity* - -# DotCover is a Code Coverage Tool -*.dotCover - -# NCrunch -*.ncrunch* -.*crunch*.local.xml - -# Installshield output folder -[Ee]xpress/ - -# DocProject is a documentation generator add-in -DocProject/buildhelp/ -DocProject/Help/*.HxT -DocProject/Help/*.HxC -DocProject/Help/*.hhc -DocProject/Help/*.hhk -DocProject/Help/*.hhp -DocProject/Help/Html2 -DocProject/Help/html - -# Click-Once directory -publish/ - -# Publish Web Output -*.Publish.xml -*.pubxml - -# NuGet Packages Directory -## TODO: If you have NuGet Package Restore enabled, uncomment the next line -#packages/ - -# Windows Azure Build Output -csx -*.build.csdef - -# Windows Store app package directory -AppPackages/ - -# Others -sql/ -*.Cache -ClientBin/ -[Ss]tyle[Cc]op.* -~$* -*~ -*.dbmdl -*.[Pp]ublish.xml -*.pfx -*.publishsettings - -# RIA/Silverlight projects -Generated_Code/ - -# Backup & report files from converting an old project file to a newer -# Visual Studio version. Backup files are not needed, because we have git ;-) -_UpgradeReport_Files/ -Backup*/ -UpgradeLog*.XML -UpgradeLog*.htm - -# SQL Server files -App_Data/*.mdf -App_Data/*.ldf - -############# -## Windows detritus -############# - -# Windows image file caches -Thumbs.db -ehthumbs.db - -# Folder config file -Desktop.ini - -# Recycle Bin used on file shares -$RECYCLE.BIN/ - -# Mac crap -.DS_Store - - -############# -## Python -############# - -*.py[co] - -# Packages -*.egg -*.egg-info -dist/ -build/ -eggs/ -parts/ -var/ -sdist/ -develop-eggs/ -.installed.cfg - -# Installer logs -pip-log.txt - -# Unit test / coverage reports -.coverage -.tox - -#Translations -*.mo - -#Mr Developer -.mr.developer.cfg +vendor/ diff --git a/README.md b/README.md index 4f4bc79..636ea7d 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ $cache = new FileCache\FileCache("tmp/"); //... ``` -## Sample Call +### Local file source example ```php $cache_key = "client_list"; @@ -70,6 +70,13 @@ if (!$clients_data = $cache->get($cache_key)) { var_dump($clients_data); ``` +### External http GET request example +```php +$uri = 'https://raw.githubusercontent.com/bahamas10/css-color-names/master/css-color-names.json'; +$remote_data = $cache->file_get_contents($uri); +var_dump($remote_data); +``` + ## Reference Code reference for you to get started! @@ -96,6 +103,10 @@ See code to see all private methods used like `Cache::_encrypt($pure_string)` et ## Changelog +### Version 2.1.2 + +* Integrated guzzle for more efficient http get requests + ### Version 2.1.1 * Changed: Renamed class back to Erik Giberti's original name, FileCache diff --git a/composer.json b/composer.json index 5356630..96025c9 100644 --- a/composer.json +++ b/composer.json @@ -18,7 +18,8 @@ } ], "require": { - "php": "^5.2 || ^7.0" + "php": "^5.2 || ^7.0", + "guzzlehttp/guzzle": "^6.3" }, "autoload": { "psr-4": { diff --git a/composer.lock b/composer.lock new file mode 100644 index 0000000..69eb257 --- /dev/null +++ b/composer.lock @@ -0,0 +1,251 @@ +{ + "_readme": [ + "This file locks the dependencies of your project to a known state", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", + "This file is @generated automatically" + ], + "content-hash": "9bcd19454eb94e38ae687f59f796c211", + "packages": [ + { + "name": "guzzlehttp/guzzle", + "version": "6.3.3", + "source": { + "type": "git", + "url": "https://github.com/guzzle/guzzle.git", + "reference": "407b0cb880ace85c9b63c5f9551db498cb2d50ba" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/guzzle/guzzle/zipball/407b0cb880ace85c9b63c5f9551db498cb2d50ba", + "reference": "407b0cb880ace85c9b63c5f9551db498cb2d50ba", + "shasum": "" + }, + "require": { + "guzzlehttp/promises": "^1.0", + "guzzlehttp/psr7": "^1.4", + "php": ">=5.5" + }, + "require-dev": { + "ext-curl": "*", + "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.4 || ^7.0", + "psr/log": "^1.0" + }, + "suggest": { + "psr/log": "Required for using the Log middleware" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "6.3-dev" + } + }, + "autoload": { + "files": [ + "src/functions_include.php" + ], + "psr-4": { + "GuzzleHttp\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Michael Dowling", + "email": "mtdowling@gmail.com", + "homepage": "https://github.com/mtdowling" + } + ], + "description": "Guzzle is a PHP HTTP client library", + "homepage": "http://guzzlephp.org/", + "keywords": [ + "client", + "curl", + "framework", + "http", + "http client", + "rest", + "web service" + ], + "time": "2018-04-22T15:46:56+00:00" + }, + { + "name": "guzzlehttp/promises", + "version": "v1.3.1", + "source": { + "type": "git", + "url": "https://github.com/guzzle/promises.git", + "reference": "a59da6cf61d80060647ff4d3eb2c03a2bc694646" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/guzzle/promises/zipball/a59da6cf61d80060647ff4d3eb2c03a2bc694646", + "reference": "a59da6cf61d80060647ff4d3eb2c03a2bc694646", + "shasum": "" + }, + "require": { + "php": ">=5.5.0" + }, + "require-dev": { + "phpunit/phpunit": "^4.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.4-dev" + } + }, + "autoload": { + "psr-4": { + "GuzzleHttp\\Promise\\": "src/" + }, + "files": [ + "src/functions_include.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Michael Dowling", + "email": "mtdowling@gmail.com", + "homepage": "https://github.com/mtdowling" + } + ], + "description": "Guzzle promises library", + "keywords": [ + "promise" + ], + "time": "2016-12-20T10:07:11+00:00" + }, + { + "name": "guzzlehttp/psr7", + "version": "1.4.2", + "source": { + "type": "git", + "url": "https://github.com/guzzle/psr7.git", + "reference": "f5b8a8512e2b58b0071a7280e39f14f72e05d87c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/guzzle/psr7/zipball/f5b8a8512e2b58b0071a7280e39f14f72e05d87c", + "reference": "f5b8a8512e2b58b0071a7280e39f14f72e05d87c", + "shasum": "" + }, + "require": { + "php": ">=5.4.0", + "psr/http-message": "~1.0" + }, + "provide": { + "psr/http-message-implementation": "1.0" + }, + "require-dev": { + "phpunit/phpunit": "~4.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.4-dev" + } + }, + "autoload": { + "psr-4": { + "GuzzleHttp\\Psr7\\": "src/" + }, + "files": [ + "src/functions_include.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Michael Dowling", + "email": "mtdowling@gmail.com", + "homepage": "https://github.com/mtdowling" + }, + { + "name": "Tobias Schultze", + "homepage": "https://github.com/Tobion" + } + ], + "description": "PSR-7 message implementation that also provides common utility methods", + "keywords": [ + "http", + "message", + "request", + "response", + "stream", + "uri", + "url" + ], + "time": "2017-03-20T17:10:46+00:00" + }, + { + "name": "psr/http-message", + "version": "1.0.1", + "source": { + "type": "git", + "url": "https://github.com/php-fig/http-message.git", + "reference": "f6561bf28d520154e4b0ec72be95418abe6d9363" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/http-message/zipball/f6561bf28d520154e4b0ec72be95418abe6d9363", + "reference": "f6561bf28d520154e4b0ec72be95418abe6d9363", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Http\\Message\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Common interface for HTTP messages", + "homepage": "https://github.com/php-fig/http-message", + "keywords": [ + "http", + "http-message", + "psr", + "psr-7", + "request", + "response" + ], + "time": "2016-08-06T14:39:51+00:00" + } + ], + "packages-dev": [], + "aliases": [], + "minimum-stability": "stable", + "stability-flags": [], + "prefer-stable": false, + "prefer-lowest": false, + "platform": { + "php": "^5.2 || ^7.0" + }, + "platform-dev": [] +} diff --git a/example.php b/example.php index 6e50fee..60c80a9 100644 --- a/example.php +++ b/example.php @@ -1,4 +1,6 @@ set($cache_key, $clients_data, $expire); } - var_dump($clients_data); + +//get external url, and cache the contents +$uri = 'https://raw.githubusercontent.com/bahamas10/css-color-names/master/css-color-names.json'; +$remote_data = $cache->file_get_contents($uri); +var_dump($remote_data); diff --git a/lib/FileCache.php b/lib/FileCache.php index 20b9a82..e5b3f88 100644 --- a/lib/FileCache.php +++ b/lib/FileCache.php @@ -53,265 +53,289 @@ class FileCache { - /** - * Value is pre-pended to the cache, should be the full path to the directory - * @var string - */ - protected $root = '/tmp/'; + /** + * Value is pre-pended to the cache, should be the full path to the directory + * @var string + */ + protected $root = '/tmp/'; - /** - * For holding any error messages that may have been raised - * @var string - */ - protected $error = null; + /** + * For holding any error messages that may have been raised + * @var string + */ + protected $error = null; - /** - * The encryption method. This is private! set this inside this class - * @var string - */ - private $_encryption_method = 'aes-256-cbc'; + /** + * The encryption method. This is private! set this inside this class + * @var string + */ + private $_encryption_method = 'aes-256-cbc'; - /** - * The encryption key. Must be 32 characters. This is private! set this inside this class - * @var string - */ - private $_encryption_key = 'Z7w@L!r8&1Tgl*KcfD^ViB@xaHYE!sQ@'; + /** + * The encryption key. Must be 32 characters. This is private! set this inside this class + * @var string + */ + private $_encryption_key = 'Z7w@L!r8&1Tgl*KcfD^ViB@xaHYE!sQ@'; - /** - * @param string $root The root of the file cache. - */ - function __construct($root = '/tmp/') { - $this->root = $root; - // Requires the native JSON library - if (!function_exists('json_decode') || !function_exists('json_encode')) { - throw new Exception('FileCache needs the JSON PHP extensions.'); - } - } + /** + * @param string $root The root of the file cache. + */ + function __construct($root = '/tmp/') { + $this->root = $root; + // Requires the native JSON library + if (!function_exists('json_decode') || !function_exists('json_encode')) { + throw new Exception('FileCache needs the JSON PHP extensions.'); + } + } - /** - * Saves data to the cache. Anything that evaluates to false, null, '', boolean false, 0 will - * not be saved. - * @param string $key An identifier for the data - * @param mixed $data The data to save - * @param int $ttl Seconds to store the data - * @returns boolean True if the save was successful, false if it failed - */ - public function set($key, $data = false, $ttl = 3600) { - if (!$key) { - $this->error = "Invalid key"; - return false; - } - if (!$data) { - $this->error = "Invalid data"; - return false; - } + /** + * Saves data to the cache. Anything that evaluates to false, null, '', boolean false, 0 will + * not be saved. + * @param string $key An identifier for the data + * @param mixed $data The data to save + * @param int $ttl Seconds to store the data + * @returns boolean True if the save was successful, false if it failed + */ + public function set($key, $data = false, $ttl = 3600) { + if (!$key) { + $this->error = "Invalid key"; + return false; + } + if (!$data) { + $this->error = "Invalid data"; + return false; + } - $key = $this->_make_file_key($key); - $store = array( - 'data' => serialize($data), - 'ttl' => time() + $ttl, - ); - $status = false; - try { - $fh = fopen($key, "w+"); - if (flock($fh, LOCK_EX)) { - ftruncate($fh, 0); - fwrite($fh, $this->_encrypt(json_encode($store))); - flock($fh, LOCK_UN); - $status = true; - } - fclose($fh); - } - catch (exception $e) { - $this->error = "Exception caught: ".$e->getMessage(); - return false; - } - return $status; - } + $key = $this->_make_file_key($key); + $store = array( + 'data' => serialize($data), + 'ttl' => time() + $ttl, + ); + $status = false; + try { + $fh = fopen($key, "w+"); + if (flock($fh, LOCK_EX)) { + ftruncate($fh, 0); + fwrite($fh, $this->_encrypt(json_encode($store))); + flock($fh, LOCK_UN); + $status = true; + } + fclose($fh); + } + catch (exception $e) { + $this->error = "Exception caught: ".$e->getMessage(); + return false; + } + return $status; + } - /** - * Reads the data from the cache - * @param string $key An identifier for the data - * @returns mixed Data that was stored - */ - public function get($key) { - if (!$key) { - $this->error = "Invalid key"; - return false; - } + /** + * Reads the data from the cache + * @param string $key An identifier for the data + * @returns mixed Data that was stored + */ + public function get($key) { + if (!$key) { + $this->error = "Invalid key"; + return false; + } - $key = $this->_make_file_key($key); - $file_content = null; + $key = $this->_make_file_key($key); + $file_content = null; - if (file_exists($key) !== true) { - return false; - } + if (file_exists($key) !== true) { + return false; + } - // Get the data from the file - try { - $fh = fopen($key, "r"); - if (flock($fh, LOCK_SH)) { - $file_content = trim($this->_decrypt(fread($fh, filesize($key)))); - } - fclose($fh); - } - catch (exception $e) { - $this->error = "Exception caught: ".$e->getMessage(); - return false; - } + // Get the data from the file + try { + $fh = fopen($key, "r"); + if (flock($fh, LOCK_SH)) { + $file_content = trim($this->_decrypt(fread($fh, filesize($key)))); + } + fclose($fh); + } + catch (exception $e) { + $this->error = "Exception caught: ".$e->getMessage(); + return false; + } - // Assuming we got something back... - if ($file_content) { - $store = json_decode($file_content, true); - if ($store['ttl'] < time()) { - @unlink($key); // remove the file - $this->error = "Data expired"; - return false; - } else return unserialize($store['data']); - } else return false; - } + // Assuming we got something back... + if ($file_content) { + $store = json_decode($file_content, true); + if ($store['ttl'] < time()) { + @unlink($key); // remove the file + $this->error = "Data expired"; + return false; + } else return unserialize($store['data']); + } else return false; + } - /** - * Remove a key, regardless of it's expire time - * @param string $key An identifier for the data - */ - public function delete($key) { - if (!$key) { - $this->error = "Invalid key"; - return false; - } + /** + * Remove a key, regardless of it's expire time + * @param string $key An identifier for the data + */ + public function delete($key) { + if (!$key) { + $this->error = "Invalid key"; + return false; + } - $key = $this->_make_file_key($key); + $key = $this->_make_file_key($key); - try { - unlink($key); // remove the file - } - catch (exception $e) { - $this->error = "Exception caught: ".$e->getMessage(); - return false; - } + try { + unlink($key); // remove the file + } + catch (exception $e) { + $this->error = "Exception caught: ".$e->getMessage(); + return false; + } - return true; - } + return true; + } - /** - * Reads and clears the internal error - * @returns string Text of the error raised by the last process - */ - public function get_error() { - $message = $this->error; - $this->error = null; - return $message; - } + /** + * Reads and clears the internal error + * @returns string Text of the error raised by the last process + */ + public function get_error() { + $message = $this->error; + $this->error = null; + return $message; + } - /** - * Can be used to inspect internal error - * @returns boolean True if we have an error, false if we don't - */ - public function have_error() { - return ($this->error !== null) ? true : false; - } + /** + * Can be used to inspect internal error + * @returns boolean True if we have an error, false if we don't + */ + public function have_error() { + return ($this->error !== null) ? true : false; + } - /** - * returns an encrypted string - * @param string $pure_string source string to encrypt - * @return string decrypted string - */ - private function _encrypt($pure_string) { - if (phpversion() < 7.1) { - $iv_size = mcrypt_get_iv_size(MCRYPT_BLOWFISH, MCRYPT_MODE_ECB); - $iv = mcrypt_create_iv($iv_size, MCRYPT_RAND); - $encrypted_string = mcrypt_encrypt(MCRYPT_BLOWFISH, $this->_encryption_key, utf8_encode($pure_string), MCRYPT_MODE_ECB, $iv); - } else { - //found here: https://paragonie.com/blog/2015/05/if-you-re-typing-word-mcrypt-into-your-code-you-re-doing-it-wrong - if (mb_strlen($this->_encryption_key, '8bit') !== 32) { - throw new Exception("Needs a 256-bit key!"); - } - $iv_size = openssl_cipher_iv_length($this->_encryption_method); - $iv = openssl_random_pseudo_bytes($iv_size); - $ciphertext = openssl_encrypt($pure_string, $this->_encryption_method, $this->_encryption_key, OPENSSL_RAW_DATA, $iv); - $encrypted_string = $iv.$ciphertext; - } - return $encrypted_string; - } + /** + * returns an encrypted string + * @param string $pure_string source string to encrypt + * @return string decrypted string + */ + private function _encrypt($pure_string) { + if (phpversion() < 7.1) { + $iv_size = mcrypt_get_iv_size(MCRYPT_BLOWFISH, MCRYPT_MODE_ECB); + $iv = mcrypt_create_iv($iv_size, MCRYPT_RAND); + $encrypted_string = mcrypt_encrypt(MCRYPT_BLOWFISH, $this->_encryption_key, utf8_encode($pure_string), MCRYPT_MODE_ECB, $iv); + } else { + //found here: https://paragonie.com/blog/2015/05/if-you-re-typing-word-mcrypt-into-your-code-you-re-doing-it-wrong + if (mb_strlen($this->_encryption_key, '8bit') !== 32) { + throw new Exception("Needs a 256-bit key!"); + } + $iv_size = openssl_cipher_iv_length($this->_encryption_method); + $iv = openssl_random_pseudo_bytes($iv_size); + $ciphertext = openssl_encrypt($pure_string, $this->_encryption_method, $this->_encryption_key, OPENSSL_RAW_DATA, $iv); + $encrypted_string = $iv.$ciphertext; + } + return $encrypted_string; + } - /** - * returns a decrypted string - * @param string $encrypted_string ecrypted string - * @return string decrypted string - */ - private function _decrypt($encrypted_string) { - if (phpversion() < 7.1) { - $iv_size = mcrypt_get_iv_size(MCRYPT_BLOWFISH, MCRYPT_MODE_ECB); - $iv = mcrypt_create_iv($iv_size, MCRYPT_RAND); - $decrypted_string = mcrypt_decrypt(MCRYPT_BLOWFISH, $this->_encryption_key, $encrypted_string, MCRYPT_MODE_ECB, $iv); - } else { - //found here: https://paragonie.com/blog/2015/05/if-you-re-typing-word-mcrypt-into-your-code-you-re-doing-it-wrong - if (mb_strlen($this->_encryption_key, '8bit') !== 32) { - throw new Exception("Needs a 256-bit key!"); - } - $iv_size = openssl_cipher_iv_length($this->_encryption_method); - $iv = mb_substr($encrypted_string, 0, $iv_size, '8bit'); - $ciphertext = mb_substr($encrypted_string, $iv_size, null, '8bit'); + /** + * returns a decrypted string + * @param string $encrypted_string ecrypted string + * @return string decrypted string + */ + private function _decrypt($encrypted_string) { + if (phpversion() < 7.1) { + $iv_size = mcrypt_get_iv_size(MCRYPT_BLOWFISH, MCRYPT_MODE_ECB); + $iv = mcrypt_create_iv($iv_size, MCRYPT_RAND); + $decrypted_string = mcrypt_decrypt(MCRYPT_BLOWFISH, $this->_encryption_key, $encrypted_string, MCRYPT_MODE_ECB, $iv); + } else { + //found here: https://paragonie.com/blog/2015/05/if-you-re-typing-word-mcrypt-into-your-code-you-re-doing-it-wrong + if (mb_strlen($this->_encryption_key, '8bit') !== 32) { + throw new Exception("Needs a 256-bit key!"); + } + $iv_size = openssl_cipher_iv_length($this->_encryption_method); + $iv = mb_substr($encrypted_string, 0, $iv_size, '8bit'); + $ciphertext = mb_substr($encrypted_string, $iv_size, null, '8bit'); - $decrypted_string = openssl_decrypt($ciphertext, $this->_encryption_method, $this->_encryption_key, OPENSSL_RAW_DATA, $iv); - } - return $decrypted_string; - } + $decrypted_string = openssl_decrypt($ciphertext, $this->_encryption_method, $this->_encryption_key, OPENSSL_RAW_DATA, $iv); + } + return $decrypted_string; + } - /** - * Create a key for the cache - * @todo Beef up the cleansing of the file. - * @param string $key The key to create - * @returns string The full path and filename to access - */ - private function _make_file_key($key) { - $safe_key = str_replace(array( - '.', - '/', - ':', - '\''), array( - '_', - '-', - '-', - '-'), trim($key)); - return $this->root.$safe_key.".cache"; - } + /** + * Create a key for the cache + * @todo Beef up the cleansing of the file. + * @param string $key The key to create + * @returns string The full path and filename to access + */ + private function _make_file_key($key) { + $safe_key = str_replace(array( + '.', + '/', + ':', + '\''), array( + '_', + '-', + '-', + '-'), trim($key)); + return $this->root.$safe_key.".cache"; + } - /** - * KJR 11/7/2016 - get file or url contents from given path - * @param string $uri The uri of the data we are fetching - * @param int $ttl The amount of time in seconds before cache should expire - * @returns the data or false on failure - */ - public function file_get_contents($uri, $ttl = 3600) { - $cacheFile = md5($uri); - if (!$data = $this->get($cacheFile)) { - // cache did not exist - if ($data = @file_get_contents($uri)) { - //got the data, store it - if (!$this->set($cacheFile, $data, $ttl)) { - return false; - } - } else { - return false; - } - } - return $data; - } + /** + * KJR 11/7/2016 - get file or url contents from given path + * @param string $uri The uri of the data we are fetching + * @param int $ttl The amount of time in seconds before cache should expire + * @returns the data or false on failure + */ + public function file_get_contents($uri, $ttl = 3600) { + $cacheFile = md5($uri); + if (!$data = $this->get($cacheFile)) { + // cache did not exist + $data = ((is_file($uri)) ? file_get_contents($uri) : $this->file_get_contents_remote($uri)); + if ($data) { + //got the data, store it + if (!$this->set($cacheFile, $data, $ttl)) { + return false; + } + } else { + return false; + } - /** - * KJR 11/7/2016 - get data we know is stored as JSON and decode it - * @param string $uri The uri of the json data we are fetching - * @param int $ttl The amount of time in seconds before cache should expire - * @returns the data or false on failure - */ - public function getJsonData($jsonUri, $ttl = 3600) { - if ($jsonData = $this->file_get_contents($jsonUri, $ttl)) { - //return decoded data - return json_decode($jsonData, true); - } - return false; - } + } + return $data; + } + + // get remote file contents + private function file_get_contents_remote($uri) { + //use guzzle to handle request + $client = new \GuzzleHttp\Client(); + $requestOptions = [ 'verify' => false ]; // accommodates self-signed certs + + try { + $response = $client->request('GET', $uri, $requestOptions); + if (in_array($response->getStatusCode(), array(200, 206))) { + $body = $response->getBody(); + return (string)$body; + } + } catch (\Exception $e) { + $exceptionType = get_class($e); + $errorMsg = $exceptionType; + $request = $e->getRequest(); + $requestMsg = \GuzzleHttp\Psr7\str($request); + echo 'Error getting content from: '.$uri.'. Request: '.$requestMsg; + } + return false; + } + + /** + * KJR 11/7/2016 - get data we know is stored as JSON and decode it + * @param string $uri The uri of the json data we are fetching + * @param int $ttl The amount of time in seconds before cache should expire + * @returns the data or false on failure + */ + public function getJsonData($jsonUri, $ttl = 3600) { + if ($jsonData = $this->file_get_contents($jsonUri, $ttl)) { + //return decoded data + return json_decode($jsonData, true); + } + return false; + } } From 006a52dd7aff9a1fdfc0cc2b902e9e89277eb1e1 Mon Sep 17 00:00:00 2001 From: Kevin Roth Date: Tue, 3 Jul 2018 15:25:09 -0500 Subject: [PATCH 6/8] Mute guzzle errors --- README.md | 4 ++++ lib/FileCache.php | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 636ea7d..5c5f063 100644 --- a/README.md +++ b/README.md @@ -103,6 +103,10 @@ See code to see all private methods used like `Cache::_encrypt($pure_string)` et ## Changelog +### Version 2.1.3 + +* Fixed: Stopped echoing guzzle request errors to screen + ### Version 2.1.2 * Integrated guzzle for more efficient http get requests diff --git a/lib/FileCache.php b/lib/FileCache.php index e5b3f88..c033685 100644 --- a/lib/FileCache.php +++ b/lib/FileCache.php @@ -319,7 +319,7 @@ private function file_get_contents_remote($uri) { $errorMsg = $exceptionType; $request = $e->getRequest(); $requestMsg = \GuzzleHttp\Psr7\str($request); - echo 'Error getting content from: '.$uri.'. Request: '.$requestMsg; + //return 'Error getting content from: '.$uri.'. Request: '.$requestMsg; } return false; } From af00c72bebcb24519fdf9ff8972f8022334437da Mon Sep 17 00:00:00 2001 From: Kevin Roth Date: Fri, 17 Dec 2021 10:44:01 -0600 Subject: [PATCH 7/8] Release 2.1.4 --- .gitignore | 1 + composer.json | 18 ++-- composer.lock | 251 -------------------------------------------------- 3 files changed, 10 insertions(+), 260 deletions(-) delete mode 100644 composer.lock diff --git a/.gitignore b/.gitignore index 9d33e8e..3b726a4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ tmp/ vendor/ +composer.lock diff --git a/composer.json b/composer.json index 96025c9..5fc607b 100644 --- a/composer.json +++ b/composer.json @@ -8,18 +8,18 @@ "name": "Erik Giberti" }, { - "name": "Jovanni Lo", - "email": "lodev09@gmail.com", - "homepage": "http://www.lodev09.com/" - }, - { + "name": "Jovanni Lo", + "email": "lodev09@gmail.com", + "homepage": "http://www.lodev09.com/" + }, + { "name": "Kevin Roth", - "homepage": "https://kevinroth.com/" + "homepage": "https://kevinroth.com/" } ], - "require": { - "php": "^5.2 || ^7.0", - "guzzlehttp/guzzle": "^6.3" + "require": { + "php": "^5.2 || ^7.0 || ^8.0", + "guzzlehttp/guzzle": "^6.3" }, "autoload": { "psr-4": { diff --git a/composer.lock b/composer.lock deleted file mode 100644 index 69eb257..0000000 --- a/composer.lock +++ /dev/null @@ -1,251 +0,0 @@ -{ - "_readme": [ - "This file locks the dependencies of your project to a known state", - "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", - "This file is @generated automatically" - ], - "content-hash": "9bcd19454eb94e38ae687f59f796c211", - "packages": [ - { - "name": "guzzlehttp/guzzle", - "version": "6.3.3", - "source": { - "type": "git", - "url": "https://github.com/guzzle/guzzle.git", - "reference": "407b0cb880ace85c9b63c5f9551db498cb2d50ba" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/guzzle/guzzle/zipball/407b0cb880ace85c9b63c5f9551db498cb2d50ba", - "reference": "407b0cb880ace85c9b63c5f9551db498cb2d50ba", - "shasum": "" - }, - "require": { - "guzzlehttp/promises": "^1.0", - "guzzlehttp/psr7": "^1.4", - "php": ">=5.5" - }, - "require-dev": { - "ext-curl": "*", - "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.4 || ^7.0", - "psr/log": "^1.0" - }, - "suggest": { - "psr/log": "Required for using the Log middleware" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "6.3-dev" - } - }, - "autoload": { - "files": [ - "src/functions_include.php" - ], - "psr-4": { - "GuzzleHttp\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Michael Dowling", - "email": "mtdowling@gmail.com", - "homepage": "https://github.com/mtdowling" - } - ], - "description": "Guzzle is a PHP HTTP client library", - "homepage": "http://guzzlephp.org/", - "keywords": [ - "client", - "curl", - "framework", - "http", - "http client", - "rest", - "web service" - ], - "time": "2018-04-22T15:46:56+00:00" - }, - { - "name": "guzzlehttp/promises", - "version": "v1.3.1", - "source": { - "type": "git", - "url": "https://github.com/guzzle/promises.git", - "reference": "a59da6cf61d80060647ff4d3eb2c03a2bc694646" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/guzzle/promises/zipball/a59da6cf61d80060647ff4d3eb2c03a2bc694646", - "reference": "a59da6cf61d80060647ff4d3eb2c03a2bc694646", - "shasum": "" - }, - "require": { - "php": ">=5.5.0" - }, - "require-dev": { - "phpunit/phpunit": "^4.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.4-dev" - } - }, - "autoload": { - "psr-4": { - "GuzzleHttp\\Promise\\": "src/" - }, - "files": [ - "src/functions_include.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Michael Dowling", - "email": "mtdowling@gmail.com", - "homepage": "https://github.com/mtdowling" - } - ], - "description": "Guzzle promises library", - "keywords": [ - "promise" - ], - "time": "2016-12-20T10:07:11+00:00" - }, - { - "name": "guzzlehttp/psr7", - "version": "1.4.2", - "source": { - "type": "git", - "url": "https://github.com/guzzle/psr7.git", - "reference": "f5b8a8512e2b58b0071a7280e39f14f72e05d87c" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/guzzle/psr7/zipball/f5b8a8512e2b58b0071a7280e39f14f72e05d87c", - "reference": "f5b8a8512e2b58b0071a7280e39f14f72e05d87c", - "shasum": "" - }, - "require": { - "php": ">=5.4.0", - "psr/http-message": "~1.0" - }, - "provide": { - "psr/http-message-implementation": "1.0" - }, - "require-dev": { - "phpunit/phpunit": "~4.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.4-dev" - } - }, - "autoload": { - "psr-4": { - "GuzzleHttp\\Psr7\\": "src/" - }, - "files": [ - "src/functions_include.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Michael Dowling", - "email": "mtdowling@gmail.com", - "homepage": "https://github.com/mtdowling" - }, - { - "name": "Tobias Schultze", - "homepage": "https://github.com/Tobion" - } - ], - "description": "PSR-7 message implementation that also provides common utility methods", - "keywords": [ - "http", - "message", - "request", - "response", - "stream", - "uri", - "url" - ], - "time": "2017-03-20T17:10:46+00:00" - }, - { - "name": "psr/http-message", - "version": "1.0.1", - "source": { - "type": "git", - "url": "https://github.com/php-fig/http-message.git", - "reference": "f6561bf28d520154e4b0ec72be95418abe6d9363" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/php-fig/http-message/zipball/f6561bf28d520154e4b0ec72be95418abe6d9363", - "reference": "f6561bf28d520154e4b0ec72be95418abe6d9363", - "shasum": "" - }, - "require": { - "php": ">=5.3.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "autoload": { - "psr-4": { - "Psr\\Http\\Message\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "PHP-FIG", - "homepage": "http://www.php-fig.org/" - } - ], - "description": "Common interface for HTTP messages", - "homepage": "https://github.com/php-fig/http-message", - "keywords": [ - "http", - "http-message", - "psr", - "psr-7", - "request", - "response" - ], - "time": "2016-08-06T14:39:51+00:00" - } - ], - "packages-dev": [], - "aliases": [], - "minimum-stability": "stable", - "stability-flags": [], - "prefer-stable": false, - "prefer-lowest": false, - "platform": { - "php": "^5.2 || ^7.0" - }, - "platform-dev": [] -} From fed9021a31ed07abe772e154e405e2ad14cef82d Mon Sep 17 00:00:00 2001 From: Kevin Roth Date: Wed, 17 May 2023 09:46:38 -0500 Subject: [PATCH 8/8] Guzzle version update --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 5fc607b..cbe65ff 100644 --- a/composer.json +++ b/composer.json @@ -19,7 +19,7 @@ ], "require": { "php": "^5.2 || ^7.0 || ^8.0", - "guzzlehttp/guzzle": "^6.3" + "guzzlehttp/guzzle": "^7.2" }, "autoload": { "psr-4": {