• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
autoload problem using base classes a la Phil Sturgeon

#1
[eluser]LuckyFella73[/eluser]
In my application I did set up base classes like Phil Sturgeon
suggested in his blog. My problem is that I get error messages
in my log file:

Code:
ERROR - 2011-06-01 14:29:55 --&gt; Severity: Warning  --&gt; include_once(application/core/MY_Menu.php) [<a href='function.include-once'>function.include-once</a>]: failed to open stream: .....

I have a menu library in application/libraries (menu.php) and have this in autoload.php:
Code:
$autoload['libraries'] = array('database', 'menu');

I don't have a clue why the autoload function is looking for MY_menu.php in
application/core.

Is there anything I'm doing wrong? My application works but of course I don't like
to get error messages ..

#2
[eluser]WanWizard[/eluser]
Well, it should be looking, that's how CI's way of extending libraries work. But it should not be finding (if it is indeed not there) and therefore not include the file.

Any more details about the error? Filename? Line number? Which CI version?

#3
[eluser]pickupman[/eluser]
It seems odd that the error is being thrown for looking into /application/core folder as the menu class is not part of the core classes...Just checked the bottom part of the comments and see someone posted a fix for this:
Code:
function __autoload($class)
{
  if (strpos($class, 'CI_') !== 0)
  {
    if (is_file($location = APPPATH.'libraries/'.$class.EXT))
    {
      include_once $location;
    }
    // core folder is used by CodeIgniter 2
    else if (is_file($location = APPPATH.'core/'.$class.EXT))
    {
      include_once $location;
    }
  }
}

#4
[eluser]LuckyFella73[/eluser]
The error comes from config.php file. In my version it's line 380,
the line where Phils autoload function tries to include the
classes from application/core

The CI version is 2.0.2

In the meantime I found a post where it was suggested to add
Code:
if (file_exists(..))
to the autoloader part. I just wonder if that is the right way
because Phil didn't edit his tutorial that way.

Edit: while I was writing this thread pickupman posted his. Ok,
it seems not to be wrong to check if the file exists. But I'm still
wondering why the autoloader expect MY_menu.php in application/core
like pickupman noticed too.


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.