Jump to content

How Can I use autoload for my structure app?


OOPBeginner

Recommended Posts

I have three files  index.php, loader.php and BasePresenter.php. In directory Templates / layouts I have 2 file, index.php and header.php like a template files. How Can I automaticaly loaded these files with autoload function from BasePresenter? Thx

 

index.php

<?php


    // index.php


    // loader


    require_once 'loader.php';
     
    new BasePresenter();
      
     
?>

loader.php

 

<?php


// [ LIBS ]


                // notORM


                require_once 'libs/NotORM.php';


// [ MODELS ]


                // database


                require_once 'models/db.php';
                
                
 // [ PRESENTERS ]


                // base presenter


                require_once 'presenters/BasePresenter.php';
               
?>

BasePresenter.php

 

<?php


class BasePresenter {
    
    public function __construct( ) {
        
        function __autoload($class_name) {
    require_once($class_name.".php"); 
}


    
    
} }


?>
 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.