Loads Composer generated autoload files in Textpattern CMS

Installs: 38

Dependents: 6

Watchers: 2

Forks: 1

Type: textpattern-plugin

0.3.1 2014-03-28 22:55 UTC


Packagist | Twitter | GitHub | Donate

This Textpattern CMS plugin loads the autoload file generated by Composer dependency manager. Fits well together with textpattern/installer and textpattern/lock to complete the Textpattern and Composer integration. This plugin removes any need to manually import the autoload file, and allows plugins access their dependencies.


Using Composer:

$ composer require rah/rah_autoload:*

Using in your plugins

To use rah_autoload with your Composer distributed plugins, just add it as a dependency to your composer.json:

    "require": {
        "rah/rah_autoload": "*"

And that’s it. Rah_autoload gets installed with your plugin, the autoload file is loaded in Textpattern and you can access your dependencies.

Invoking the autoloader

The plugin and autoloader is invoked automatically as long as the plugin is enabled, but the autoloader can be invoked manually too, once installed. Normally this isn’t required, but if you want to make sure autoloader is initialized before you try to access your dependencies, you may invoke the plugin by our own in your plugin.

You will be able to invoke the autoloader like any other plugin using Textpattern’s native plugin management functions such as load_plugin() and require_plugin(). You don’t need to do anything other than load the plugin.

load_plugin('rah_autoload', true);

The above will initialize the autoloader as long as its installed, regardless of its type or status. The plugin and autoloader is initialized only once. Subsequent load and require statements don’t have any impact or eat resources. This basically means you can safely “spam” the load_plugin() when ever you need an autoloader or class maps generated by Composer.


Version 0.3.1 – 2014/03/28

  • Updated source comment.

Version 0.3.0 – 2014/03/24

  • Removed: xrstf/composer-php52 support.
  • Removed: Preferences. Due to textpattern-installer changes, the plugin can now work automatically. As plugin source is loaded from vendors directory, the source file itself will be able to tell where the autoloader is located.

Version 0.2.1 – 2013/05/20

  • Fixed: Reported version number.

Version 0.2.0 – 2013/05/20

  • Added: Can load PHP 5.2.0 autoloader files generated by xrstf/composer-php52.
  • Added: Preferences that let you manually configure the imported autoload files, and disable searching.

Version 0.1.0 – 2013/05/08

  • Initial release.