I am deploying a symfony2 application to a server where php intl extension is not enabled. I have no say in this.
The answer to this question suggests a solution:
Possible to disable intl requirement for Symfony?
I have put the "symfony/intl": "3.0.*#dev" in my composer.json and everything updates fine. Must I do anything more to activate/enable it? In AppKernel like with bundles?
Now I get the following errors when I run check.php on deployment server:
PHP Fatal error: Uncaught exception 'ReflectionException' with message 'Extension intl does not exist' in /web/folk/eirik/030476/releases/20150528181203/app/SymfonyRequirements.php:658
Stack trace:
#0 /web/folk/eirik/030476/releases/20150528181203/app/SymfonyRequirements.php(658): ReflectionExtension->__construct('intl')
#1 /web/folk/eirik/030476/releases/20150528181203/app/check.php(6): SymfonyRequirements->__construct()
#2 {main}
thrown in /web/folk/eirik/030476/releases/20150528181203/app/SymfonyRequirements.php on line 658
I look at line 658 in SymfonyRequirements.php and find:
if (class_exists('Locale')) {
if (defined('INTL_ICU_VERSION')) {
$version = INTL_ICU_VERSION;
} else {
$reflector = new ReflectionExtension('intl');
ob_start();
$reflector->info();
$output = strip_tags(ob_get_clean());
preg_match('/^ICU version +(?:=> )?(.*)$/m', $output, $matches);
$version = $matches[1];
}
$this->addRecommendation(
version_compare($version, '4.0', '>='),
'intl ICU version should be at least 4+',
'Upgrade your <strong>intl</strong> extension with a newer ICU version (4+).'
);
}
I don't know much about this stuff, but I assume
new ReflectionExtension('intl') requires the intl exension to be enabled in php, which is no option for me.
But what is INTL_ICU_VERSION? And why is it not defined? And why won't the symfony/intl component fix this for me?
And btw
if (class_exists('Collator')) {
$this->addRecommendation(
null !== new Collator('FR_fr'),
'intl extension should be correctly configured',
'The intl extension does not behave properly. This problem is typical on PHP 5.3.X x64 WIN builds.'
);
}
I have also changed 'FR_fr' to 'en' here, this was an error given by check.php that disappeared when I made the change.
If you take a look into the file check.php you are running you'll see that it does not load the Composer autoloader therefore it makes no difference whether you have installed that Symfony Intl component or not, it'll keep failing because it's looking for a required extension that is not there. The SO question you linked does mention the problem got solved but it doesn't say that the check passed.
If that extension was your problem with your Symfony installation and the only locale you needed is "en" than the problem should have gone away already after you installed the Symfony Intl drop in replacement. Although if you want to run the check for other problems you can comment out those lines so the script can finish. Don't worry that script is totally decoupled from the framework, you can even delete it when you are done.
If you are using Capistrano for the deployment and you are running those checks on every deployment you might want to disable that as well, or customise that script for your needs.
Related
I upgraded from Symfony 3.1.5 to 3.2.0 yesterday morning and everything was fine up until an hour or so ago.
Now Symfony throws the following exception upon any type of access, including console commands:
[Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException]
The service "session.storage.metadata_bag" has a dependency on a
non-existent parameter "session.metadata.storage_key".
I have tried the following:
Backed out my most recent changes
Deleted var/cache/*
Here is the exception trace:
Exception trace:
() at /Volumes/Data01/Projects/Beck/WWUI/site/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/ParameterBag/ParameterBag.php:100
Symfony\Component\DependencyInjection\ParameterBag\ParameterBag->get() at /Volumes/Data01/Projects/Beck/WWUI/site/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/ParameterBag/EnvPlaceholderParameterBag.php:56
Symfony\Component\DependencyInjection\ParameterBag\EnvPlaceholderParameterBag->get() at /Volumes/Data01/Projects/Beck/WWUI/site/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/ParameterBag/ParameterBag.php:217
Symfony\Component\DependencyInjection\ParameterBag\ParameterBag->resolveString() at /Volumes/Data01/Projects/Beck/WWUI/site/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/ParameterBag/ParameterBag.php:187
Symfony\Component\DependencyInjection\ParameterBag\ParameterBag->resolveValue() at /Volumes/Data01/Projects/Beck/WWUI/site/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/ParameterBag/ParameterBag.php:177
Symfony\Component\DependencyInjection\ParameterBag\ParameterBag->resolveValue() at /Volumes/Data01/Projects/Beck/WWUI/site/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Compiler/ResolveParameterPlaceHoldersPass.php:39
Symfony\Component\DependencyInjection\Compiler\ResolveParameterPlaceHoldersPass->process() at /Volumes/Data01/Projects/Beck/WWUI/site/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Compiler/Compiler.php:120
Symfony\Component\DependencyInjection\Compiler\Compiler->compile() at /Volumes/Data01/Projects/Beck/WWUI/site/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/ContainerBuilder.php:565
Symfony\Component\DependencyInjection\ContainerBuilder->compile() at /Volumes/Data01/Projects/Beck/WWUI/site/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Kernel.php:484
Symfony\Component\HttpKernel\Kernel->initializeContainer() at /Volumes/Data01/Projects/Beck/WWUI/site/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Kernel.php:116
Symfony\Component\HttpKernel\Kernel->boot() at /Volumes/Data01/Projects/Beck/WWUI/site/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Console/Application.php:68
Symfony\Bundle\FrameworkBundle\Console\Application->doRun() at /Volumes/Data01/Projects/Beck/WWUI/site/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:122
Symfony\Component\Console\Application->run() at /Volumes/Data01/Projects/Beck/WWUI/site/bin/console:29
As you can see, it's part of Symfony, and not my code.
I am at a loss.
Has anybody else seen this?
Suggestions?
Edit 1:
Based on Dagon's suggestion that I check session.xml, and seeing that it appears correct, I decided to replace the
<argument>%session.metadata.storage_key%</argument>
tag with
<argument>_sf2_meta</argument>
in session.xml. This resulted in a new, similar error:
[Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException]
The service
"64e3c91c625381e3c2c0184cf9ea0c6d5353986d77aa111949ca6fb8b17a8f07_2"
has a dependency on a non-existent parameter "validator.mapping.
cache.prefix".
This isn't really an answer per-se, but is is a fix.
I renamed vendor to vendor-HOLD and then ran composer install. Problem gone.
I did a diff on the old and new session.xml files and found that the definition of the parameter was different. The version causing the error contained:
<parameter string="session.metadata.storage_key">_sf2_meta</parameter>
The newly installed version contained:
<parameter key="session.metadata.storage_key">_sf2_meta</parameter>
instead. Obviously other files were incorrect, as well, based on the experimental edit I did to session.xml. No clue as to what happened, but it's nice that composer install fixed it. Oh, and yes, I deleted vendor-HOLD afterwards.
I am trying to use semaphores on php but cannot get sem_get() function to work. Here is my PHP code:
<?php
$key = 123567;
$maxAcquire = 1;
$permissions = 0666;
$autoRelease = 1;
//it gives the error on the line below
$semaphore = sem_get($key, $maxAcquire, $permissions, $autoRelease);
sem_acquire($semaphore);
echo "hello world!";
sem_release($semaphore);
?>
When I try to run it with:
php semaphore.php
It prints this error:
PHP Fatal error: Uncaught Error: Call to undefined function sem_get()
in /root/semaphore.php:8
Stack trace:
#0 {main}
thrown in /root/semaphore.php on line 8
I am working on Arch Linux with PHP 7.0.3 (cli). I guess the solution is so simple but I couldn't find a way to fix it. If you could help me, I would appreciate it. Thanks.
Support for semaphores is not a standard feature of php.
It has to be activated via compiler --enable-sysvsem option when creating the php binary.
See explanation in manual: http://php.net/manual/en/sem.installation.php
Thank you all! I uncommented the line :
extension=sysvsem.so
on php.ini and it worked!
The semaphore extension is not available by default, as stated in the docs:
Support for this functions are not enabled by default. To enable System V semaphore support compile PHP with the option --enable-sysvsem . To enable the System V shared memory support compile PHP with the option --enable-sysvshm . To enable the System V messages support compile PHP with the option --enable-sysvmsg .
If you are on a hosted server, then that hosting service probably does not offer this.
Have a look at the docs. It feels like you do not have installed php with semaphores properly. Have a look at the installation instructions.
I am trying to install libgit2 and php-git. I've successfully downloaded and built libgit2.However, I face problem when I try to install php-git.
This is how I try to install it :
phpize
./configure --enable-git2-debug
make
make install
There's no problem with phpize. However, when I use make and make install, following errors are showed:
./php_git2.h:180:3: error: unknown type name 'git_smart_subtransport'
git_smart_subtransport *smart_subtransport;
./helper.h:58:42: error: unknown type name 'git_checkout_opts'; did you mean 'git_checkout_options'?
void php_git2_git_checkout_opts_to_array(git_checkout_opts *opts, zval **out TSRMLS_DC);
/usr/local/include/git2/checkout.h:295:3: note: 'git_checkout_options' declared here
} git_checkout_options;
^~~~~~~~~~~~~~~~~
./helper.h:62:41: error: unknown type name 'git_checkout_opts'; did you mean 'git_checkout_options'?
int php_git2_array_to_git_checkout_opts(git_checkout_opts **out, zval *array TSRMLS_DC);
^~~~~~~~~~~~~~~~~
git_checkout_options
and there are more errors. Why this happens?
These errors indicate that the header files for libgit2 do not correspond to the version which the PHP bindings expect.
The bindings have their own libgit2 version which they link statically, so it does not need/want to use a system-installed version, but this is where the header files are being read from (as indicated by the paths in the output).
It looks to be a bug in php-git that it reads system header files for libgit2, but that's the root of the issue. The bindings do not want you to install libgit2 on your system. Unless you need a system libgit2 for another purpose, removing it should fix the issue.
You should file a bug with the php-git project as failing to work when a version of libgit2 is installed on the system is a build system bug in its code.
I should have been clearer. Looks like it's not finding libgit2.
I am trying to use the HttpRequest class which should be in the PECL_HTTP extension of php.
I have php5 and used the following to install pecl_http.
sudo pecl install pecl_http
pecl/pecl_http is already installed and is the same as the released version 2.0.1
install failed
After that i enter into my php.ini:
[PHP]
extension=http.so
[...]
Then i restart my apache2 server, and try using the HttpRequest class, but it gives me the following error:
PHP Fatal error: Class 'HttpRequest' not found
What are possible error's i might have missed?
UPDATE: (Changed the title)
The Extension is not shown in phpinfo(), i set
extension=http.so
And checked if the http.so file is in my extension_dir. I really don't know how to make php recognise the extension.
UPDATE 2:
I managed to install extension, but the class still does not exist.
For others, i had to reference the other extensions pecl_http needs. (For me: propro.so, raphfr.so)
UPDATE 3:
I did not manage to make the Class visible, the answers below show some approaches with other classes.
I solved this issue by using CURL.
You have installed the new version of the extension which uses a completely different API. I still don't know how it works, but I will update my answer one I know. The Documentation of the new version is to be found at http://devel-m6w6.rhcloud.com/mdref/http.
To Install the old version, first uninstall the new verion and then execute
pecl install http://pecl.php.net/get/pecl_http-1.7.6.tgz
UPDATE: here are two examples from the documentation, both should work well:
one request (can be found at http://devel-m6w6.rhcloud.com/mdref/http/Client/enqueue):
<?php
(new http\Client)->enqueue(new http\Client\Request("GET", "http://php.net"),
function(http\Client\Response $res) {
printf("%s returned %d\n", $res->getTransferInfo("effective_url"), $res->getResponseCode());
return true; // dequeue
})->send();
multiple requests (can be found at http://devel-m6w6.rhcloud.com/mdref/http/Client/once):
<?php
$client = new http\Client;
$client->enqueue(new http\Client\Request("HEAD", "http://php.net"));
$client->enqueue(new http\Client\Request("HEAD", "http://pecl.php.net"));
$client->enqueue(new http\Client\Request("HEAD", "http://pear.php.net"));
printf("Transfers ongoing");
while ($client->once()) {
// do something else here while the network transfers are busy
printf(".");
// and then call http\Client::wait() to wait for new input
$client->wait();
}
printf("\n");
while ($res = $client->getResponse()) {
printf("%s returned %d\n", $res->getTransferInfo("effective_url"),
$res->getResponseCode());
}
In both examples you can use $res->getBody() to return the body of the response.
I couldn't test these examples but I have heard of other people that they work.
I had the same problem and solved it by arrange the order in wich extensions are loaded in php.ini
All my other extensions was loaded using their own .ini files in /etc/php5/mods_available.
In my apache2 error.log I noticed that json_decode was needed by http.so to load.
I created a file for http (http.ini) and a symlink in /etc/php5/apache/conf.d with a higher prefix than json.
my http.ini
; configuration for php http module
; priority=50
extension=raphf.so
extension=propro.so
extension=http.so
use the new pecl_http.2.0.6 like this
new http\Message();
or extend in your own class as extends http\Message
I get this error on my production server (CentOS 5.4 and php 5.3.5) :
Warning: include_once(PharData.php): failed to open stream: No such
file or directory in /var/www/ZendFramework/library/Zend/Loader.php on
line 146
Warning: include_once(): Failed opening 'PharData.php' for inclusion
(include_path='/var/www/fw:/var/www/vmms:/var/www/ZendFw/library:.:/usr/share/pear:/usr/share/php')
in /var/www/ZendFw/library/Zend/Loader.php on line 146
Fatal error: Class 'PharData' not found in
/var/www/vm/app/Backup.php on line 40
And this is the code which fail :
$phar = new PharData($imageBackupFile);
$phar->buildFromDirectory($imageDir);
Logger::info("Image directory backed up to: $imageBackupFile");
This code is working fine on my own computer.
PharData should be included by default in php 5.3+ ...
Thanks for your help!
UPDATE :
I am using the Zend Auto loader feature to load the good php files using this code :
require_once("Zend/Loader/Autoloader.php");
$autoloader = Zend_Loader_Autoloader::getInstance()->setFallbackAutoloader(true);
Zend autoloader is doing the include_once(PharData.php).
Just because Phar is bundled by default in PHP 5.3 doesn't mean that it's necessarily included in your install. When you build PHP with ./configure, you can pass the --disable-phar to disable the Phar extension.
To confirm this, run the following script:
<?php
phpinfo();
?>
One of the first sections to appear will be the Configure Command section. Review this section to see if the --disable-phar switch is present, and if there is a Phar section to the page in general.
If it's not present, you'll need to contact your host to have it enabled. There's a decent chance, however, that they won't do it for you since it could impact other users depending on how their servers are set up. If this is on your own machine, you'll need to either rebuild PHP without that switch, or install Phar manually from PECL (no idea if this would still work in 5.3, but I don't see why it wouldn't).