talesoft/tale-loader

A small and lightweight PSR-4 and PSR-0 compatible loader

0.1 2016-03-01 19:04 UTC

This package is auto-updated.

Last update: 2024-10-10 08:24:35 UTC


README

A Tale Framework Component

What is Tale Loader?

A PSR-4 and PSR-0 compatible loader without other dependencies

Installation

Install via Composer

composer require "talesoft/tale-loader:*"
composer install

Usage

Assuming the following structure:

/library
    /App.php
    /App
        /Middleware.php
    /Db.php
    /Db/Table.php

do

use Tale\Loader;


$loader = new Loader(__DIR__.'/library');
$loader->register();

and you're done.

To disable the loader you can unregister it (which it will do automatically upon destruction)

$loader->unregister();

If you want to map a namespace on your directory, use the second argument

$loader = new Loader(__DIR__.'/vendor/my/app', 'My\\App\\');

If your files are named differently, use the third parameter

$loader = new Loader(__DIR__.'/lib', 'My\\', '%s.class.php');

That's all it can do any probably ever will. Maybe optional class maps will be implemented.