diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index a9f86bcb..e5921c87 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -8,11 +8,11 @@ jobs: fail-fast: false matrix: php-versions: - - '5.6' - - '7.4' - '8.0' - '8.1' - '8.2' + - '8.3' + - '8.4' steps: - name: Checkout uses: actions/checkout@v4 diff --git a/README.md b/README.md index f9318797..85bfb5b2 100644 --- a/README.md +++ b/README.md @@ -5,16 +5,19 @@ Cloudinary PHP SDK ================== + ## About + The Cloudinary PHP SDK allows you to quickly and easily integrate your application with Cloudinary. Effortlessly optimize, transform, upload and manage your cloud's assets. - #### Note + This Readme provides basic installation and usage information. For the complete documentation, see the [PHP SDK Guide](https://cloudinary.com/documentation/php_integration). ## Table of Contents + - [Key Features](#key-features) - [Version Support](#Version-Support) - [Installation](#installation) @@ -22,8 +25,8 @@ For the complete documentation, see the [PHP SDK Guide](https://cloudinary.com/d - [Setup](#Setup) - [Transform and Optimize Assets](#Transform-and-Optimize-Assets) - ## Key Features + - [Transform](https://cloudinary.com/documentation/php_video_manipulation#video_transformation_examples) and [optimize](https://cloudinary.com/documentation/php_image_manipulation#image_optimizations) assets. - Generate [image](https://cloudinary.com/documentation/php_image_manipulation#deliver_and_transform_images) and @@ -31,17 +34,18 @@ For the complete documentation, see the [PHP SDK Guide](https://cloudinary.com/d - [Asset Management](https://cloudinary.com/documentation/php_asset_administration). - [Secure URLs](https://cloudinary.com/documentation/video_manipulation_and_delivery#generating_secure_https_urls_using_sdks). - - ## Version Support -| SDK Version | PHP 5.4 | PHP 5.5 | PHP 5.6 | PHP 7.x | PHP 8.x | -|-------------|---------|---------|---------|---------|---------| -| 2.x | x | x | v | v | v | -| 1.x | v | v | v | v | x | +| SDK Version | PHP 5.4 | PHP 5.5 | PHP 5.6 | PHP 7.x | PHP 8.0 - 8.3 | PHP 8.4 | +|-------------|---------|---------|---------|---------|---------------|---------| +| 3.x | ✘ | ✘ | ✘ | ✘ | ✔ | ✔ | +| 2.x | ✘ | ✘ | ✔ | ✔ | ✔ | ✘ * | +| 1.x | ✔ | ✔ | ✔ | ✔ | ✘ | ✘ | +\* Deprecation warnings ## Installation + ```bash composer require "cloudinary/cloudinary_php" ``` @@ -56,6 +60,7 @@ on migrating to this version of the PHP SDK. The previous (1.x) version of the SDK is located [here](https://github.com/cloudinary/cloudinary_php/tree/support/1.x). ### Setup + ```php use Cloudinary\Cloudinary; @@ -63,6 +68,7 @@ $cloudinary = new Cloudinary(); ``` ### Transform and Optimize Assets + - [See full documentation](https://cloudinary.com/documentation/php_image_manipulation). ```php @@ -70,43 +76,55 @@ $cloudinary->image('sample.jpg')->resize(Resize::fill()->width(100)->height(150) ``` ### Upload + - [See full documentation](https://cloudinary.com/documentation/php_image_and_video_upload). - [Learn more about configuring your uploads with upload presets](https://cloudinary.com/documentation/upload_presets). + ```php $cloudinary->uploadApi->upload('my_image.jpg'); ``` ### Security options + - [See full documentation](https://cloudinary.com/documentation/solution_overview#security). ## Contributions + - Ensure tests run locally - Open a PR and ensure Travis tests pass - ## Get Help + If you run into an issue or have a question, you can either: + - Issues related to the SDK: [Open a GitHub issue](https://github.com/cloudinary/cloudinary_php/issues). - Issues related to your account: [Open a support ticket](https://cloudinary.com/contact) - ## About Cloudinary -Cloudinary is a powerful media API for websites and mobile apps alike, Cloudinary enables developers to efficiently -manage, transform, optimize, and deliver images and videos through multiple CDNs. Ultimately, viewers enjoy responsive -and personalized visual-media experiences—irrespective of the viewing device. +Cloudinary is a powerful media API for websites and mobile apps alike, Cloudinary enables developers to efficiently +manage, transform, optimize, and deliver images and videos through multiple CDNs. Ultimately, viewers enjoy responsive +and personalized visual-media experiences—irrespective of the viewing device. ## Additional Resources -- [Cloudinary Transformation and REST API References](https://cloudinary.com/documentation/cloudinary_references): Comprehensive references, including syntax and examples for all SDKs. + +- [Cloudinary Transformation and REST API References](https://cloudinary.com/documentation/cloudinary_references): + Comprehensive references, including syntax and examples for all SDKs. - [MediaJams.dev](https://mediajams.dev/): Bite-size use-case tutorials written by and for Cloudinary Developers -- [DevJams](https://www.youtube.com/playlist?list=PL8dVGjLA2oMr09amgERARsZyrOz_sPvqw): Cloudinary developer podcasts on YouTube. -- [Cloudinary Academy](https://training.cloudinary.com/): Free self-paced courses, instructor-led virtual courses, and on-site courses. -- [Code Explorers and Feature Demos](https://cloudinary.com/documentation/code_explorers_demos_index): A one-stop shop for all code explorers, Postman collections, and feature demos found in the docs. -- [Cloudinary Roadmap](https://cloudinary.com/roadmap): Your chance to follow, vote, or suggest what Cloudinary should develop next. -- [Cloudinary Facebook Community](https://www.facebook.com/groups/CloudinaryCommunity): Learn from and offer help to other Cloudinary developers. +- [DevJams](https://www.youtube.com/playlist?list=PL8dVGjLA2oMr09amgERARsZyrOz_sPvqw): Cloudinary developer podcasts on + YouTube. +- [Cloudinary Academy](https://training.cloudinary.com/): Free self-paced courses, instructor-led virtual courses, and + on-site courses. +- [Code Explorers and Feature Demos](https://cloudinary.com/documentation/code_explorers_demos_index): A one-stop shop + for all code explorers, Postman collections, and feature demos found in the docs. +- [Cloudinary Roadmap](https://cloudinary.com/roadmap): Your chance to follow, vote, or suggest what Cloudinary should + develop next. +- [Cloudinary Facebook Community](https://www.facebook.com/groups/CloudinaryCommunity): Learn from and offer help to + other Cloudinary developers. - [Cloudinary Account Registration](https://cloudinary.com/users/register/free): Free Cloudinary account registration. -- [Cloudinary Website](https://cloudinary.com): Learn about Cloudinary's products, partners, customers, pricing, and more. - +- [Cloudinary Website](https://cloudinary.com): Learn about Cloudinary's products, partners, customers, pricing, and + more. ## Licence + Released under the MIT license. diff --git a/RoboFile.php b/RoboFile.php deleted file mode 100644 index b4dc68e4..00000000 --- a/RoboFile.php +++ /dev/null @@ -1,82 +0,0 @@ - false, - 'dox' => false, - ]; - - /** - * Run all test suites - * - * @param array $opts - * @option $dox Output agile documentation - * @option $coverage Generate test coverage report - */ - public function test($opts = self::DEFAULT_OPTIONS_TEST) - { - $task = $this->taskPHPUnit(); - - self::applyTestOptions($task, $opts); - - $task->run(); - } - - /** - * Run unit tests - * - * @param array $opts - * @option $dox Output agile documentation - * @option $coverage Generate test coverage report - */ - public function testUnit($opts = self::DEFAULT_OPTIONS_TEST) - { - $task = $this->taskPHPUnit() - ->option('testsuite', 'Unit'); - - self::applyTestOptions($task, $opts); - - $task->run(); - } - - /** - * Run integration tests - * - * @param array $opts - * @option $dox Output agile documentation - * @option $coverage Generate test coverage report - */ - public function testIntegration($opts = self::DEFAULT_OPTIONS_TEST) - { - $task = $this->taskPHPUnit() - ->option('testsuite', 'Integration'); - - self::applyTestOptions($task, $opts); - - $task->run(); - } - - private function applyTestOptions($task, $opts) - { - if ($opts['dox']) { - $task->option('testdox'); - } - - if ($opts['coverage']) { - $task->option('coverage-html', './tests/coverage'); - } - - return $task; - } -} diff --git a/composer.json b/composer.json index 8e06081d..b2037ccb 100644 --- a/composer.json +++ b/composer.json @@ -24,24 +24,23 @@ "issues": "https://github.com/cloudinary/cloudinary_php/issues" }, "require": { - "php": ">=5.6.0", - "cloudinary/transformation-builder-sdk": "^1", - "guzzlehttp/guzzle": "^6.5.8|^7.4.5", + "php": ">=8.0.0", + "cloudinary/transformation-builder-sdk": "^2", + "guzzlehttp/guzzle": "^7.4.5", "guzzlehttp/promises": "^1.5.3|^2.0", - "guzzlehttp/psr7": "^1.9.1|^2.5", + "guzzlehttp/psr7": "^2.7", "ext-json": "*", - "monolog/monolog": "^1|^2|^3", - "psr/log" : "^1|^2|^3" + "monolog/monolog": "^2|^3", + "psr/log" : "^2|^3" }, "require-dev": { - "symfony/phpunit-bridge": "^5.2", + "symfony/phpunit-bridge": "^7.2", "phpmd/phpmd": "*", - "squizlabs/php_codesniffer": "3.*", + "squizlabs/php_codesniffer": "*", "friendsofphp/php-cs-fixer": "*", "ext-dom": "*", "ext-libxml": "*", - "ext-zip": "*", - "consolidation/robo": "~1" + "ext-zip": "*" }, "autoload": { "classmap": [ diff --git a/phpunit.xml b/phpunit.xml index a8a0b7bb..9f8646e8 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -1,33 +1,20 @@ - - - - - - - - - tests/Unit - - - tests/Integration - - - - - - ./src - - + + + + ./src + + + + + + + + + tests/Unit + + + tests/Integration + + diff --git a/src/Api/Provisioning/AccountApi.php b/src/Api/Provisioning/AccountApi.php index 513ef1bd..ec6ad518 100644 --- a/src/Api/Provisioning/AccountApi.php +++ b/src/Api/Provisioning/AccountApi.php @@ -35,7 +35,7 @@ class AccountApi * * @param ProvisioningConfiguration $configuration */ - public function __construct(ProvisioningConfiguration $configuration = null) + public function __construct(?ProvisioningConfiguration $configuration = null) { $this->accountApiClient = new AccountApiClient($configuration); } diff --git a/src/Api/Provisioning/AccountApiClient.php b/src/Api/Provisioning/AccountApiClient.php index db2b54f6..c0e35e36 100644 --- a/src/Api/Provisioning/AccountApiClient.php +++ b/src/Api/Provisioning/AccountApiClient.php @@ -39,7 +39,7 @@ class AccountApiClient extends BaseApiClient * * @param ProvisioningConfiguration $configuration */ - public function __construct(ProvisioningConfiguration $configuration = null) + public function __construct(?ProvisioningConfiguration $configuration = null) { $this->init($configuration); } @@ -47,7 +47,7 @@ public function __construct(ProvisioningConfiguration $configuration = null) /** * @param ProvisioningConfiguration $configuration */ - public function init(ProvisioningConfiguration $configuration = null) + public function init(?ProvisioningConfiguration $configuration = null) { if ($configuration === null) { $configuration = ProvisioningConfiguration::instance(); diff --git a/src/Log/Logger.php b/src/Log/Logger.php index 3dabafc2..35b05df9 100644 --- a/src/Log/Logger.php +++ b/src/Log/Logger.php @@ -54,7 +54,6 @@ class Logger E_USER_ERROR => Monolog::ERROR, E_USER_WARNING => Monolog::WARNING, E_USER_NOTICE => Monolog::NOTICE, - E_STRICT => Monolog::NOTICE, E_RECOVERABLE_ERROR => Monolog::ERROR, E_DEPRECATED => Monolog::NOTICE, E_USER_DEPRECATED => Monolog::NOTICE, diff --git a/src/Log/LoggerDecorator.php b/src/Log/LoggerDecorator.php index 649c205b..1305e0a3 100644 --- a/src/Log/LoggerDecorator.php +++ b/src/Log/LoggerDecorator.php @@ -15,28 +15,6 @@ use Monolog\Handler\TestHandler; use Psr\Log\LoggerInterface; -/** - * Backwards compatibility with PSR Log v1. - */ -$r = new \ReflectionClass(LoggerInterface::class); -if (PHP_MAJOR_VERSION < 7 || !$r->getMethod('log')->hasReturnType()) { - /** - * Logger decorator trait that exposes PSR-3 Logger methods. - */ - trait LoggerDecoratorTrait - { - use LoggerDecoratorV1Trait; - } -} else { - /** - * Logger decorator trait that exposes PSR-3 Logger methods. - */ - trait LoggerDecoratorTrait - { - use LoggerDecoratorV3Trait; - } -} - /** * Logger decorator that instantiates logger by configuration and exposes PSR-3 Logger methods */ @@ -58,7 +36,7 @@ class LoggerDecorator implements LoggerInterface * * @param LoggingConfig|null $config */ - public function __construct(LoggingConfig $config = null) + public function __construct(?LoggingConfig $config = null) { $this->config = $config; } diff --git a/src/Log/LoggerDecoratorV3Trait.php b/src/Log/LoggerDecoratorTrait.php similarity index 95% rename from src/Log/LoggerDecoratorV3Trait.php rename to src/Log/LoggerDecoratorTrait.php index a6cfc894..8d3738c3 100644 --- a/src/Log/LoggerDecoratorV3Trait.php +++ b/src/Log/LoggerDecoratorTrait.php @@ -15,7 +15,7 @@ /** * Logger decorator that instantiates logger by configuration and exposes PSR-3 v3 Logger methods */ -trait LoggerDecoratorV3Trait +trait LoggerDecoratorTrait { /** * Adds a log record at the DEBUG level. @@ -25,7 +25,6 @@ trait LoggerDecoratorV3Trait * @param string|\Stringable $message The log message * @param array $context The log context * - * @return void */ public function debug(string|\Stringable $message, array $context = []): void { @@ -39,7 +38,6 @@ public function debug(string|\Stringable $message, array $context = []): void * @param string|\Stringable $message The log message * @param array $context The log context * - * @return void */ public function log($level, string|\Stringable $message, array $context = []): void { @@ -71,7 +69,6 @@ public function log($level, string|\Stringable $message, array $context = []): v * @param string|\Stringable $message The log message * @param array $context The log context * - * @return void */ public function info(string|\Stringable $message, array $context = []): void { @@ -86,7 +83,6 @@ public function info(string|\Stringable $message, array $context = []): void * @param string|\Stringable $message The log message * @param array $context The log context * - * @return void */ public function notice(string|\Stringable $message, array $context = []): void { @@ -102,7 +98,6 @@ public function notice(string|\Stringable $message, array $context = []): void * @param string|\Stringable $message The log message * @param array $context The log context * - * @return void */ public function warning(string|\Stringable $message, array $context = []): void { @@ -117,7 +112,6 @@ public function warning(string|\Stringable $message, array $context = []): void * @param string|\Stringable $message The log message * @param array $context The log context * - * @return void */ public function error(string|\Stringable $message, array $context = []): void { @@ -133,7 +127,6 @@ public function error(string|\Stringable $message, array $context = []): void * @param string|\Stringable $message The log message * @param array $context The log context * - * @return void */ public function critical(string|\Stringable $message, array $context = []): void { @@ -149,7 +142,6 @@ public function critical(string|\Stringable $message, array $context = []): void * @param string|\Stringable $message The log message * @param array $context The log context * - * @return void */ public function alert(string|\Stringable $message, array $context = []): void { @@ -164,7 +156,6 @@ public function alert(string|\Stringable $message, array $context = []): void * @param string|\Stringable $message The log message * @param array $context The log context * - * @return void */ public function emergency(string|\Stringable $message, array $context = []): void { diff --git a/src/Log/LoggerDecoratorV1Trait.php b/src/Log/LoggerDecoratorV1Trait.php deleted file mode 100644 index 5c2c3a4a..00000000 --- a/src/Log/LoggerDecoratorV1Trait.php +++ /dev/null @@ -1,173 +0,0 @@ -log('debug', $message, $context); - } - - /** - * Logs with an arbitrary level - * - * @param string $level The log level - * @param string $message The log message - * @param array $context The log context - * - * @return void - */ - public function log($level, $message, array $context = []) - { - if ($this->logger === null) { - $this->logger = LoggersList::instance()->getLogger($this->config); - } - - if ($this->logger !== null) { - static $handlerLogged; - - try { - $this->logger->log($level, $message, $context); - } catch (UnexpectedValueException $e) { - if (! $handlerLogged) { - // Triggering the error once per execution - trigger_error($e, E_USER_WARNING); - $handlerLogged = true; - throw $e; - } - } - } - } - - /** - * Adds a log record at the INFO level. - * - * Used for logging informational messages that highlight the progress of the application at coarse-grained level. - * - * @param string $message The log message - * @param array $context The log context - * - * @return void - */ - public function info($message, array $context = []) - { - $this->log('info', $message, $context); - } - - /** - * Adds a log record at the NOTICE level. - * - * Used for logging normal but significant events. - * - * @param string $message The log message - * @param array $context The log context - * - * @return void - */ - public function notice($message, array $context = []) - { - $this->log('notice', $message, $context); - } - - /** - * Adds a log record at the WARNING level. - * - * Used for logging exceptional occurrences that are not errors. - * Example: Use of deprecated APIs, poor use of an API, undesirable things that are not necessarily wrong. - * - * @param string $message The log message - * @param array $context The log context - * - * @return void - */ - public function warning($message, array $context = []) - { - $this->log('warning', $message, $context); - } - - /** - * Adds a log record at the ERROR level. - * - * Used for logging error events that might still allow the application to continue running. - * - * @param string $message The log message - * @param array $context The log context - * - * @return void - */ - public function error($message, array $context = []) - { - $this->log('error', $message, $context); - } - - /** - * Adds a log record at the CRITICAL level. - * - * Used for logging critical events. - * Example: Application component unavailable, unexpected exception. - * - * @param string $message The log message - * @param array $context The log context - * - * @return void - */ - public function critical($message, array $context = []) - { - $this->log('critical', $message, $context); - } - - /** - * Adds a log record at the ALERT level. - * - * Used for logging and probably triggering an alert that will wake someone up. - * Example: Entire website down, database unavailable, etc. - * - * @param string $message The log message - * @param array $context The log context - * - * @return void - */ - public function alert($message, array $context = []) - { - $this->log('alert', $message, $context); - } - - /** - * Adds a log record at the EMERGENCY level. - * - * Used for logging the highest level of errors. System is unusable. - * - * @param string $message The log message - * @param array $context The log context - * - * @return void - */ - public function emergency($message, array $context = []) - { - $this->log('emergency', $message, $context); - } -} diff --git a/src/Log/LoggerTrait.php b/src/Log/LoggerTrait.php index 6cc448f5..734048e7 100644 --- a/src/Log/LoggerTrait.php +++ b/src/Log/LoggerTrait.php @@ -16,7 +16,7 @@ /** * LoggerTrait adds logging capabilities to a class * - * By default it writes to the standard error log configured for PHP + * By default, it writes to the standard error log configured for PHP * * Example usage: * class Foo diff --git a/src/Tag/Attribute/SrcSet.php b/src/Tag/Attribute/SrcSet.php index b4491766..62806dbd 100644 --- a/src/Tag/Attribute/SrcSet.php +++ b/src/Tag/Attribute/SrcSet.php @@ -104,7 +104,7 @@ public function __construct($image, $configuration = null) * * @return $this */ - public function breakpoints(array $breakpoints = null) + public function breakpoints(?array $breakpoints = null) { $this->breakpoints = $breakpoints; diff --git a/src/Tag/BaseImageTag.php b/src/Tag/BaseImageTag.php index 93e06b89..1c21127c 100644 --- a/src/Tag/BaseImageTag.php +++ b/src/Tag/BaseImageTag.php @@ -211,7 +211,7 @@ public function addAction($action) * * @return $this */ - public function breakpoints(array $breakpoints = null) + public function breakpoints(?array $breakpoints = null) { $this->srcset->breakpoints($breakpoints); diff --git a/src/Utils/Utils.php b/src/Utils/Utils.php index 762e946d..e1f89d92 100644 --- a/src/Utils/Utils.php +++ b/src/Utils/Utils.php @@ -199,7 +199,7 @@ public static function randomPublicId($prefix = '') * * @return false|UriInterface */ - public static function tryParseUrl($url, array $allowedSchemes = null) + public static function tryParseUrl($url, ?array $allowedSchemes = null) { if (! $url instanceof UriInterface) { if (! is_string($url)) {