Programmable Media

PHP quick start

Last updated: Oct-31-2023

This quick start is intended to let you quickly try using several common Cloudinary features. It doesn't necessarily employ coding best practices and the code you create here isn't intended for production.

You can perform this quick start in a code sandbox or in a clean project in the dev environment of your choice.

You can also view the completed code of this quick start in a GitHub repo.

If you aren't familiar with Cloudinary, you may want to first take a look at the Developer get started guide for a high-level overview of integrating Cloudinary into your code, and an introduction to the main concepts.

You may also find our Glossary helpful to understand Cloudinary-specific terminology.


To perform this quick start, you'll need:

1. Set up and configure the SDK

Install the SDK

Use Composer to manage your PHP library dependency, and install Cloudinary's PHP library.

  1. Update your composer.json file as follows:

  2. Automatically install dependencies, including Cloudinary's PHP package, by running the following command in the root folder of your project:

Configure Cloudinary

When writing your own applications, follow your organization's policy on storing secrets and don't expose your API secret.

Within a new file based on an empty HTML template called 'php_quickstart', use your API environment variable to configure your credentials (replace cloudinary://my_key:my_secret@my_cloud_name below with your environment variable value):


2. Upload an image

Use the upload method of the UploadApi class to upload assets to Cloudinary. The code is encased in HTML to format and display the response:

php_quickstart.php (continued)

3. Get info about the image

Use the asset method of the AdminApi class to return the details of our uploaded asset. The code is encased in HTML to format and display the response:

php_quickstart.php (continued)

4. Transform and deliver the image

Use the imageTag method to generate the full image URL based on the specified transformation parameters and add the image tag to your HTML code:

php_quickstart.php (continued)

5. Run your code

Run your php_quickstart.php file and take a look at the output you get from each step of this quick start.

View the completed code

The sample code for this quick start can be forked from GitHub.

Next steps

  • Learn more about the PHP SDK by visiting the other pages in this SDK guide.
  • Get comprehensive details about Cloudinary features and capabilities:

✔️ Feedback sent!

Rate this page: