2017 © Pedro Peláez
 

library composer-wp-autoload

WordPress Core Autoloader for Composer.

image

schlessera/composer-wp-autoload

WordPress Core Autoloader for Composer.

  • Tuesday, August 30, 2016
  • by schlessera
  • Repository
  • 3 Watchers
  • 9 Stars
  • 12 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 1 Open issues
  • 2 Versions
  • 33 % Grown

The README.md

WordPress Core Autoloader for Composer

This is a custom autoloader generator and class map loader Composer plugin for WordPress Core., (*1)

It diverges from the default Composer autoloader setup in the following ways:, (*2)

  • The generated autoloader is compatible with PHP 5.2. Classes containing PHP 5.3+ code will be skipped and throw warnings.
  • The paths to the classes are relative to a set constant. The default constant being used is ABSPATH.
  • The class maps can optionally be configured to be case-insensitive.

Usage

In your project's composer.json, add the following lines:, (*3)

{
    "require": {
        "schlessera/composer-wp-autoload": "^1"
    },
    "scripts": {
        "post-install-cmd": [
            "WordPress\\ComposerAutoload\\Generator::dump"
        ],
        "post-update-cmd": [
            "WordPress\\ComposerAutoload\\Generator::dump"
        ],
        "post-autoload-dump": [
            "WordPress\\ComposerAutoload\\Generator::dump"
        ]
    },
    "extra": {
        "wordpress-autoloader": {
            "class-root": "ABSPATH",
            "case-sensitive": true
        },
    }
}

After the next update/install, you will have a vendor/autoload_wordpress.php file, that you can simply include and use to autoload classes within WordPress Core., (*4)

Valid "extra" Keys

You can configure the autoloader by providing "extra" keys under the "wordpress-autoloader" root key., (*5)

  • "class-root" :, (*6)

    String value that is used to replace the dirname($vendorDir) string. The default is "ABSPATH", to make the autoloader use the ABSPATH constant., (*7)

  • "case-sensitive":, (*8)

    Boolean value to configure whether the classmap loader should be case-sensitive or not. The default value is true., (*9)

Contributing

All feedback / bug reports / pull requests are welcome., (*10)

License

This code is released under the MIT license., (*11)

For the full copyright and license information, please view the LICENSE file distributed with this source code., (*12)

The Versions

30/08 2016

dev-master

9999999-dev

WordPress Core Autoloader for Composer.

  Sources   Download

MIT

30/08 2016

v1.0.0

1.0.0.0

WordPress Core Autoloader for Composer.

  Sources   Download

MIT