1

I have this helper class file (currently reachable):

<?php

require_once dirname(__FILE__).'/securimage/securimage.php';

class Milyuncarros_Mobile_Helper_Captcha extends Mage_Core_Helper_Abstract
{
    public function check($value)
    {
        $securimage = new Securimage();
        return $securimage->check($value);
    }

    public function show($ns)
    {
        $img = new Securimage();
        if ($ns) $img->setNamespace($ns);
        $img->show();  // outputs the image and content headers to the browser
    }
}

I get this error:

Fatal error: require_once(): Failed opening required '/home/carros/public_html/includes/src/securimage/securimage.php' (include_path='/home/carros/public_html/includes/src:.:/usr/lib/php:/usr/local/lib/php') in /home/carros/public_html/includes/src/Milyuncarros_Mobile_Helper_Captcha.php on line 3

As you can notice, there's no /app directory in the failing path. But my helper class (and the needed securimage folder) is located at /app/code/local/Milyuncarros/Mobile/Helper.

Why is it failing at such wrong path?

1

This is due to compilation enabled. Use the following lines for require_once:

require_once BP.DS.'securimage'.DS.'securimage.php';

BP and DS are the pre-defined constants in Mage.php, BP is base path of install while DS is directory separator.

Hope this will resolve the issue even if compilation enabled.

  • yes, figured it yesterday :). expand the answer (i.e. what values are BP and DS fetched from). – Luis Masuelli Jul 16 '14 at 14:12
  • 1
    Updated the answer on your request. – MTM Jul 16 '14 at 15:37
1

Try Mage::getModuleDir('', 'Your_Extension'); and concat Helper. Check this question to see some more options about folders shortcuts.

  • found the error: the helpers are compiled, and the compiled files are sent to such "wrong" folder. – Luis Masuelli Jul 15 '14 at 22:21
  • Its a good practice to use this either way since Magento will detect the folders for the includes. – mbalparda Jul 15 '14 at 22:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.