• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
config.php autoload question

#1
[eluser]LuckyFella73[/eluser]
Hi there,

I'm extending my controller like Phil suggested on his blog. For getting
that to work we have to place the "autoload - code" in our config.php

I never had a problem with that but in my actual project where I use the
old Ajax-Library (found in the CI Wiki) I get this error message in my logs:
Code:
ERROR - 2011-04-06 15:45:00 --&gt; Severity: Warning  --&gt; include_once(application/core/MY_Xajax.php) [<a href='function.include-once'>function.include-once</a>]: failed to open stream: No such file or directory D:\xampp\htdocs\edc\admin_201\application\config\config.php 388
ERROR - 2011-04-06 15:45:00 --&gt; Severity: Warning  --&gt; include_once() [<a href='function.include'>function.include</a>]: Failed opening 'application/core/MY_Xajax.php' for inclusion (include_path='.;\xampp\php\PEAR') D:\xampp\htdocs\edc\admin_201\application\config\config.php 388

I have CI 2.0.1 installed

I just would like to know why the autoload function is looking for MY_Ajax.php in application/core ?

#2
[eluser]internut[/eluser]
getting the same errors...

#3
[eluser]InsiteFX[/eluser]
Here is the new autoloader which was updated:
Code:
/*
| -------------------------------------------------------------------
|  Native Autoload - by Phil Sturgeon. New Version!
| -------------------------------------------------------------------
|
| Nothing to do with config/autoload.php, this allows PHP autoload to work
| for base controllers and some third-party libraries.
|
| If using HMVC you do not need this! HMVC will autoload.
|
| Place this code at the bottom of your application/config/config.php file.
*/
function __autoload($class)
{
    if (strpos($class, 'CI_') !== 0)
    {
        if (file_exists($file = APPPATH . 'core/' . $class . EXT))
        {
            include $file;
        }

        elseif (file_exists($file = APPPATH . 'libraries/' . $class . EXT))
        {
            include $file;
        }
    }
}
MY_Xajax should go into application/libraries I think.

InsiteFX

#4
[eluser]internut[/eluser]
I'm not using v2 but the older version.

Is this ok:

Code:
function __autoload($class)
{
if(strpos($class, 'CI_') !== 0)
{

    if (file_exists(APPPATH . 'libraries/'. $class . EXT ))  {
      @include_once( APPPATH . 'libraries/'. $class . EXT );

     }
}
}

?

Seems to be working on. Could I run into problems with this?

#5
[eluser]InsiteFX[/eluser]
It should work fine if your not using CI 2.0.+

InsiteFX

#6
[eluser]internut[/eluser]
thx @InsiteFX - seems to be working just fine.


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


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