Reputation: 13948
I'm looking at Kohana framework and trying to go through the code to better understand how framework works.
So - from index.php we load:
require SYSPATH.'base'.EXT;
require SYSPATH.'classes/kohana/core'.EXT;
require APPPATH.'bootstrap'.EXT;
In core.php file we do the following:
public static $environment = Kohana::DEVELOPMENT;
What to we refer to by calling Kohana::DEVELOPMENT? From what I understand - by using :: we should be getting static constant from kohana class. - right? But at that moment in the code there is no Kohana class loaded that I could find. So - can someone explain what's going on here:) ? Thanks
RESOLUTION:
never mind. I didn't follow the code far enough. Kohana class extends Kohana_Core class. mmm. too bad there is no way to delete dumb questions from StackOverflow.
Upvotes: 0
Views: 636
Reputation: 352
For further information check this link: spl_autoload register. Kohana uses own implementation, which can be set in the bootstrap.php
file. You can found this funtion in the Core.php
file.
/**
* Enable the Kohana auto-loader.
*
* @link http://kohanaframework.org/guide/using.autoloading
* @link http://www.php.net/manual/function.spl-autoload-register
*/
spl_autoload_register(array('Kohana', 'auto_load'));
Upvotes: 0
Reputation: 53931
Kohana (as probably any other framework) uses "auto loading" mechanism. This allows you to use classes without including the files they are defined in by hand. The autoloader will automatically include/require the file that the Kohana
class is in.
So when you type Kohana::DEVELOPMENT
or new Kohana ();
the auto loader will load the file with the Kohana
class in it. You should know that this does not work magically. You have to write your own auto loader code for your framework.
You can read more about auto loading here.
Upvotes: 2