Skip to content

Commit 6d0628c

Browse files
fix github errors
1 parent 5541796 commit 6d0628c

File tree

2 files changed

+66
-2
lines changed

2 files changed

+66
-2
lines changed

examples/php_credentials/README

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
## PHP Quick Start with Cloudinary
2+
3+
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)
10+
11+
12+
### Installation
13+
14+
1. Clone the repository:
15+
```
16+
git clone https://github.com/your-username/php-cloudinary-quickstart.git
17+
cd php-cloudinary-quickstart
18+
```
19+
20+
2. Install dependencies: <p>Run the following command to install PHP dependencies using Composer:</p>
21+
```
22+
composer install
23+
```
24+
25+
3. Set up environment variables:
26+
* Create a .env file in the root of your project.
27+
* Add your Cloudinary URL (from your Cloudinary dashboard) in the `.env` file like this:
28+
```
29+
CLOUDINARY_URL=cloudinary://API_KEY:API_SECRET@CLOUD_NAME
30+
```
31+
32+
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):
52+
53+
```
54+
<img src="https://res.cloudinary.com/demo/image/upload/b_auto:predominant,c_pad,h_400,w_400/flower_sample">
55+
```
56+
57+
### Dependencies
58+
59+
* `vlucas/phpdotenv` for environment variable management
60+
* Cloudinary PHP SDK for managing Cloudinary assets
61+
62+
### License
63+
64+
This project is licensed under the MIT License.

examples/php_credentials/php_credentials.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@
3434
);
3535

3636
echo $imgtag;
37-
// The code above generates the following HTML image tag (for the demo account):
38-
// <img src="https://res.cloudinary.com/demo/image/upload/b_auto:predominant,c_pad,h_400,w_400/flower_sample">
37+
// The code above generates the following HTML image tag:
38+
// <img src="https://res.cloudinary.com/new-shop/image/upload/cld-sample">
3939

4040
echo '<br>';
4141
echo '<br>';

0 commit comments

Comments
 (0)