Apparently my last question was too vague even though it was pretty straightforward.
I'm trying to use Embed.ly's API to embed some stuff, for example, some of the stuff shown here.
https://github.com/embedly/embedly-php/blob/master/README.rst
I have the entire Embedly.php source file in my working directory.
However, when I have the following in my header file:
<?php
//require_once('Embedly/src/Embedly/Embedly.php'); // if using pear
require_once('./Embedly.php'); // if using source
$api = new Embedly\Embedly(array('user_agent' => 'Mozilla/5.0 (compatible; mytestapp/1.0)'));
?>
And the following in my main page:
<?php
$objs = $api->oembed(array(
'urls' => array(
'http://www.youtube.com/watch?v=sPbJ4Z5D-n4&feature=topvideos',
'http://twitpic.com/3yr7hk'
)
));
?>
I get the following error:
( ! ) Fatal error: Call to undefined function Embedly\curl_init() in C:\wamp\www\Embedly.php on line 259
It looks like curl isn't installed or enabled.
If you're on you own server (assuming something similar to ubuntu server), a simple sudo apt-get install php5-curl should solve it.
Otherwise, you may have to contact your hosting provider.
Got this from a forum and it seems legit:
Close WAMP (if running)
Navigate to WAMP\bin\php(your version of php)\
Edit php.ini
Search for curl, uncomment extension=php_curl.dll
Navigate to WAMP\bin\Apache(your version of apache)\bin\
Edit php.ini
Search for curl, uncomment the line/remove the #, extension=php_curl.dll
Save the files
Restart WAMP
Related
I have a simple test code:
<?php
var_dump(curl_init());
echo '.';
if I run it on command line (Windows 10) I get the expected result:
php.exe test.php
resource(4) of type (curl) .
very fine. But when Im running this file from browser (set to Apache rootdir).
Fatal error: Uncaught Error: Call to undefined function curl_init() in
Im speachless. For legacy reasons, this is php 7.04 (on 7.2, 7.4, 8.1 everything is fine).
The php.ini does work. Of course "extension=php_curl.dll" is enabled. When I change something, for example "max_execution_time = 300", the php_info(); also reinforcements me that these settings are taken into account.
However, the strange thing is what php_info() is saying:
cURL Sterling Hughes
nothing more for curl!
EDIT:
I tried the same with "extension=php_gd2.dll" and it does work if I remove/readd it, phpinfo shows that correctly!
This is because the php folder is not in your system PATH (not user), Apache doesn't know where to search dlls. The easiest way is adding php folder to PATH.
If you doesn't want to do that, you probably need set extension_dir to the full path of your extension folder in php.ini. for example:
extension_dir = "D:\Program Files\php-7.04-ts\ext"
cURL extension needs openssl to work. and you can also find these dlls in php folder, just copy them to Windows or system32 folder. According to RiggsFolly's comment you can copy these required dlls to Apache\bin folder.
libssl-1_1-x64.dll / libeay32.dll
libcrypto-1_1-x64.dll / ssleay32.dll
libssh2.dll
Uncaught Error: Call to undefined function CodeIgniter\locale_set_default()
in C:\xampp\htdocs\sunpay-ci4\system\CodeIgniter.php:184
Stack trace:
#0 C:\xampp\htdocs\sunpay-ci4\system\bootstrap.php(181): CodeIgniter\CodeIgniter->initialize()
#1 C:\xampp\htdocs\sunpay-ci4\public\index.php(36): require('C:\\xampp\\htdocs...')
#2 {main} thrown in C:\xampp\htdocs\sunpay-ci4\system\CodeIgniter.php on line 184
I don't understand this error, the first page works if I drop this package.
Try opening php.ini from the control panel:
Apache row -> Config -> php.ini
Then enable intl extension by removing ; in front of extension=intl
Edit: the reason it fails is because the intl extension is disabled by default in xampp
Recently I stuck on the same problem on CI version 4.0.4.
Follow the steps to fix it.
Click on "config" from the xampp control panel.
Then click on php.ini option.
Then it will open on your default text editor application (for me it is Notepad). then click on find option.
Then search for ";extension=intl".
replace ";extension=intl" with "extension=intl".
That's all. Thanks.
get your php version by put this code : phpinfo();die(); in your index.php after <?php so it looks like like <?php phpinfo();die();
PHP Version 7.2.24-0ubuntu0.18.04.7
jump to /etc/php/{your php version}/apache2 folder; example : /etc/php/7.2/apache2 and open php.ini then find ;extension=intl and remove the semicolon ;
open your terminal then write or copy paste this command sudo systemctl restart apache2 and press ENTER
open your CI 4 again in your browser.
Welcome to CodeIgniter 4.0.4
The small framework with powerful features
==============================================================================
if you still get the same error please try to install intl extension using this command in your terminal:
sudo apt install php{your php version}-intl
sudo systemctl restart apache2`
example :
sudo apt install php7.2-intl
sudo systemctl restart apache2
open your CI 4 again in your browser.
Welcome to CodeIgniter 4.0.4
The small framework with powerful features
=============================================================================
#NB :
dont forget to remove phpinfo();die(); in the first step
sorry for my bad english
Just go to the mentioned line in display in error.
C:\xampp\htdocs\sunpay-ci4\system\CodeIgniter.php:184
You can find it here: root folder/system/CodeIgniter.php
on line no 184 you will find the below code.
locale_set_default($this->config->defaultLocale ?? 'en');
just comment it like this.
#locale_set_default($this->config->defaultLocale ?? 'en');
Now, the code is working.
1.search for intl and uncomment this extension in php.ini file by removing ; from begin of line extension=intl
2. restart Apache service by stop and starting it again from xampp control panel
When i started a new project i got this error on welcome screen. Fatal error: Uncaught Error: //pp\Views\welcome_message.php:222 Stack trace: #0 {main} thrown in. It appears like there is a problem with the installation of codeigniter but in fact it is an echo error in line 222 of the welcom_message.php page go there an remove the <?= CodeIgniter\CodeIgniter::CI_VERSION ?> from line 222 it should look like this
<div class="heroe">
<h1>Welcome to CodeIgniter </h1>
<h2>The small framework with powerful features</h2>
</div>
Then it will echo hello screen correctly
Usually to get round this try these three points:
Ensure .writable folder is writable with file permissions 0777 (must have leading zero)
Try setting the following in index.php -> $_SERVER['CI_ENVIRONMENT'] = 'development'; and toggle with $_SERVER['CI_ENVIRONMENT'] = 'production' in .env file;
Access this file(CodeIgniter.php) in the following directory: project_folder/vendor/codeigniter4/framework/system/CodeIgniter.php
public function initialize()
{
if( function_exists('locale_set_default' )):
locale_set_default($this->config->defaultLocale ?? 'en');
endif;}
if your have installed Apache, PHP, MYSQL manually, then set locale to app in .env file:
app.locale = "en"
save and restart apache service
I an creating a PWA app and its working fine, but when I tried to upload on server I stuck on error. On windows local server, everything is fine even notifications, and I dont know much putty/linux commands.
check here my phpinfo file.
I am tring to upload to amazon ec2 server. I installed apache, php, ssl and other required things. And its working file except notifications.
When I call my notification file, I got 503 response. I installed composer, installed everything. I used this github library.
As I understand, I stuck on gmp extension, When I open phpinfo() I didnt see gmp over there. I installed gmp using sudo yum install php-gmp and also I see a file in php.d named as 20-gmp.ini and it included extension=gmp. Also restarted apache server using sudo apachectl stop, sudo apachectl start.
But still I am getting error. And I coudnt see gmp in phpinfo().
notificationb.php
<?php
require __DIR__ . '/vendor/autoload.php';
use Minishlink\WebPush\WebPush;
use Minishlink\WebPush\Subscription;
$subscription = Subscription::create(json_decode(file_get_contents('php://input'), true));
print_r($subscription);
$auth = array(
'VAPID' => array(
'subject' => 'https://github.com/Minishlink/web-push-php-example/',
'publicKey' => file_get_contents(__DIR__ . '/scripts/keys/public_key.txt'), // don't forget that your public key also lives in app.js
'privateKey' => file_get_contents(__DIR__ . '/scripts/keys/private_key.txt'), // in the real world, this would be in a secret file
),
);
$webPush = new WebPush($auth);
$res = $webPush->sendNotification(
$subscription,
"Welcome to Kaya. You can book Appointments and many more."
);
foreach ($webPush->flush() as $report) {
$endpoint = $report->getRequest()->getUri()->__toString();
if ($report->isSuccess()) {
echo "[v] Message sent successfully for subscription {$endpoint}.";
} else {
echo "[x] Message failed to sent for subscription {$endpoint}: {$report->getReason()}";
}
}
?>
If you need any thing, let me know in command. I will update here.
Edit 1: Also I tried to add gmp extension in php.ini in /etc/php.ini but still not added.
I think I am getting error on $subscription = Subscription::create(json_decode(file_get_contents('php://input'), true));
I know I am commenting my own question, As I was searching this answer for 3-4 days I think I should share this info with everyone.
The issue is, In linux, PHP have different-different configuration files. The main configuration file is php.ini. And it include other extensions after loading this file and override mail file. These additional configuration are located in /etc/php.d/ (in my case, which is common for mostly).
So just restarting apache server in not enough. We need to also restart php-fpm.
To restart php-fpm: sudo service php-fpm restart
And then restart apache: sudo apachectn restart
You can check more here
To apply change in php.ini, you need to restart apache server and also restart php.
sudo service php-fpm restart
sudo apachectn restart
Also sometime it took time to apply changes to server.
I have a local WordPress installation running at: https://catalogue3.test.
Note that all .test domains should resolve to localhost, as I use Laravel valet. When I execute the following code in my Laravel project however, I get an exception as shown below.
$client = new \GuzzleHttp\Client();
$response = $client->request('GET', "https://catalogue3.test", ['verify' => false]);
ConnectException
cURL error 6: Could not resolve: catalogue3.test (Domain name not
found) (see http://curl.haxx.se/libcurl/c/libcurl-errors.html)
When I run the command below in the terminal, the WordPress page is displayed.
curl https://catalogue3.test/ --insecure
Add
ip catalogue3.test
to your /etc/hosts file
I tried to add the domain to hosts and I tried to change dns in network settings, this answer is what worked for me.
Quick way to check if this is your problem is to do: curl --version
and php --ri curl
The versions should match. If they don't it's probably because brew
has installed curl-openssl. This can be removed by doing:
brew uninstall curl-openssl --ignore-dependencies
Maybe there's a way to configure the installed curl-openssl properly -
I've not investigated this yet.
I solved this adding catalogue3.test to /etc/hosts, even if I was using DnsMasq, and in theory, I wouldn't need it.
In my case (on macos) I had to add 127.0.0.1 as the first DNS server option in my WiFi settings.
Some useful info here too: https://github.com/laravel/valet/issues/736
I've a development computer, which runs under windows.
For a project, I've to make a php website which has to connect to an Ingres database server.
So I installed wamp, I installed ingres(server and client, on my local machine).
I added the library that I found on their site(php_ingres.dll) in the C:\wamp\bin\php\php5.3.5\ext folder, and I added a line "extension=php_ingres.dll" in the configuration file.
I shutdown wamp and restarted it, and I restarted the server, I see now a check mark in the wamp menu, indicating that php_ingres is now activated. But when I go to the welcome page of the server, I don't see this extension as loaded. If I go on the php info page, I don't see any Ingres entry in the Configure Command.
I just can't found any post/tutorial/... which indicating how to do this operation, so any help would be appreciated!
Thank you!
Edit: I made a small test to see if I can connect to an Ingres database:
<?php
$link = ingres_connect("localhost", "demodbtest", "demodbtest") or die("Connexion impossible");
echo "Connexion réussie";
$result = ingres_query($link,"select * from airline");
while ($row = ingres_fetch_array($result)) {
echo $row["al_iatacode"]; // utilisation du tableau associatif
echo $row["al_name"];
echo $row["al_ccode"]; // utilisation du tableau à indices numériques
echo "</br>";
}
ingres_close($link);
?>
And I get this error:
( ! ) Fatal error: Call to undefined function ingres_connect() in
C:\wamp\www\tests\index.php on line 2
Some information on my installation:
I've a windows 7 pro 32bits
Wampserver 2.1 ( http://sourceforge.net/projects/wampserver/files/WampServer%202/WampServer%202.1/WampServer2.1e-x32.exe/download )
Apache 2.2.17
PHP 5.3.5
Ingres 10.1.0 Community edition( downloaded here: http://esd.ingres.com/product/Community_Projects/Ingres_Database/Windows_32-Bit/Ingres_10.1_Build_121/ingres-10.1.0-121-gpl-win-x86-NoDoc.zip/http )
PHP drivers downloaded here: http://esd.ingres.com/product/drivers/PHP/Windows_32-Bit/PHP_Driver
To practically test if the extension was loaded you can as well call one of it's functions. If the extension was loaded, you should not get a fatal error for a missing function. That's perhaps one of the quickest checks.
Another check is to make use of extension_loaded *PHP Manual** which will give you a list of all loaded extensions. See the PHP Manual link above for more info.
The configure line
The configure line will not show the ingres extension because it has not been compiled in. That's perfectly alright because you load it as an extension (.dll) so it's not part of php.exe. This is why you don't see it in the configure line.
Locating ingres on the phpinfo() page.
On the phpinfo()-page use the search function inside your browser (often CTRL+F) and try to locate the word ingres. You should locate a section that displays the extensions default settings if it has been loaded.
The following is an example screenshot for the xdebug extension. This might look similar for ingres:
Image from: Launching xdebug in Eclipse stuck at 57% - How to trouble-shoot?
Double check your extension_dir setting as well as the actual php.ini file being used. Calling php.exe -i from the command line might not give the same output if executing phpinfo() in a script via Apache (or IIS). In fact http://www.wampserver.com/en/faq.php says there are 3 potential php.ini scripts.
The problem is that I wasn't having the ingres client installed locally, so it appears that this lib cannot works without it