You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is a simple PHP project that demonstrates how to configure and use Cloudinary for image management. The program loads Cloudinary credentials from a .env file, generates an image tag with specified transformations, and outputs it to the browser.
4
+
5
+
### Prerequisites
6
+
7
+
* PHP (version 7.4 or higher recommended)
8
+
* Composer for dependency management
9
+
* A Cloudinary account (you can sign up here if you don’t have one)
4. This project uses `vlucas/phpdotenv` to load environment variables, so make sure your `.env` file is in the same directory as your PHP file.
33
+
34
+
### Usage
35
+
36
+
1. Start a local server: You can use the built-in PHP server to serve the file:
37
+
```
38
+
php -S localhost:8000
39
+
```
40
+
41
+
2. Access the program: Open your browser and go to `http://localhost:8000` to see the output, which will display a Cloudinary image with specified transformations.
42
+
43
+
### Code Explanation
44
+
45
+
* **Dotenv**: This project uses `vlucas/phpdotenv` to load environment variables from a `.env` file.
46
+
* **Cloudinary PHP SDK**: The code configures Cloudinary using credentials from `.env` and generates an image tag with a transformation (resizing to 400px width).
47
+
* **Image transformation**: The example includes a resize transformation for the sample image using Resize::scale().
48
+
49
+
### Example Output
50
+
51
+
The program will display the following HTML image tag (adjusted for the Cloudinary demo account):
0 commit comments