Cloudinary PHP: Fatal error: undefined function cloudinary_url()
i'm trying to use Cloudinary PHP. I downloaded the official github samples. (https://github.com/cloudinary/cloudinary_php/tree/master/samples)
I've copied the SRC and SAMPLES folders and the autoload.php to my hosting FTP's root. ( i followed carefully the manual setup process, no using composer )
The directory structure on the server (PHP 7.3) is really simple:
WWWROOT:
- autoload.php
--- src/
--- samples/
---------- basic/
--------------- basic.php
--------------- settings.php
I've correctly configured the settings.php inside the basic folder with my Cloudinary account parameters.
Now, if i try to call the basic.php page, i get:
PHP Fatal error: Uncaught Error: Call to undefined function cloudinary_url() on basic.php:107
This is line 107:
<link rel="shortcut icon" href="<?php echo cloudinary_url('http://cloudinary.com/favicon.png', array('type' => 'fetch')); ?>"/>
So, why it's not recognizing that cloudinary_url function ?
Please, help me, thank you
-
Hi Alessandro,
Thank you for sharing the error message.
This error usually happens when the path is incorrect. The
samplesdirectory is supposedly at the same level as where yourvendorfolder is located. So I would suggest to move thesamplesfolder there and give it a try again.Please test and let me know if you continue seeing the issue.
Regards,
Aditi0 -
Dear Aditi Madan, firstly, thank you for your prompt answer.
I read your instructions, but I don't understand...
is there supposed to be a "vendor" folder then ?I'm asking this because I followed the instructions here:
https://cloudinary.com/documentation/php_integration#manual_installationManual installation:
-
Download the latest sources from:
https://github.com/cloudinary/cloudinary_php/tarball/master. -
Copy the src folder and the autoload.php file into your PHP project and then include Cloudinary's PHP classes in your code
So, I just copied the SRC FOLDER and AUTOLOAD.PHP ( and SAMPLES folder too ) directly inside my root folder. Aren't them enough to run Cloudinary correctly ?
As I said, I did a manual setup, didn't use Composer ( isn't the "vendor" folder a composer's thing ? )
Please help, thank you !
Alessandro0 -
-
Hi Alessandro,
My apologies, I missed the part that you are not using composer. If you are not using composer then you just need to change the settings.php file inside samples/basic with your config and then just run the command PHP -S localhost:8001 -t samples/basic and this should work.
The part of copying autoupload.php and src was when you are creating your own project. It is not needed when running basic sample project. If you continue seeing the issue then can you please open a support ticket here: https://support.cloudinary.com/hc/en-us/requests/new and add your project link or zipped up project and I will try and reproduce it on my end. Also, can you please share which PHP version you are currently using?
Regards,
Aditi
0 -
Hi Aditi,
The problem was the missing inclusion (of Helpers.php) inside the samples.
Please see: https://github.com/cloudinary/cloudinary_php/issues/192
Thank you so much for the help,
Bye from Italy
Alessandro
0
Post is closed for comments.
Comments
4 comments