PHPackages                             moonwalkingbits/wordpress-autoloader-composer-plugin - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. moonwalkingbits/wordpress-autoloader-composer-plugin

ActiveComposer-plugin

moonwalkingbits/wordpress-autoloader-composer-plugin
====================================================

A composer plugin enabling libraries/projects to autoload classes using the WordPress coding standards.

0.2.3(4y ago)0357[1 PRs](https://github.com/moonwalkingbits/wordpress-autoloader-composer-plugin/pulls)GPL-3.0-or-laterPHPPHP &gt;=7.4

Since Jun 12Pushed 2y ago1 watchersCompare

[ Source](https://github.com/moonwalkingbits/wordpress-autoloader-composer-plugin)[ Packagist](https://packagist.org/packages/moonwalkingbits/wordpress-autoloader-composer-plugin)[ RSS](/packages/moonwalkingbits-wordpress-autoloader-composer-plugin/feed)WikiDiscussions master Synced 1w ago

READMEChangelogDependencies (7)Versions (9)Used By (0)

WordPress Autoloader Composer Plugin
====================================

[](#wordpress-autoloader-composer-plugin)

To easily consume libraries following the [WordPress coding standards](https://developer.wordpress.org/coding-standards/wordpress-coding-standards/php/)this plugin enables the libraries to register namespace mappings in the composer configuration like any other autoloading standard.

A library can register any number of namespace mappings:

```
{
    "autoload": {
        "wordpress": {
            "Namespace\\": "path/to/classes/"
        }
    }
}
```

This plugin will generate a file named `wordpress-autoload.php` that resides in the composer vendor directory. The consumer of the library can include this file directly and it will work as expected. But you can also add the file to the list of autoloaded files in the composer configuration. Doing this allows you to use all possible autoloading standards simultaneously:

```
{
    "autoload": {
        "files": [
            "vendor/wordpress-autoload.php"
        ]
    }
}
```

The consumer can of course also define its own set of namespace mappings:

```
{
    "autoload": {
        "Additional\\Namespace\\": "path/",
        "files": [
            "vendor/wordpress-autoload.php"
        ]
    }
}
```

Just like the composer autoload file `wordpress-autoload.php` returns the autoloader instance. If you use `wordpress-autoload.php` directly you can store the return value of the include call in a variable and add more namespace mappings:

```
