|
1 | | -[](https://github.com/cloudinary/cloudinary_php/actions/workflows/test.yaml) |
2 | | -[](https://github.com/cloudinary/cloudinary_php/blob/master/LICENSE) |
3 | | -[](https://packagist.org/packages/cloudinary/cloudinary_php) |
4 | | -[](https://packagist.org/packages/cloudinary/cloudinary_php/stats) |
5 | | - |
6 | | -Cloudinary PHP SDK |
7 | | -================== |
8 | | - |
9 | | -## About |
| 1 | +# Cloudinary PHP SDK |
10 | 2 |
|
11 | | -The Cloudinary PHP SDK allows you to quickly and easily integrate your application with Cloudinary. |
12 | | -Effortlessly optimize, transform, upload and manage your cloud's assets. |
| 3 | +Upload, transform, optimize, and manage images and videos with Cloudinary from PHP — the `cloudinary/cloudinary_php` package on Packagist. |
13 | 4 |
|
14 | | -#### Note |
15 | | - |
16 | | -This Readme provides basic installation and usage information. |
17 | | -For the complete documentation, see the [PHP SDK Guide](https://cloudinary.com/documentation/php_integration). |
| 5 | +[](https://github.com/cloudinary/cloudinary_php/actions/workflows/test.yaml) |
| 6 | +[](https://packagist.org/packages/cloudinary/cloudinary_php) |
| 7 | +[](LICENSE) |
18 | 8 |
|
19 | | -## Table of Contents |
| 9 | +## Install |
20 | 10 |
|
21 | | -- [Key Features](#key-features) |
22 | | -- [Version Support](#Version-Support) |
23 | | -- [Installation](#installation) |
24 | | -- [Usage](#usage) |
25 | | - - [Setup](#Setup) |
26 | | - - [Transform and Optimize Assets](#Transform-and-Optimize-Assets) |
| 11 | +```bash |
| 12 | +composer require cloudinary/cloudinary_php |
| 13 | +``` |
27 | 14 |
|
28 | | -## Key Features |
| 15 | +## Quick start |
29 | 16 |
|
30 | | -- [Transform](https://cloudinary.com/documentation/php_video_manipulation#video_transformation_examples) and |
31 | | - [optimize](https://cloudinary.com/documentation/php_image_manipulation#image_optimizations) assets. |
32 | | -- Generate [image](https://cloudinary.com/documentation/php_image_manipulation#deliver_and_transform_images) and |
33 | | - [video](https://cloudinary.com/documentation/php_video_manipulation#php_video_transformation_code_examples) tags. |
34 | | -- [Asset Management](https://cloudinary.com/documentation/php_asset_administration). |
35 | | -- [Secure URLs](https://cloudinary.com/documentation/video_manipulation_and_delivery#generating_secure_https_urls_using_sdks). |
| 17 | +Set your API environment variable (Console > Settings > API Keys): |
36 | 18 |
|
37 | | -## Version Support |
| 19 | +```bash |
| 20 | +export CLOUDINARY_URL=cloudinary://<api_key>:<api_secret>@<cloud_name> |
| 21 | +``` |
38 | 22 |
|
39 | | -| SDK Version | PHP 5.4 | PHP 5.5 | PHP 5.6 | PHP 7.x | PHP 8.0 - 8.3 | PHP 8.4 | |
40 | | -|-------------|---------|---------|---------|---------|---------------|---------| |
41 | | -| 3.x | ✘ | ✘ | ✘ | ✘ | ✔ | ✔ | |
42 | | -| 2.x | ✘ | ✘ | ✔ | ✔ | ✔ | ✘ * | |
43 | | -| 1.x | ✔ | ✔ | ✔ | ✔ | ✘ | ✘ | |
| 23 | +Upload an image and get an optimized delivery URL: |
44 | 24 |
|
45 | | -\* Deprecation warnings |
| 25 | +```php |
| 26 | +<?php |
46 | 27 |
|
47 | | -## Installation |
| 28 | +require 'vendor/autoload.php'; |
48 | 29 |
|
49 | | -```bash |
50 | | -composer require "cloudinary/cloudinary_php" |
| 30 | +use Cloudinary\Cloudinary; |
| 31 | +use Cloudinary\Transformation\Delivery; |
| 32 | +use Cloudinary\Transformation\Format; |
| 33 | +use Cloudinary\Transformation\Gravity; |
| 34 | +use Cloudinary\Transformation\Quality; |
| 35 | +use Cloudinary\Transformation\Resize; |
| 36 | + |
| 37 | +try { |
| 38 | + $cloudinary = new Cloudinary(); |
| 39 | + |
| 40 | + // Upload a remote image (a local file path works the same way). |
| 41 | + $result = $cloudinary->uploadApi()->upload( |
| 42 | + 'https://res.cloudinary.com/demo/image/upload/sample.jpg', |
| 43 | + ['public_id' => 'quickstart-sample'] |
| 44 | + ); |
| 45 | + |
| 46 | + echo 'Uploaded: ', $result['public_id'], PHP_EOL; |
| 47 | + |
| 48 | + // Build a 400x400 auto-cropped URL with automatic format and quality. |
| 49 | + $url = $cloudinary->image($result['public_id']) |
| 50 | + ->resize(Resize::fill(400, 400)->gravity(Gravity::auto())) |
| 51 | + ->delivery(Delivery::format(Format::auto())) |
| 52 | + ->delivery(Delivery::quality(Quality::auto())); |
| 53 | + |
| 54 | + echo 'Optimized URL: ', $url, PHP_EOL; |
| 55 | +} catch (Throwable $e) { |
| 56 | + fwrite(STDERR, 'Quick start failed: ' . $e->getMessage() . PHP_EOL); |
| 57 | + fwrite(STDERR, 'Check that CLOUDINARY_URL is set (Console > Settings > API Keys).' . PHP_EOL); |
| 58 | + exit(1); |
| 59 | +} |
51 | 60 | ``` |
52 | 61 |
|
53 | | -# Usage |
54 | | - |
55 | | -### Migration |
| 62 | +Save as `quickstart.php` and run `php quickstart.php`. [Create a free account](https://cloudinary.com/users/register_free) if you don't have one — or run `npx @cloudinary/cloud` to [provision one without signing up](docs/get-credentials.md). |
56 | 63 |
|
57 | | -See the [Cloudinary PHP SDK Migration guide](https://cloudinary.com/documentation/php2_migration) for more information |
58 | | -on migrating to this version of the PHP SDK. |
| 64 | +`uploadApi()`, `adminApi()`, and `searchApi()` are methods — call them with parentheses. |
59 | 65 |
|
60 | | -The previous (1.x) version of the SDK is located [here](https://github.com/cloudinary/cloudinary_php/tree/support/1.x). |
| 66 | +## Common tasks |
61 | 67 |
|
62 | | -### Setup |
| 68 | +- [Get Cloudinary credentials](docs/get-credentials.md) |
| 69 | +- [Import and call the SDK](docs/import-and-call.md) |
| 70 | +- [Configure Cloudinary](docs/configure-cloudinary.md) |
| 71 | +- [Upload an image](docs/upload-image.md) |
| 72 | +- [Upload a large video](docs/upload-large-video.md) |
| 73 | +- [Sign a browser upload](docs/sign-browser-upload.md) |
| 74 | +- [Transform and deliver an image](docs/transform-and-deliver-image.md) |
| 75 | +- [Transform and deliver a video](docs/transform-and-deliver-video.md) |
| 76 | +- [Search and manage assets](docs/search-and-manage-assets.md) |
| 77 | +- [Moderate an upload](docs/moderate-upload.md) |
| 78 | +- [Use structured metadata](docs/use-structured-metadata.md) |
| 79 | +- [Troubleshoot errors](docs/troubleshoot-errors.md) |
63 | 80 |
|
64 | | -```php |
65 | | -use Cloudinary\Cloudinary; |
| 81 | +Runnable versions live in [`examples/`](examples/) — each is a complete file you can run directly. |
66 | 82 |
|
67 | | -$cloudinary = new Cloudinary(); |
68 | | -``` |
| 83 | +## When to use this SDK |
69 | 84 |
|
70 | | -### Transform and Optimize Assets |
| 85 | +Use this package in **PHP server-side code**: uploads, signed operations, asset |
| 86 | +administration, search, moderation, and delivery URL generation. It works with any |
| 87 | +framework, and with none. |
71 | 88 |
|
72 | | -- [See full documentation](https://cloudinary.com/documentation/php_image_manipulation). |
| 89 | +For other jobs, better-fitting tools exist: |
73 | 90 |
|
74 | | -```php |
75 | | -$cloudinary->image('sample.jpg')->resize(Resize::fill()->width(100)->height(150))->format(Format::auto()); |
76 | | -``` |
| 91 | +- Laravel-native integration with facades and a storage driver: [`cloudinary-labs/cloudinary-laravel`](https://github.com/cloudinary-labs/cloudinary-laravel). |
| 92 | +- WordPress, Magento, and similar platforms: [platform integrations](https://cloudinary.com/documentation/integrations) ([md](https://cloudinary.com/documentation/integrations.md)). |
| 93 | +- Browser or frontend framework rendering: [frontend SDKs](https://cloudinary.com/documentation/frontend_sdks) ([md](https://cloudinary.com/documentation/frontend_sdks.md)). |
| 94 | +- Complete in-browser upload UI: [Upload Widget](https://cloudinary.com/documentation/upload_widget) ([md](https://cloudinary.com/documentation/upload_widget.md)). |
| 95 | +- Text-to-image generation and image-to-video: [platform APIs](https://cloudinary.com/documentation/image_generation_addon) ([md](https://cloudinary.com/documentation/image_generation_addon.md)), not wrapped by this package. |
| 96 | +- Multi-step media workflow automation: [MediaFlows](https://cloudinary.com/documentation/mediaflows_user_guide) ([md](https://cloudinary.com/documentation/mediaflows_user_guide.md)). |
| 97 | +- Interactive agent-driven asset operations: [Cloudinary MCP servers and Skills](https://cloudinary.com/documentation/cloudinary_llm_mcp) ([md](https://cloudinary.com/documentation/cloudinary_llm_mcp.md)). |
77 | 98 |
|
78 | | -### Upload |
| 99 | +The full capability map — plus the Skills, MCP servers, and CLI worth setting up first — |
| 100 | +is in [docs/platform-capabilities.md](docs/platform-capabilities.md). |
79 | 101 |
|
80 | | -- [See full documentation](https://cloudinary.com/documentation/php_image_and_video_upload). |
81 | | -- [Learn more about configuring your uploads with upload presets](https://cloudinary.com/documentation/upload_presets). |
| 102 | +## Status and compatibility |
82 | 103 |
|
83 | | -```php |
84 | | -$cloudinary->uploadApi->upload('my_image.jpg'); |
85 | | -``` |
| 104 | +Stable, actively maintained. See [CHANGELOG.md](CHANGELOG.md). |
86 | 105 |
|
87 | | -### Security options |
| 106 | +| SDK version | PHP | |
| 107 | +|-------------|-----| |
| 108 | +| 3.x | 8.0 and later | |
| 109 | +| 2.x | 5.6 – 8.3 (no longer maintained) | |
| 110 | +| 1.x | 5.4 – 7.x (no longer maintained) | |
88 | 111 |
|
89 | | -- [See full documentation](https://cloudinary.com/documentation/solution_overview#security). |
| 112 | +The 1.x series lives on the [`support/1.x`](https://github.com/cloudinary/cloudinary_php/tree/support/1.x) branch. Moving from it? See the [migration guide](https://cloudinary.com/documentation/php2_migration) ([md](https://cloudinary.com/documentation/php2_migration.md)). |
90 | 113 |
|
91 | | -## Contributions |
| 114 | +## Documentation |
92 | 115 |
|
93 | | -- Ensure tests run locally |
94 | | -- Open a PR and ensure Travis tests pass |
| 116 | +- [Bundled task docs](docs/README.md) — ship inside the package, version-matched. |
| 117 | +- [PHP SDK guide](https://cloudinary.com/documentation/php_integration) — the full documentation ([md](https://cloudinary.com/documentation/php_integration.md)). |
| 118 | +- [Transformation and API reference](https://cloudinary.com/documentation/cloudinary_references) ([md](https://cloudinary.com/documentation/cloudinary_references.md)). |
95 | 119 |
|
96 | | -## Get Help |
| 120 | +Documentation links in this README point at the browsable HTML page, with an `(md)` |
| 121 | +companion link that returns the same page as raw Markdown. Inside `docs/` and `examples/` |
| 122 | +the links are Markdown-only, since those files are written to be read by coding agents. |
| 123 | +Either form works for any page: add `.md` for Markdown, drop it for HTML. |
97 | 124 |
|
98 | | -If you run into an issue or have a question, you can either: |
| 125 | +## For AI coding agents |
99 | 126 |
|
100 | | -- Issues related to the SDK: [Open a GitHub issue](https://github.com/cloudinary/cloudinary_php/issues). |
101 | | -- Issues related to your account: [Open a support ticket](https://cloudinary.com/contact) |
| 127 | +- Contributing to this repo: read [AGENTS.md](AGENTS.md). |
| 128 | +- Using the installed package: the docs in `vendor/cloudinary/cloudinary_php/docs/` match |
| 129 | + your installed version and are the source of truth; start with |
| 130 | + [platform-capabilities](docs/platform-capabilities.md) before assuming a feature exists. |
102 | 131 |
|
103 | | -## About Cloudinary |
| 132 | +## Support |
104 | 133 |
|
105 | | -Cloudinary is a powerful media API for websites and mobile apps alike, Cloudinary enables developers to efficiently |
106 | | -manage, transform, optimize, and deliver images and videos through multiple CDNs. Ultimately, viewers enjoy responsive |
107 | | -and personalized visual-media experiences—irrespective of the viewing device. |
| 134 | +- SDK bugs and feature requests: [GitHub issues](https://github.com/cloudinary/cloudinary_php/issues) |
| 135 | +- Account and platform questions: [Cloudinary support](https://support.cloudinary.com) |
108 | 136 |
|
109 | | -## Additional Resources |
| 137 | +## Security |
110 | 138 |
|
111 | | -- [Cloudinary Transformation and REST API References](https://cloudinary.com/documentation/cloudinary_references): |
112 | | - Comprehensive references, including syntax and examples for all SDKs. |
113 | | -- [MediaJams.dev](https://mediajams.dev/): Bite-size use-case tutorials written by and for Cloudinary Developers |
114 | | -- [DevJams](https://www.youtube.com/playlist?list=PL8dVGjLA2oMr09amgERARsZyrOz_sPvqw): Cloudinary developer podcasts on |
115 | | - YouTube. |
116 | | -- [Cloudinary Academy](https://training.cloudinary.com/): Free self-paced courses, instructor-led virtual courses, and |
117 | | - on-site courses. |
118 | | -- [Code Explorers and Feature Demos](https://cloudinary.com/documentation/code_explorers_demos_index): A one-stop shop |
119 | | - for all code explorers, Postman collections, and feature demos found in the docs. |
120 | | -- [Cloudinary Roadmap](https://cloudinary.com/roadmap): Your chance to follow, vote, or suggest what Cloudinary should |
121 | | - develop next. |
122 | | -- [Cloudinary Facebook Community](https://www.facebook.com/groups/CloudinaryCommunity): Learn from and offer help to |
123 | | - other Cloudinary developers. |
124 | | -- [Cloudinary Account Registration](https://cloudinary.com/users/register/free): Free Cloudinary account registration. |
125 | | -- [Cloudinary Website](https://cloudinary.com): Learn about Cloudinary's products, partners, customers, pricing, and |
126 | | - more. |
| 139 | +See [SECURITY.md](SECURITY.md) for private vulnerability reporting. Keep your |
| 140 | +`api_secret` in server-side code; for client uploads, use the server-signed pattern in |
| 141 | +[Sign a browser upload](docs/sign-browser-upload.md). |
127 | 142 |
|
128 | | -## Licence |
| 143 | +## License |
129 | 144 |
|
130 | | -Released under the MIT license. |
| 145 | +Released under the MIT license — see [LICENSE](LICENSE). Copyright (c) Cloudinary Ltd. |
0 commit comments