Login   Register  
PHP Classes
elePHPant
Icontem

File: example.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Ivan Stojmenovic  >  Loader Class  >  example.php  >  Download  
File: example.php
Role: Example script
Content type: text/plain
Description: example
Class: Loader Class
Automatically load MVC and library classes
Author: By
Last change:
Date: 2 years ago
Size: 1,262 bytes
 

Contents

Class file image Download
<?php

// Initialize class or use static methods!

$load = new Loader();

/**
 * Load specific user library class
 */

$load->library('my_lib');
 
// or
Loader::library('my_lib');

/**
 * Load specific user controller class
 */

$load->controller('blog');
 
// or
Loader::controller('blog');


/**
 * Load specific user model class
 */

$load->model('Model_blog');
 
// or
Loader::model('Model_blog');

/**
 * Load specific config
 */

$load->config('database')
$load->config('route')
 
// or
Loader::config('database');
 
// Load more configs
$data = array('database','route','config','my_config');
$load->config('data');

// ADD NEW PATH FROM OTHER DIRECTORIES

// If u want do add new path and autoload all files from other dir, flow  // next steps.

// First add in __constructor new line like this.

spl_autoload_register(array($this,'my_new_directory'));

// After adding spl_autoload_register in __constructor u must create new // method with name "my_new_directory".

public function my_new_directory($class)
{
  if (
$class) {
     
set_include_path('app/my_dir_path');
     
spl_autoload_extensions('.php');
     
spl_autoload($class);
    }
}

// Dont forget to change path in index constants

?>