awps/loader

Simple loader that is designed to work with both classes and normal PHP files.

Maintainers

Details

github.com/awps/loader

Source

Issues

Installs: 51

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 0

Open Issues: 0

pkg:composer/awps/loader

1.0.1 2017-12-18 22:47 UTC

This package is not auto-updated.

Last update: 2025-10-12 10:08:08 UTC


README

Loader

A simple loader that is designed to work with both classes and normal PHP files.

Installation

With composer:

composer require awps/loader

Manually:

require_once 'getloader.php';

Usage

Load PHP classes:

Awps\Loader::loadClasses( $path, $namespace );

This will autoload all PHP classes from $path and will assume that the namespace in those classes is $namespace;

Load simple PHP files:

Awps\Loader::loadFiles( $path, $pattern );

This will autoload all php files from $path that contains $pattern in their name.

Examples

// Autoload classes from `inc` folder and set the namespace to `Awesome`
Awps\Loader::loadClasses( __DIR__ . 'inc', 'Awesome' );

// Now you can initialize a class. For example: 
new Awesome\Something();

// -------------------------------------------------------

// Include all php files from `functions`
Awps\Loader::loadFiles( __DIR__ . 'functions', 'component-' );

// This one will include all php files that contains `component-` string in their name
// from `functions` directory.
// Now you may call a function defined in one of those files. For example: 
do_something_special();