https://github.com/compwright/codeigniter_classmap
A simple, lightweight classmap autoloader for CodeIgniter libraries
https://github.com/compwright/codeigniter_classmap
Last synced: 5 months ago
JSON representation
A simple, lightweight classmap autoloader for CodeIgniter libraries
- Host: GitHub
- URL: https://github.com/compwright/codeigniter_classmap
- Owner: compwright
- Created: 2013-04-08T18:48:35.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2013-04-08T19:16:54.000Z (over 12 years ago)
- Last Synced: 2025-03-27T14:47:50.781Z (9 months ago)
- Language: PHP
- Size: 99.6 KB
- Stars: 5
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Classmapper
===========
A tiny classmap autoloader for CodeIgniter.
Author: [Jonathon Hill](http://jonathonhill.net)
Use Case
--------
* You want to load classes without having them attached to the `$this` super-object.
* Your classes are interdependent, so that manual load calls have a high chances of
being executed more than once.
* You want a true autoloader in CodeIgniter.
Installation
------------
To install, copy the contents of this package into your CodeIgniter application directory and define a `pre_system` hook to call `Classmapper::register()`:
```
$hook['pre_system'] = array(
'class' => 'Classmapper',
'function' => 'register',
'filename' => 'Classmapper.php',
'filepath' => 'hooks',
);
```
Be sure to enable hooks in your main `config.php` file.
Usage
-----
Once Classmapper is installed, you have to manually configure the `config/classmap.php` file for each of the classes that you want to be able to autoload:
```
$classmap = array(
'Foolib' => APPPATH . 'libraries/Foolib.php',
'ThirdPartyClass' => APPPATH . 'third_party/package/Class.php',
);
```
You may now instantiate objects from the classes you defined without having to manually `require` or call `$this->load`, and the required file will be loaded automatically.
```
$foo = new Foolib();
```
Enjoy!