I am trying to debug Magendo 1.9.2.4 app\code\core\Mage\Core\Controller\Varien\Router\Standard.php. I am using PhpStorm with Xdebug.
During the debug it shows me an error that it cannot find the class Abstract that it's referring to.
Here is the full log:
C:\xampp\php\php.exe -dxdebug.remote_enable=1 -dxdebug.remote_mode=req -dxdebug.remote_port=9000 -dxdebug.remote_host=127.0.0.1 C:\xampp\htdocs\vaimo\app\code\core\Mage\Core\Controller\Varien\Router\Standard.php
PHP Fatal error: Class 'Mage_Core_Controller_Varien_Router_Abstract' not found in C:\xampp\htdocs\vaimo\app\code\core\Mage\Core\Controller\Varien\Router\Standard.php on line 28
PHP Stack trace:
PHP 1. {main}() C:\xampp\htdocs\vaimo\app\code\core\Mage\Core\Controller\Varien\Router\Standard.php:0
Fatal error: Class 'Mage_Core_Controller_Varien_Router_Abstract' not found in C:\xampp\htdocs\vaimo\app\code\core\Mage\Core\Controller\Varien\Router\Standard.php on line 28
Call Stack:
0.0699 193008 1. {main}() C:\xampp\htdocs\vaimo\app\code\core\Mage\Core\Controller\Varien\Router\Standard.php:0
Process finished with exit code 255
Class Standard extends from Abstract class which is located in different file but in the same folder with Standard.
You are doing it wrong.
You are debugging your code in CLI environment ("PHP Script" type of Run/Debug Configuration). This way you are executing your C:\xampp\htdocs\vaimo\app\code\core\Mage\Core\Controller\Varien\Router\Standard.php file directly in terminal hence the Magento's bootstrap code (class autoloading etc) is not executed and PHP (yes, this error comes from PHP interpreter itself) is unable to find your parent class.
Solution: do not debug in CLI mode using "PHP Script" type of config -- debug it via browser as Web Application instead with correct type of config. This way normal Magento routine will be in place (autoloading/configs/db connection/etc) -- https://confluence.jetbrains.com/display/PhpStorm/Debugging+PHP+Web+Applications+with+Run+Debug+Configurations.
All debugging materials
Zero-configuration approach -- when you initiate debugging from the browser using xdebug browser extension or manually setting up cookie/xdebug param.
Related
I recently switched autoload in composer.json from classlist to psr-4. Then in terminal I ran vendor/bin/composer dump-autoload in the project root, which is a plugin directory.
My autoload settings:
"autoload": {
"psr-4": { "A\\" : "classes/A" }
}
There is only 1 class in ./classes/A so it was a concern when the console said it loaded 545 classes. I double checked that I was in the right (plugin) folder instead of the wordpress root.
It appears composer is recursively loading every wordpress class starting from 3 levels below. I get a list of errors, here are a few of the top ones.
owner#G700:/var/www/html/wptest2/wp-content/plugins/fvc$ vendor/bin/codecept run wpunit
Codeception PHP Testing Framework v2.5.6
Powered by PHPUnit 7.5.10 by Sebastian Bergmann and contributors.
Running with seed:
PHP Warning: call_user_func_array() expects parameter 1 to be a valid callback, class 'Utilities' not found in /var/www/html/wptest2/wp-includes/class-wp-hook.php on line 286
PHP Stack trace:
PHP 1. {main}() /var/www/html/wptest2/wp-content/plugins/fvc/vendor/lucatume/wp-browser/src/includes/isolated-install.php:0
PHP 2. activate_plugin() /var/www/html/wptest2/wp-content/plugins/fvc/vendor/lucatume/wp-browser/src/includes/isolated-install.php:210
PHP 3. do_action() /var/www/html/wptest2/wp-admin/includes/plugin.php:660
PHP 4. WP_Hook->do_action() /var/www/html/wptest2/wp-includes/plugin.php:465
PHP 5. WP_Hook->apply_filters() /var/www/html/wptest2/wp-includes/class-wp-hook.php:310
PHP Warning: require_once(../../vendor/autoload.php): failed to open stream: No such file or directory in /var/www/html/wptest2/wp-content/plugins/fvc/tests/wpunit/T1Test.php on line 2
PHP Stack trace:
PHP 1. {main}() /var/www/html/wptest2/wp-content/plugins/fvc/vendor/codeception/codeception/codecept:0
PHP 2. Codeception\Application->run() /var/www/html/wptest2/wp-content/plugins/fvc/vendor/codeception/codeception/codecept:43
PHP 3. Codeception\Application->run() /var/www/html/wptest2/wp-content/plugins/fvc/vendor/codeception/codeception/src/Codeception/Application.php:108
This is an autoload error right? Any idea how I can fix this?
In case this might be something else I am including the test file I am running. This is the only test file that should run with the command vendor/bin/codecept run wpunit
<?php
require_once("../../vendor/autoload.php");
require_once ('../../classes/A/T1.php');
class T1Test extends \Codeception\TestCase\WPTestCase
{
public function testAdd() {
$t1 = new \T1();
$this->assertEquals(1, 1);
$sum = $t1->add(5, 2);
$this->assertEquals(7, $sum, "didn't sum");
}
}
I have a problem with PhpStorm. I had trouble adding the Composer and Symfony commands to PhpStorm.
I receive a message of this style:
Problem Failed to parse output as xml: Error on line 2: Content is not
allowed in prolog.. Command php /root/Downloads/composer.phar list
--format=xml Output Fatal error: Uncaught Error: Class 'DOMDocument' not found in
phar:///root/Downloads/composer.phar/vendor/symfony/console/Descriptor/XmlDescriptor.php:90
Stack trace:
0 phar:///root/Downloads/composer.phar/vendor/symfony/console/Descriptor/XmlDescriptor.php(166):
Symfony\Component\Console\Descriptor\XmlDescriptor->getApplicationDocument(Object(Composer\Console\Application),
NULL)
1 phar:///root/Downloads/composer.phar/vendor/symfony/console/Descriptor/Descriptor.php(55):
Symfony\Component\Console\Descriptor\XmlDescriptor->describeApplication(Object(Composer\Console\Application),
Array)
2 phar:///root/Downloads/composer.phar/vendor/symfony/console/Helper/DescriptorHelper.php(69):
Symfony\Component\Console\Descriptor\Descriptor->describe(Object(Symfony\Component\Console\Output\ConsoleOutput),
Object(Composer\Console\Application), Array)
3 phar:///root/Downloads/composer.phar/vendor/symfony/console/Command/ListCommand.php(81):
Symfony\Component\Console\Helper\DescriptorHelper->describe(Object(Symfony\Component\Console\Ou
in
phar:///root/Downloads/composer.phar/vendor/symfony/console/Descriptor/XmlDescriptor.php
on line 90
Can you help me find the solution please ?
The version of PHP needs to be recent. On macOS by default you may end up with PHP 5.6, and PHPStorm actually choose /usr/bin/php as it's preferred option for commands.
I'm trying to use composer on my NAS (a good old D-Link DNS-323 running the incredibly good fonz fun plug 0.7).
I have my php installed in /ffp/bin/php.
When I install composer using the following command
php -r "readfile('https://getcomposer.org/installer');" | php -- --install-dir=/ffp/sbin --filename=composer
But when I do a simple less /ffp/sbin/composer, I have the following shebang set :
#!/usr/bin/env php
<?php
/*
* This file is part of Composer.
*
Unfortunatly, my NAS do not have the /usr/bin/env folder existing on my machine ...
So, how can I have composer referring to the correct php executable ?
Besides, I tried changing the declaration to use #!/ffp/bin/php, but when doing so, any composer run echoes the following result :
PHP Warning: PHP Startup: Unable to load dynamic library '/ffp/lib/php/extensions/no-debug-non-zts-20100525/gd.so' - File not found in Unknown on line 0
Warning: PHP Startup: Unable to load dynamic library '/ffp/lib/php/extensions/no-debug-non-zts-20100525/gd.so' - File not found in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library '/ffp/lib/php/extensions/no-debug-non-zts-20100525/sqlite.so' - File not found in Unknown on line 0
Warning: PHP Startup: Unable to load dynamic library '/ffp/lib/php/extensions/no-debug-non-zts-20100525/sqlite.so' - File not found in Unknown on line 0
PHP Fatal error: Uncaught exception 'PharException' with message 'phar "/mnt/HD_a2/ffp/sbin/composer" has a broken signature' in /mnt/HD_a2/ffp/sbin/composer:23
Stack trace:
#0 /mnt/HD_a2/ffp/sbin/composer(23): Phar::mapPhar('composer.phar')
#1 {main}
thrown in /mnt/HD_a2/ffp/sbin/composer on line 23
Fatal error: Uncaught exception 'PharException' with message 'phar "/mnt/HD_a2/ffp/sbin/composer" has a broken signature' in /mnt/HD_a2/ffp/sbin/composer:23
Stack trace:
#0 /mnt/HD_a2/ffp/sbin/composer(23): Phar::mapPhar('composer.phar')
#1 {main}
thrown in /mnt/HD_a2/ffp/sbin/composer on line 23
Of particular importance is the line
PHP Fatal error: Uncaught exception 'PharException' with message 'phar "/mnt/HD_a2/ffp/sbin/composer" has a broken signature' in /mnt/HD_a2/ffp/sbin/composer:23
How can i fix it ? In other words, how can I have a working php + composer installation on my NAS ?
So, how can I have composer referring to the correct php executable ?
A very simple solution is to create a shell script:
#!/bin/sh
/ffp/bin/php -n /ffp/sbin/composer "$#"
Make it executable, name it composer, put it in your path before /ffp/sbin (or rename /ffp/sbin/composer to composer.phar and update the above script too).
The -n flag tells PHP to not use php.ini. This is useful when there are many extensions loaded from php.ini; not loading them makes composer run faster. Especially xdebug is recommended to not be loaded by composer, for speed improvement.
I'm trying to install log4php in a very simple site (trying to learn how it works).
Apache is installed in /etc/ and vhost is defined as:
DocumentRoot "/home/fferri/workspace/site-tutorial/www"
ServerName tutorial.localhost
php_value auto_prepend_file "/home/fferri/workspace/site-tutorial/www/ConfigureSite.php"
My site is at /home/fferri/workspace/site-tutorial/www/ and log4php folder is at /home/fferri/workspace/site-tutorial/services/lib/log4php-0.9/src/log4php/
Then, I define
define('LOG4PHP_DIR', "/home/fferri/workspace/site-tutorial/services/lib/log4php-0.9/src/log4php/");
into ConfigureSite.php
And, into another file, I try to init log4php:
include(LOG4PHP_DIR."/Logger.php");
$log = Logger::getLogger("main");
$log->info("foo");
$log->warn("bar");
The error is always the same:
Fatal error: Class 'Logger' not found in /home/fferri/workspace/site-tutorial/services/lib/log4php-0.9/src/log4php/LoggerRoot.php on line 37
It's worth to say that LoggerRoot.php and Logger.php are in the same folder. I think I have a problem of paths because my server and my site aren't in the same folder, but I need some hint
Adding the complete stack trace of error:
[22-May-2012 11:34:38] PHP Fatal error: Class 'Logger' not found in /home/fferri/workspace/site-tutorial/services/lib/log4php-0.9/src/log4php/LoggerRoot.php on line 36
[22-May-2012 11:34:38] PHP Stack trace:
[22-May-2012 11:34:38] PHP 1. {main}() /home/fferri/workspace/site-tutorial/www/index.php:0
[22-May-2012 11:34:38] PHP 2. require_once() /home/fferri/workspace/site-tutorial/www/index.php:12
[22-May-2012 11:34:38] PHP 3. require_once() /home/fferri/workspace/site-tutorial/www/greet_at_opening.php:11
[22-May-2012 11:34:38] PHP 4. require_once() /home/fferri/workspace/site-tutorial/services/lib/log4php-0.9/src/log4php/Logger.php:24
[22-May-2012 11:34:38] PHP 5. require_once() /home/fferri/workspace/site-tutorial/services/lib/log4php-0.9/src/log4php/LoggerCategory.php:27
[22-May-2012 11:34:38] PHP 6. require_once() /home/fferri/workspace/site-tutorial/services/lib/log4php-0.9/src/log4php/spi/LoggerLoggingEvent.php:28
[22-May-2012 11:34:38] PHP 7. require_once() /home/fferri/workspace/site-tutorial/services/lib/log4php-0.9/src/log4php/LoggerManager.php:29
[22-May-2012 11:34:38] PHP 8. require_once() /home/fferri/workspace/site-tutorial/services/lib/log4php-0.9/src/log4php/LoggerHierarchy.php:28
So, first, Logger is found but on loading LoggerHierarchy, Logger isn't. Why????
SOLVED: The error is to use log4php-0.9 and php5 together. Downloading the library located in apache web (2.1), the problem is solved.
Thanks!
I think using dirname(__FILE__) will look better.
I also thought it would be the path...
Maybe the Class name defenition then. do you call new Logger in Logger.php?
What about something like:
include(LOG4PHP_DIR."/Logger.php");
$log = new Logger();
$log->info("foo");
The error is to use log4php-0.9 and php5 together. Downloading the library located in apache web (2.1), the problem is solved.
I have gone through various tutorials/posts to install PHPUnit with Selenium on my Ubuntu system. I believe I have everything setup as required:
/usr/share/php$ phpunit --version
PHPUnit 3.6.10 by Sebastian Bergmann.
So using the IDE I create my test, and save it for running, which appears to be setup as required. So I run the test using:
phpunit /home/retrobadger/working_files/tutorials/phpunit/selenium1.php
But everytime I run it, I get the error below:
PHP Fatal error: Class 'PHPUnit_Extensions_SeleniumTestSuite' not found in /usr/share/php/PHPUnit/Extensions/SeleniumTestCase.php on line 394
PHP Stack trace:
PHP 1. {main}() /usr/bin/phpunit:0
PHP 2. PHPUnit_TextUI_Command::main() /usr/bin/phpunit:46
PHP 3. PHPUnit_TextUI_Command->run() /usr/share/php/PHPUnit/TextUI/Command.php:130
PHP 4. PHPUnit_Runner_BaseTestRunner->getTest() /usr/share/php/PHPUnit/TextUI/Command.php:150
PHP 5. ReflectionMethod->invoke() /usr/share/php/PHPUnit/Runner/BaseTestRunner.php:124
PHP 6. PHPUnit_Extensions_SeleniumTestCase::suite() /usr/share/php/PHPUnit/Extensions/SeleniumTestCase.php:0
The file in extensions exists, and I have set very open priviledges to it. The only things I can think of are that either my SeleniumTestCase.php is faulty, or that I need to require another file no other tutorials have suggested.
Any recommendations would be greatly appreciated. I have little experience with PHPUnit so expect my mistake is a basic one.
Thanks for any advice you can give,
Dan
Check that you include PHPUnit when you call tests.. either in php.ini, or with IDE that you run, or explicitly - right now it just can't find class.. which means that PHPUnit is not reachable. Try a simplier class, PHPUnit_Extensions_SeleniumTestCase