https://github.com/alleyinteractive/wordpress-autoloader
WordPress autoloader that follows WordPress coding standards
https://github.com/alleyinteractive/wordpress-autoloader
wordpress
Last synced: 3 months ago
JSON representation
WordPress autoloader that follows WordPress coding standards
- Host: GitHub
- URL: https://github.com/alleyinteractive/wordpress-autoloader
- Owner: alleyinteractive
- Created: 2022-02-01T21:02:09.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2025-01-27T13:52:58.000Z (6 months ago)
- Last Synced: 2025-03-19T08:48:51.819Z (4 months ago)
- Topics: wordpress
- Language: PHP
- Homepage:
- Size: 82 KB
- Stars: 7
- Watchers: 28
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
# WordPress Autoloader
[](https://packagist.org/packages/alleyinteractive/wordpress-autoloader)
[](https://github.com/alleyinteractive/wordpress-autoloader/actions/workflows/tests.yml)A PHP Autoloader that supports the [WordPress Coding
Standards](https://developer.wordpress.org/coding-standards/wordpress-coding-standards/php/). For example, a folder that looks like this would be autoloaded as:```
src/class-example-class.php -> Root_Namespace\Example_Class
src/trait-reusable-feature.php -> Root_Namesace\Reusable_Feature
src/feature/class-example-feature.php -> Root_Namespace\Feature\Example_Feature
```Supports `class`, `trait`, `interface`, and `enum` files and any level of
namespaces.## Installation
You can install the package via composer:
```bash
composer require alleyinteractive/wordpress-autoloader
```## Usage
```php
Alley_Interactive\Autoloader\Autoloader::generate(
'Plugin\\Namespace',
__DIR__ . '/src',
)->register();// Or register the autoloader manually.
spl_autoload_register(
Alley_Interactive\Autoloader\Autoloader::generate(
'Plugin\\Namespace',
__DIR__ . '/src',
)
);
```## Testing
```bash
composer test
```## Changelog
Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.