magento-hackathon / Magento-PSR-0-Autoloader

This Extension adds a PSR-0 Autoloader before the Magento Autoloader
60 stars 21 forks source link

doesn't work #2

Closed hgati closed 10 years ago

hgati commented 10 years ago

as far as I know, there is no the magento event observer such as "add_spl_autoloader". hence, it doesn't work. I'm using magento 1.7.0.2 and I've tried psr0 library https://github.com/technosophos/querypath

require 'app/Mage.php';
Mage::app();

$qp = new \QueryPath\DOMQuery('http://www.6pm.com/womens-shoes~1gp?s=recentSalesStyle/desc');
var_dump($qp);
 PHP Fatal error:  Class 'QueryPath\DOMQuery' not found in /var/www/magento/test.php on line 8
Flyingmana commented 10 years ago

Could you explain a bit more what you did try and what did not work?

Also, did you follow the readme?

mryvlin commented 10 years ago

If you are trying to use the autoloader in a shell script, please extend the class AutoloaderInitializer (shell/autoloader_initializer.php). The event add_spl_autoloader is our custom event which is fired to initialize the autoloader and is fired in the _construct method of this class.

hgati commented 10 years ago

Ok, I've solved.

I added the code below, when executing in command line mode,(php -f test.php)

Mage::getConfig()->init()->loadEventObservers('global'); 
Mage::app()->addEventArea('global'); 
Mage::dispatchEvent('add_spl_autoloader');

Great