I was trying to install Wordpress on our server to test, but in order to do that I had to upgrade our current PHP version to 5.3. I upgraded our PHP and I am now finding that our Purolator shipping module is no longer working. According to our host support the "purolator.php" file is missing data that the new version of PHP requires. Unfortunately, I can't revert our PHP version back and our programmer is away.
This is the error message I was able to get from our website host support team:
tail /var/www/vhosts/phantomcables.com/statistics/logs/error_log -f
[Thu Jul 19 08:34:28 2012] [error] [client 70.51.168.201] PHP Fatal
error: Class 'SoapClient' not found in
/var/www/vhosts/phantomcables.com/httpdocs/shippings/purolator.php on line
49, referer: https://phantomcables.com/index.php?dispatch=checkout.cart
These are lines 40 to 72:
function createPWSSOAPClient()
{
/** Purpose : Creates a SOAP Client in Non-WSDL mode with the appropriate authentication and
* header information
**/
//Set the parameters for the Non-WSDL mode SOAP communication with your Development/Production credentials
//echo DIR_SHIPPING_FILES."estimatingservice.wsdl";
$url = "https://webservices.purolator.com/PWS/V1/Estimating/EstimatingService.asmx";
$client = new SoapClient( DIR_SHIPPING_FILES."estimatingservice.wsdl",
array (
'trace' => true,
'location' => $url,
'uri' => "http://purolator.com/pws/datatypes/v1",
'login' => PRODUCTION_KEY,
'password' => PRODUCTION_PASS
)
);
//Define the SOAP Envelope Headers
$headers[] = new SoapHeader ( 'http://purolator.com/pws/datatypes/v1', 'RequestContext',
array (
'Version' => '1.0',
'Language' => 'en',
'GroupID' => 'xxx',
'RequestReference' => 'Rating Example'
)
);
//Apply the SOAP Header to your client
$client->__setSoapHeaders($headers);
return $client;
}
Any help would be greatly appreciated.
It seems like you did not have installed the php-soap package on your server.
Type
phpinfo();
in your code and check if 'Soap Client' is 'enabled'.
If not, I don't know your distribution and package manager, but here is the code for Fedora I use:
$ yum install php-soap
I suggest to do it with your programmer back or a sys admin by your sides, you never know what could happen. A backup is also useful before any installation!
You will need to add (or remove any comment characters before)
extension=soap.so
to your php.ini file, and then restart the web server.
If you are having trouble finding your php.ini file, create a page with the following:
<?php phpinfo();
and load that file in your browser.
On some systems, this setting may not actually live in php.ini. For example, if you are using Zend Server, the setting would live in /usr/local/zend/etc/conf.d/soap.ini.
So we reverted back to an older version of PHP, and re-enabled SOAP. apparently that was the issue, not sure why that didn't work with the newer version of PHP.
Again thank you for all of your help. This is a great community.
It is already posted here
Do the following:
Locate php.ini in your apache bin folder, I.e Apache/bin/php.ini
Remove the ; from the beginning of extension=php_soap.dll
Restart your Apache server
Look up your phpinfo(); again and check if you see a similar picture to the one above
If you do, problem solved!
Enable the SOAP extension, require it in your composer.json like so:
{
"require": {
"ext-soap": "*"
}
}
Related
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'm using PHP to try using the Google Cloud Spanner. I already did the gCloud settings and everything, and that's right. Now I need to make the connection via PHP to do a CRUD with the database that is in Spanner, but the code below always returns the error:
PHP Fatal error: Undefined constant 'Grpc\STATUS_UNKNOWN' in
/xxx/xxxx/www/vendor/google/cloud-spanner/Connection/Grpc.php on line
129
The code I have is:
<?php
require 'vendor/autoload.php';
use Google\Cloud\Spanner\SpannerClient;
/* Error start here */
$spanner = new SpannerClient([
'projectId' => 'my-project-id'
]);
$db = $spanner->connect('instance', 'database');
$userQuery = $db->execute('SELECT * FROM usuario WHERE login = #login', [
'parameters' => [
'login' => 'devteam'
]
]);
$user = $userQuery->rows()->current();
echo 'Hello ' . $user['login'];
The requirements I use in the composer are:
"require": {
"google/cloud": "^0.32.1",
"google/cloud-spanner": "^0.2.2"
}
I noticed that if I enter through the browser, the error presented above continues to appear. If I run the command php teste.php on the terminal, it runs the script correctly, ie, the terminal works and the browser does not.
Google Cloud PHP's spanner client is gRPC only. This means to use it you will need to install the gRPC PHP extension:
pecl install grpc
Once you have done that, add google/proto-client-php and google/gax to your composer.json and run composer update. After this is done, the error will be resolved.
For those wanting more detailed instructions, see this page for installing and enabling gRPC for PHP!
Since you mentioned that it works on CLI but not on browser, I can say that you need to enable the grpc extension on your php web server config.
E.g. Add
extension=grpc.so to your /etc/php/5.6/apache2/php.ini
I want to deploy symfony2 application. On localhost works perfect, the only difference my web directory is in public_html, but when I installed on my prod server, after register some user, the exception has been thrown. Looks like unserializing can't decode, my entity "0:{}":
ContextErrorException: Warning: Erroneous data format for unserializing 'CodeCats\PanelBundle\Entity\User' in /home/progress/domains/progress-checker.pl/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php line 869
in /home/progress/domains/progress-checker.pl/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php line 869
at ErrorHandler->handle('2', 'Erroneous data format for unserializing 'CodeCats\PanelBundle\Entity\User'', '/home/progress/domains/progress-checker.pl/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php', '869', array())
at unserialize('O:32:"CodeCats\PanelBundle\Entity\User":0:{}') in /home/progress/domains/progress-checker.pl/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php line 869
at ClassMetadataInfo->newInstance() in /home/progress/domains/progress-checker.pl/vendor/doctrine/orm/lib/Doctrine/ORM/UnitOfWork.php line 2444
at UnitOfWork->newInstance(object(ClassMetadata)) in /home/progress/domains/progress-checker.pl/vendor/doctrine/orm/lib/Doctrine/ORM/UnitOfWork.php line 2546
at UnitOfWork->createEntity('CodeCats\PanelBundle\Entity\User', array('id' => '1', 'username' => 'tomek11', 'email' => 'tomek11#gmail.com', 'password' => '2f5e325c351294588e238389d1cc86a39a0c58f2', 'grade' => 'USER', 'avatar_id' => null, 'companyEmail_id' => null), array()) in /home/progress/domains/progress-checker.pl/vendor/doctrine/orm/lib/Doctrine/ORM/Internal/Hydration/SimpleObjectHydrator.php line 132
at SimpleObjectHydrator->hydrateRowData(array('id1' => '1', 'username2' => 'tomek11', 'email3' => 'tomek11#gmail.com', 'password4' => '2f5e325c351294588e238389d1cc86a39a0c58f2', 'grade5' => 'USER', 'avatar_id6' => null, 'companyEmail_id7' => null), array('id1' => array('name' => 'id', 'type' => 'integer'), 'username2' => array('name' => 'username', 'type' => 'string'), 'email3' => array('name' => 'email', 'type' => 'string'), 'password4' => array('name' => 'password', 'type' => 'string'), 'grade5' => array('name' => 'grade', 'type' => 'string'), 'avatar_id6' => array('name' => 'avatar_id', 'type' => 'integer'), 'companyEmail_id7' => array('name' => 'companyEmail_id', 'type' => 'integer')), array()) in /home/progress/domains/progress-checker.pl/vendor/doctrine/orm/lib/Doctrine/ORM/Internal/Hydration/SimpleObjectHydrator.php line 48
Additional info: The magic gpc in turned on.
Update
my check.php result:
** Mandatory requirements **
OK PHP version must be at least 5.3.3 (5.4.29 installed)
OK PHP version must not be 5.3.16 as Symfony won't work properly with it
OK Vendor libraries must be installed
OK app/cache/ directory must be writable
OK app/logs/ directory must be writable
OK date.timezone setting must be set
OK Configured default timezone "Europe/Warsaw" must be supported by your installation of PHP
OK json_encode() must be available
OK session_start() must be available
OK ctype_alpha() must be available
OK token_get_all() must be available
OK simplexml_import_dom() must be available
OK detect_unicode must be disabled in php.ini
OK PCRE extension must be available
** Optional recommendations **
OK Requirements file should be up-to-date
OK You should use at least PHP 5.3.4 due to PHP bug #52083 in earlier versions
OK When using annotations you should have at least PHP 5.3.8 due to PHP bug #55156
OK You should not use PHP 5.4.0 due to the PHP bug #61453
OK When using the logout handler from the Symfony Security Component, you should have at least PHP 5.4.11 due to PHP bug #63379 (as a workaround, you can also set invalidate_session to false in the security logout handler configuration)
OK You should use PHP 5.3.18+ or PHP 5.4.8+ to always get nice error messages for fatal errors in the development environment due to PHP bug #61767/#60909
OK PCRE extension should be at least version 8.0 (8.32 installed)
OK PHP-XML module should be installed
OK mb_strlen() should be available
OK iconv() should be available
OK utf8_decode() should be available
WARNING posix_isatty() should be available
Install and enable the php_posix extension (used to colorize the CLI output).
OK intl extension should be available
OK intl extension should be correctly configured
OK intl ICU version should be at least 4+
WARNING a PHP accelerator should be installed
Install and enable a PHP accelerator like APC (highly recommended).
WARNING short_open_tag should be disabled in php.ini
Set short_open_tag to off in php.ini*.
OK magic_quotes_gpc should be disabled in php.ini
OK register_globals should be disabled in php.ini
OK session.auto_start should be disabled in php.ini
OK PDO should be installed
OK PDO should have some drivers installed (currently available: mysql, pgsql, sqlite)
Ok it's the issue (and possible solutions):
http://www.doctrine-project.org/jira/browse/DDC-3120
https://github.com/symfony/symfony/issues/11056
For those still coming across this issue, updating the doctrine/orm dependency worked.
My new doctrine dependency line in composer.json:
"doctrine/orm": ">=2.2.3,<2.5",
Then I updated composer as per usual from the command line: php composer.phar update
Since it's the top Google result for this error I'll just paste the dirty quick fix here to get you going more easily.
Note: In nearly every case you shouldn't modify any vendor files like this. However, if you have some dependency problem which couldn't be solved for some reason here's the trick for you.
This is a Doctrine error, so you should modify the Doctrine ORM bundle a bit.
Add your PHP_VERSION_ID to the newInstance() function in
/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php
The final result looks like this for me:
public function newInstance()
{
// echo PHP_VERSION_ID; die(); // Uncomment this, in case you don't know your PHP_VERSION_ID
if ($this->_prototype === null) {
if (PHP_VERSION_ID === 50429 || PHP_VERSION_ID === 50513 || PHP_VERSION_ID === 50603 || PHP_VERSION_ID === 70009) { // This is the tricky line
$this->_prototype = $this->reflClass->newInstanceWithoutConstructor();
} else {
$this->_prototype = unserialize(sprintf('O:%d:"%s":0:{}', strlen($this->name), $this->name));
}
}
return clone $this->_prototype;
}
The original solution can be found here: https://github.com/symfony/symfony/issues/11056
I had the same issue. I solved it by updating "doctrine/orm" package in Composer.json to "~2.4" version and then running:
composer update doctrine/orm
from the command line. This should only update the concerned package. After this refreshing the webpage and/or logging in again and the error was gone.
Hope this helps.
I'm a complete PHP/wamp noob but am just trying to get a simple bit of code to work. I'm using a library to help me out with OAuth for Twitter, and have been writing and testing my code with wamp on Windows.
This is my code:
<html>
<body>
<?php
include 'tmhOAuth.php';
include 'tmhUtilities.php';
$tweet_text = 'Test Tweet. If you can see this, my PHP code is working! Yay';
echo "Posting...\n";
$result = post_tweet($tweet_text);
echo "Response code: " . $result . "\n";
function post_tweet($tweet_text) {
$connection = new tmhOAuth(array(
'consumer_key' => 'xxxxxxxxxx',
'consumer_secret' => 'xxxxxxxxxxxx',
'user_token' => 'xxxxxxxxxxxxxxxxx',
'user_secret' => 'xxxxxxxxxxxxxx',
));
$connection->request('POST',
$connection->url('1/statuses/update'),
array('status' => $tweet_text));
return $connection->response['code'];
}
?>
</body>
</html>
And the error message I get:
Fatal error: Call to undefined function curl_init() in C:\wamp\www\PHP\tmhOAuth.php on line 581
tmhOAuth is one of the library files I'm using.
After a quick Google, I followed this tutorial:
http://www.phpmind.com/blog/2011/02/how-to-enable-curl-in-wamp/
I found php.ini in both the apache and php folders, and uncommented the lines about curl. I also replaced php_curl.dll in the ext folder with a different version of the file as instructed by another tutorial I found.
Please help
Did you check which php.ini is loaded with your PHP? Make php file and put phpinfo() in it, run it and check for "Loaded configuration file"
Did you restart webserver? Because php.ini is reloaded on webserver restart in Your case.
Is this class using https protocol? Then You need to uncomment openssl extension also.
A good you to test your PHP.INI configuration in windows, is to run the PHP-CLI or check the log.
You can open the cmd and run the command php to see what's going on with your conf.
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