Need Help With Phil's Sturgeons AutoLog - Giving Error Log Message |
[eluser]vincej[/eluser]
HI - Well, my first serious CI site is up. Thanks to all those who helped me along the way ! However I have one pesky error which shows up in my logs. It references Phil Sturgeon's "native auto load" functions in the config file. Essentially I looking at the error message (below) it is tell me that it can not find $class. But I do not know what do do about it. BTW - the maps all work PERFECTLY :O) Always Grateful for your advice !! Thanks !! Phils AutoLoad Function Code: <?php Error Message from the Logs Code: ERROR - 2012-10-19 09:05:33 --> Severity: Warning --> include_once(application/core/MY_Googlemaps.php) [<a href='function.include-once'>function.include-once</a>]: failed to open stream: No such file or directory /home/countr70/public_html/application/config/config.php 379 Here is the Code which Generates the GoogleMaps refered to in the Message: Code: <?php
[eluser]CroNiX[/eluser]
You only use the prefix MY_ when extending a CI core class, not your own. When CI loads controllers/libraries/helpers, it will automatically look in the core directory for it's own extensions prefixed with MY_. There is no CI Core class for Googlemaps or Jsmin, so what you are doing won't work. The documentation explains this. It sounds like you are just creating standalone classes that are meant to be used as "libraries" (similar to a controller but it can be used within any other controller)
[eluser]vincej[/eluser]
Thanks CroxNix - I thought so much, however, the mystery is that I have never created MY_Googlemaps or MY_JSMIN. Also when I go to application/core/MY_Googlemaps.php - it does not exist. Similarly when I do a search through my whole project for MY_Googlemaps or MY_JSMIN the search comes up empty except for in the error logs. so it is no wonder there is an error - but why would autoload think it is there when it is not ?
[eluser]vincej[/eluser]
OK I am totally missing what us causing the error in my code. I have thoroughly read the user guide as suggested and what I am doing fits with the user guide. I use a Googlemaps {} class produced by http://biostall.com/codeigniter-google-m...pi-library That class lives in the application/libraries directory. No where else. It is called from the controller, as above. I have undertaken a thorough search through my code and it the class exits no where else. Can anyone give me some advice as to why CI would grab my class and stick MY_ on the front when it is not included anywhere except where it is supposed to be i.e. application/libraries. Many Thanks !
[eluser]wiredesignz[/eluser]
CodeIgniter 2.x is still coded to use the PHP4 version of the class_exists() function to check for the user defined (MY_) extension of a core library. If your CodeIgniter application is running on a PHP5.x installation then the __autoload or spl_autoload function(s) will be called to additionally search for the missing class extension as well, and this is what is causing your error. http://php.net/manual/en/function.class-exists.php The solution is to modify Sturgeons simplistic __autoload function to exclude MY_ prefixed classes in addition to the CI_ prefixed classes.
[eluser]jmadsen[/eluser]
[quote author="wiredesignz" date="1351058708"]CodeIgniter 2.x is still coded to use the PHP4 version of the class_exists() function to check for the user defined (MY_) extension of a core library. If your CodeIgniter application is running on a PHP5.x installation then the __autoload or spl_autoload function(s) will be called to additionally search for the missing class extension as well, and this is what is causing your error. http://php.net/manual/en/function.class-exists.php The solution is to modify Sturgeons simplistic __autoload function to exclude MY_ prefixed classes in addition to the CI_ prefixed classes.[/quote] That can't be right - he says his two libraries are in the application/LIBRARIES dir. Are you sure about that? Everything points to them being in the application/core dir - in which case, the answer is move them to /libraries where they belong
[eluser]wiredesignz[/eluser]
@jmadsen, Read the error messages from log files provided by the OP. He is not trying to load any library class extensions which he notes in his second post, and nothing is in the wrong location. In fact his library is working correctly. The code used by CodeIgniter in it's library loader is actually in conflict with the simple PHP5 __autoload function provided by Sturgeon.
[eluser]jmadsen[/eluser]
EDIT: need to read carefully before posting EDIT AGAIN: Crap, I dunno. Was going to put my feet up with a book - looks like I'll be tracing CI loading code for the evening. I've never had this issue in several years of using that code snippet - I'll be interested in seeing what is causing it in this case.
[eluser]wiredesignz[/eluser]
Here is a 'modified' excerpt taken from Modular Extensions HMVC which deals with this issue. Code: public function __autoload($class)
[eluser]wiredesignz[/eluser]
[quote author="jmadsen" date="1351072499"]EDIT: need to read carefully before posting I have used Sturgeon's little workaround for several years now on a great many sites. I don't believe it is suddenly having a problem on two libraries out of the blue. [/quote] @jmadsen, Nothing is suddenly happening. Have you ever checked your error logs while using Sturgeons little workaround? Because of the way it is coded every library loaded will also cause the __autoload function to fire looking for a matching class extension in the application/core directory. You should get an error message for every missing file. For your own reference check out the CI_Loader::_ci_init_class() method and the use of the class_exists() function. |
Welcome Guest, Not a member yet? Register Sign In |