1
votes

For all intents and purposes, this should be working.. But it's not.

Structure:

  • app / etc / modules / Company_Modulename.xml

    <?xml version="1.0"?>
    <config>
        <modules>
            <Company_Modulename>
                <active>true</active>
                <codePool>community</codePool>
                <version>1.0.0</version>
            </Company_Modulename>
        </modules>
    </config>
    
  • app / code / community / Company / Modulename / etc / config.xml

<?xml version="1.0"?>
<config>
    <modules>
        <Company_Modulename>
        <version>1.0.0</version>
        </Company_Modulename>
    </modules>
    <global>
        <helpers>
            <modulename>
                <class>Company_Modulename_Helper</class>
            </modulename>
        </helpers>
    </global>
 </config>
  • app / code / community / Company / Modulename / Helper / Data.php
<?php
class Company_Modulename_Helper_Data extends Mage_Core_Helper_Abstract
{
  public function sayHello() {
      die('hello');
  }
}
  • app / design / frontend / custom / default / template / page / 2columns-right.phtml
...
<?php Mage::helper('modulename')->sayHello(); ?>
...

This should be die'ing with the word 'hello'. Instead, I'm getting:

Warning: include(Mage/Modulename/Helper/Data.php): failed to open stream: No such file or directory in /var/www/html/testing/lib/Varien/Autoload.php on line 94

I've set all module files' permissions to 777 just in case. Any ideas?

Edit: I have tried renaming Data.php to Helper.php (also modified class name), and tried to invoke it with Mage::helper('modulename/helper')->... , as expected - it threw the same error, changed the file name it was looking for to Helper.php but kept using the same path.

Compilation is off, cache is disabled (clearing it before each test anyway)

1
Whenever the autoloader can't find the namespace (Warning: include(Mage/Modulename/Helper/Data.php):), it's usually because of a misspelling or file/directory not available in the include path. Check your config.xml and filesystem paths. - user439441
Heh. The path & config were correct. But while I was checking, I noticed the www-data user didn't have access to the files. Had to give it permission to the whole namespace folder (Company). Thanks for the tip, though. - Alex M

1 Answers

0
votes

Found the problem.

The www-data user had no permissions for the namespace (Company) directory.