Welcome Guest, Not a member yet? Register   Sign In
CI 2 ignores core folder.
#1

[eluser]dardar[/eluser]
I recently upgraded from 1.7.2.
I've moved my MY_Profiler.php to /core/ folder, but it just ignores /application/core folder.
If I move back this file to libraries, I'm getting error:
Code:
Fatal error: Call to undefined method CI_Profiler::ci_profiler() in C:\www\epg\application\libraries\MY_Profiler.php on line 13

My code looks like:
Code:
class MY_Profiler extends CI_Profiler {

    function __construct($config = array())
    {
        //add your needed sections to the _available_sections array here
        $this->_available_sections[] = 'mysection';
        $this->_available_sections[] = 'session';
        parent::CI_Profiler($config);
    }

this 13 line:
Code:
parent::CI_Profiler($config);
#2

[eluser]InsiteFX[/eluser]
Code:
/*
| -------------------------------------------------------------------
|  Native Autoload - by Phil Sturgeon.
| -------------------------------------------------------------------
|
| Nothing to do with config/autoload.php, this allows PHP autoload to work
| for base controllers and some third-party libraries.
|
| Place this code at the bottom of your application/config/config.php file.
*/
function __autoload($class)
{
    if (strpos($class, 'CI_') !== 0)
    {
        @include_once(APPPATH . 'core/' . $class . EXT);
    }
}

InsiteFX
#3

[eluser]Matthieu Fauveau[/eluser]
[quote author="dardar" date="1301115034"]I recently upgraded from 1.7.2.
I've moved my MY_Profiler.php to /core/ folder, but it just ignores /application/core folder.
If I move back this file to libraries, I'm getting error:
Code:
Fatal error: Call to undefined method CI_Profiler::ci_profiler() in C:\www\epg\application\libraries\MY_Profiler.php on line 13

My code looks like:
Code:
class MY_Profiler extends CI_Profiler {

    function __construct($config = array())
    {
        //add your needed sections to the _available_sections array here
        $this->_available_sections[] = 'mysection';
        $this->_available_sections[] = 'session';
        parent::CI_Profiler($config);
    }

this 13 line:
Code:
parent::CI_Profiler($config);
[/quote]

Should be
Code:
parent::_construct($options);
#4

[eluser]InsiteFX[/eluser]
And it should be placed into application/libraries not application/core

InsiteFX
#5

[eluser]dardar[/eluser]
@Matthieu Fauveau
Thank you, it works.

@InsiteFX I'm in a mess right now. Why not /core folder?
As Codeigniter2 documentation states:
Quote:For example, to extend the native Input class you'll create a file named application/core/MY_Input.php
( http://ellislab.com/codeigniter/user-gui...asses.html )

I would like to follow the official rules, but am I wrong here? Or maybe there is a mistake in documentation?
#6

[eluser]LuckyFella73[/eluser]
Quote:( http://ellislab.com/codeigniter/user-gui...asses.html )

I would like to follow the official rules, but am I wrong here? Or maybe there is a mistake in documentation?

You read the page dscribing how to extend "core classes" - which are found in
"system/core". The Profiler class is not a CI "core-member" Wink

There is a simple rule:
If you want to extend a CI class located in "system/core/" place your "MY_classextention"
in "application/core/". The same principle with classes saved in "system/libraries/" ..
#7

[eluser]blacklion[/eluser]
Further to this subject, I have been trying to replace the core Log class.
The manual page at http://ellislab.com/codeigniter/user-gui...asses.html shows that Log is a core system file but going on the instructions from LuckyFella73, it is in fact located in the system/libraries folder, not system/core.

However, I am still having trouble replacing this file into application/libraries. (Log.php)
If I remove the system/libraries version, all is ok.

I can't figure out why this is... I haven't yet tried extending it as it is so small, it's not worthwhile.

Can anyone tell me what I am doing wrong? (I'm a newb!)

Sorry for hijacking....

BL
#8

[eluser]InsiteFX[/eluser]
1) If the library you are extending is in system/libraries then your extended version goes into application/libraries !

2) If the library you are extending is in system/core then your extended version goes into application/core !

As LuckyFella73 stated above!

InsiteFX
#9

[eluser]blacklion[/eluser]
@InsiteFX: Thanks - I guess I wasn't clear enough - I was trying to ask 2 things;

1) The manual is (appears to be) wrong in that Log is not a core class - no biggie.
2) Replacing Log.php into application/libraries doesn't seem to work for me for some reason I can't figure.
I'm using:
class CI_Log {
...
}

But unless I remove the system/libraries/Log.php I can't get my version to work.
Any ideas?!

BL
#10

[eluser]InsiteFX[/eluser]
Ya, that's an Error in the CodeIgniter User Guide, the log.php class is in system/libraries.

Try this: not tested.
Code:
class Log extends CI_Log {

}

InsiteFX




Theme © iAndrew 2016 - Forum software by © MyBB