I'm using Symfony 2 and working with wamp server. After some time, i cannot access my pages anymore with that exception always showing, can't figuring why.
Here's the full stack trace :
in DebugClassLoader.php line 203
at DebugClassLoader->loadClass('Symfony\\Component\\HttpFoundation\\ParameterBag')
at spl_autoload_call('Symfony\\Component\\HttpFoundation\\ParameterBag') in Request.php line 240
at Request->initialize(array(), array(), array(), array(), array(), array([...]), null) in Request.php line 222
at Request->__construct(array(), array(), array(), array(), array(), array([...]), null) in Request.php line 1964
at Request::createRequestFromFactory(array(), array(), array(), array(), array(), array([...])) in Request.php line 281
at Request::createFromGlobals() in app_dev.php line 27
It seems the "DebugClassLoader" class is using reflection to analyze what's wrong and it throws an exception when getting to the ParameterBag class. A var_dump() shows that ParameterBag is implementing \IteratorAggregate and \Countable as expected but also some random class "o" which i can't figure where it comes from.
Prod environment will be an apache server running on a debian, maybe it will work on it but I'd better fix this on my current environment before going live.
All the code I have which may deal with ParameterBag is something like that :
$session = $request->getSession();
$session_id = $session->getId();
$webclient = $em->getRepository('AppBundle\Entity\WebClient')
->findOneBy(array("session_id" => $session_id));
...
Also note that clearing the cache does not fix this issue. (using php bin/console cache:clear [--env=dev])
PS: restarting apache fixes it, but it shows again later
I had that problem (not on ParameterBag but same exception in the same file), it was caused by a corrupted installation of APC. Try putting this line in your php.ini :
apc.cache_by_default = 0
In the [APC] block. If the error is gone for good, consider removing and reinstalling APC.
APC was not enabled. I tried to find if any other cache was installed to disable them but there was not. It still occurs on my dev environment.
However it does not seem to happen on my prod environment. I'll probably work with it.
If you while debugging try to clear server cache. You will face some error like:
Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 2444952 bytes) in C:\xampp\htdocs\project_name\vendor\symfony\symfony\src\Symfony\Bundle\FrameworkBundle\Command\CacheClearCommand.php on line 163
so to solve this issue you need to add below line in your php.ini and restart apache.
apc.cache_by_default = 0
Now see the magic. It will work fine.
thanks,
Anirudh Sood.
Update PHP version and restart the apache server.
To quote:
Currently, there are three supported versions of PHP i.e Versions 5.6, 7.0, 7.1and 7.2. As a modern-day web developer who works on different frameworks, packages need to have the multiple versions of PHP installed on your VPS.
During your development, not all your projects may support the latest version (V. 7.2) resulting you to downgrade to a much earlier version. In this tutorial, we will illustrate how to switch between the different versions of PHP from 7.2 to 7.0 to enable you to run your projects smoothly.
Related
I'm on MacOS 10.15.1 (19B88). PHP scripts that connect to MySQL over SSL were working before the upgrade, now they're throwing SIGILL the moment new PDO() runs. Basic reproduceable example:
<?php
new PDO('mysql:', null, null, [
PDO::MYSQL_ATTR_SSL_CERT => 'foo',
]);
This is happening with PHP 7.2 and 7.3.11 installed via homebrew, as well as with PHP 7.3.9 which ships with MacOS (/usr/bin/php). There's no exception to catch or anything, the process immediately throws SIGILL.
Bash shows the error as: Illegal instruction: 4
Fish shows the error as: fish: 'php test.php' terminated by signal SIGILL (Illegal instruction)
I've added Terminal/iTerm/php binaries to "Full Disk Access" in the security preference pane in case it's related to the new disk access permissions, but that didn't make a difference. Maybe the issue is too specific for help, and I don't see others reporting this, but I'm grasping here.
Deployer version 4.1.0
When running dep deploy test the following error is reported:
PHP Fatal error: Call to undefined function server()
server ftn is defined as follows in config file:
// Configure servers
server('test', 'test.server.com')
->user('user')
->identityFile('~/.ssh/id.pub', '~/.ssh/user', 'password')
->stage("test")
->env('deploy_path', '/var/www/project.com');
This is pretty much the standard as per the Deployer site. Has anyone else experienced this issue? If so how did you resolve it?
SOLUTION
Fixed issue by running the following cmd (Suggested in comments above by Ken)
dep init
Compared the auto-generated deploy.php file to the original. Noted that the following was omitted:
namespace Deployer;
Also noted that ->env has been replaced with ->set
I had the same problem using deployer on a Laravel 5.4 project:
I had installed deployer using composer, when removed it and worked with deployer.pharfile , everything worked fine.
Running phpunit tests using PhpStorm.
Receiving this error:
/usr/local/php5/bin/php
/private/var/folders/m8/k61mmmmj7g732j3pd0_91s0c0000gn/T/ide-phpunit.php
--configuration /Users/psteinheuser/unity/test/phpunit.xml DatabaseDumperTest
/Users/psteinheuser/unity/test/DatabaseDumperTest.inc Testing started
at 11:36 AM ...
Fatal error: Class IDE_PHPUnit_Framework_TestListener contains 1
abstract method and must therefore be declared abstract or implement
the remaining methods (PHPUnit_Framework_TestListener::addRiskyTest)
in
/private/var/folders/m8/k61mmmmj7g732j3pd0_91s0c0000gn/T/ide-phpunit.php
on line 504
Call Stack:
0.0013 340096 1. {main}() /private/var/folders/m8/k61mmmmj7g732j3pd0_91s0c0000gn/T/ide-phpunit.php:0
PHP Fatal error: Class IDE_PHPUnit_Framework_TestListener contains 1
abstract method and must therefore be declared abstract or implement
the remaining methods (PHPUnit_Framework_TestListener::addRiskyTest)
in
/private/var/folders/m8/k61mmmmj7g732j3pd0_91s0c0000gn/T/ide-phpunit.php
on line 504
Have found previous posts which have said this is fixed, though I seem to have the correct versions where it should work.
PHPStorm 7.1.3
phpunit 3.7.28
php 5.4.24
The OS is Mac 10.9.2
Have removed and re-installed PHPStorm, upgraded php, re-installed phpunit, restarted apache, rebooted, scratched my head, etc.
Running the phpunit tests manually from the terminal, works fine.
Looking at Preferences within PHpStorm, it seems to be pointing to phpunit correctly.
I'm thinking it's a permission or path issue, but I don't know where to look next.
Appreciate any input or direction.
In PHPStorm, the only way I was able to solve this was by manually updating the contents of the jar file where this error exists.
We're both on Mac OSX 10.9, so these instructions should work for you.
Begin by making a copy of the existing jar file:
cp /Applications/PhpStorm.app/plugins/php/lib/php.jar /Applications/PhpStorm.app/plugins/php/lib/php.jar.orig
Now, create a temporary directory to hold your jar file's contents and extract
mkdir ~/jarfiles
cd ~/jarfiles
jar xf /Applications/PhpStorm.app/plugins/php/lib/php.jar
Once extracted, you'll need to edit the phpunit.php file to add the missing method stub
vi scripts/phpunit.php
Around line 310 in my file is a class 'IDE_PHPUnit_Framework_TestListener'. Insert the following method stub:
public function addRiskyTest(PHPUnit_Framework_Test $test, Exception $e, $time){}
Now just re-pack your jar and replace it into your PhpStorm:
jar cf0 php.jar ./*
mv php.jar /Applications/PhpStorm.app/plugins/php/lib/php.jar
That fixed it for me. Hope it fixes it for you too. Good luck!
I'm trying to get PHPUnit up and running in my Symfony 2 app, but I'm running into a problem I can't seem to figure out.
When I run my unit test a Fatal Error is returned, this does not happen inside of a normal browser.
Test function
$client = static::createClient(array(), array(
'PHP_AUTH_USER' => 'test',
'PHP_AUTH_PW' => 'test',
));
$crawler = $client->request('GET', '/test/url');
Error in console
$ phpunit -c app/
PHPUnit 3.6.10 by Sebastian Bergmann.
Configuration read from /Acme/app/phpunit.xml.dist
PHP Fatal error: Call to undefined function xcache_get() in /Acme/vendor/aws-sdk-for-php/lib/cachecore/cachexcache.class.php on line 58
Fatal error: Call to undefined function xcache_get() in /Acme/vendor/aws-sdk-for-php/lib/cachecore/cachexcache.class.php on line 58
Line error refers to (In AWS SDK) L 58 is L 3 in this excerpt
public function read()
{
if ($data = xcache_get($this->id))
{
$data = $this->gzip ? gzuncompress($data) : $data;
return unserialize($data);
}
return false;
}
Any help much appreciated :-)
phpunit is using different ini file that does not load this extension
Try running php --ini from console, compare it with phpinfo() output from the browser to see what ini files are being loaded (most probably your web server runs on different user and may have it's own ini file)
Possible ways to fix it:
Editing ini used by cli and adding necessary options
By setting PHPRC enviroment variable to point to MAMP ini file
Create symlink to the MAMP ini file in php bin folder
Edit phpunit file and add -c path/to/ini after php binary
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).