get_instance() undefined in custom librairies ? :( |
[eluser]doMynation[/eluser]
Good day, Although I've seen many people pretending to do it without any error, I just can't access the CI core base using: Code: $CI =& get_instance(); It says the function is undefined. I need to load some CI ressources (helpers for example) within my library. Am I doing something wrong ? Even the user guide says it's the way to do it: http://ellislab.com/codeigniter/user-gui...aries.html Thank you !
[eluser]Colin Williams[/eluser]
Are you using your library within the CI app? Show some code that reproduces the error. That's always a vital first step when you think you've spotted a bug.
[eluser]doMynation[/eluser]
Well I've tested two things. First, I've tried simply modifying the Exceptions library (which is autoloaded, at least I think). Then I extended it, and added it to autoload in autoload.php.
[eluser]Michael Wales[/eluser]
To extend a CodeIgniter library you should just make a file named MY_Exceptions.php in the libraries directory (this is configurable via config.php).
[eluser]doMynation[/eluser]
Yes that's what I've done, and I still can't access the get_instance function. Sounds like the library is loaded BEFORE the CI_BASE.
[eluser]Colin Williams[/eluser]
Yeah, the exceptions class is kind of the exception. You are limited to what you can do in there.
[eluser]doMynation[/eluser]
Awww I see... lol. Well then, I'm simply trying to perform a quick redirection to the default controller when a controller or controller function is not found. Is there an easy to achieve this ? (I'm using clean URLs) I've read multiple post where they extend the CI_Route or CI_Extensions with a considerable amount of code. Is there a kind of "shortcut" for this ? |
Welcome Guest, Not a member yet? Register Sign In |