Skip to content

Latest commit

 

History

History
49 lines (39 loc) · 1.74 KB

README.md

File metadata and controls

49 lines (39 loc) · 1.74 KB

Simple PHP autoloader

About as simple as it gets and still be useful. Namespace friendly. Uses spl_autoload_register

Note: it assumes the following:

  • one class per file
  • filename is the same as the classname
  • classes are in a folder called 'classes'
    • change this by altering line 10 private $classesFolder = 'classes';
  • no filename duplication, ie folder1/myclass.php and folder2/myclass.php won't work

Also I used throwable from php7 in the catch() on line 53

If you're using php 5.x try something like

catch(Exception $ex){
    error_log($ex)
}

More help here.

structure

Looks as follows:

-------------------------------------------------------------------------------
 Language            Files        Lines         Code     Comments       Blanks
-------------------------------------------------------------------------------
 Markdown                1           33           33            0            0
 PHP                     4           88           51           24           13
-------------------------------------------------------------------------------
 Total                   5          121           84           24           13

├── classes
│   ├── autoloader.php
│   ├── dbstuff
│   │   └── mydb.php
│   └── frontendstuff
│       └── myfrontend.php
├── index.php
└── README.md

Use as you like, ask questions if stuck, and stars are nice (top right)...