https://github.com/elusivecodes/fyreloader
FyreLoader is a free, open-source autoloader library for PHP.
https://github.com/elusivecodes/fyreloader
autoloader loader php psr4
Last synced: 5 months ago
JSON representation
FyreLoader is a free, open-source autoloader library for PHP.
- Host: GitHub
- URL: https://github.com/elusivecodes/fyreloader
- Owner: elusivecodes
- License: mit
- Created: 2021-10-22T11:46:06.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2024-11-15T10:08:39.000Z (about 1 year ago)
- Last Synced: 2024-11-15T15:46:10.978Z (about 1 year ago)
- Topics: autoloader, loader, php, psr4
- Language: PHP
- Homepage:
- Size: 128 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# FyreLoader
**FyreLoader** is a free, open-source autoloader library for *PHP*.
## Table Of Contents
- [Installation](#installation)
- [Basic Usage](#basic-usage)
- [Methods](#methods)
## Installation
**Using Composer**
```
composer require fyre/loader
```
In PHP:
```php
use Fyre\Loader\Loader;
```
## Basic Usage
```php
$loader = new Loader();
```
**Autoloading**
It is recommended to bind the *Loader* to the [*Container*](https://github.com/elusivecodes/FyreContainer) as a singleton.
```php
$container->singleton(Loader::class);
```
## Methods
**Add Class Map**
Add a class map.
- `$classMap` is an array containing the class map.
```php
$loader->addClassMap($classMap);
```
**Add Namespaces**
Add namespaces.
- `$namespaces` is an array containing the namespaces where the key is the namespace prefix and the value is the path.
```php
$loader->addNamespaces($namespaces);
```
**Clear**
Clear the auto loader.
```php
$loader->clear();
```
**Get Class Map**
Get the class map.
```php
$classMap = $loader->getClassMap();
```
**Get Namespace**
Get a namespace.
- `$prefix` is a string representing the namespace prefix.
```php
$paths = $loader->getNamespace($prefix);
```
**Get Namespace Paths**
Get all paths for a namespace.
- `$prefix` is a string representing the namespace prefix.
```php
$paths = $loader->getNamespacePaths($prefix);
```
**Get Namespaces**
Get the namespaces.
```php
$namespaces = $loader->getNamespaces();
```
**Has Namespace**
Determine whether a namespace exists.
- `$prefix` is a string representing the namespace prefix.
```php
$hasNamespace = $loader->hasNamespace($prefix);
```
**Load Composer**
Load composer.
- `$composerPath` is a string representing the composer autoload path.
```php
$loader->loadComposer($composerPath);
```
**Register**
Register the autoloader.
```php
$loader->register();
```
**Remove Class**
Remove a class.
- `$className` is a string representing the class name.
```php
$loader->removeClass($className);
```
**Remove Namespace**
Remove a namespace.
- `$prefix` is a string representing the namespace prefix.
```php
$loader->removeNamespace($prefix);
```
**Unregister**
Unregister the autoloader.
```php
$loader->unregister();
```