Download the PHP package pfaciana/composer-autoloader-plugin without Composer

On this page you can find all versions of the php package pfaciana/composer-autoloader-plugin. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package composer-autoloader-plugin

Composer Autoloader Plugin

Generate Composer bootstrap files from PHP attributes or directory patterns.

This package is a Composer plugin. It runs during composer dump-autoload, writes generated bootstrap files into vendor/composer by default, and registers those files with Composer's autoload.files list.

Install

After changing config, adding or removing autoload attributes, or changing matched files, regenerate Composer autoload files:

Understanding Patterns

A major feature of this plugin is that it can scan files by patterns. These patterns mirror the patterns used by .gitignore files. If you already know how to use a .gitignore file, then you know how to use patterns here. The only difference is this plugins uses "include" patterns instead of "ignore" patterns. So your patterns will likely be inverted from your .gitignore file.

This done using the pfaciana/includefile package, which is an inverted wrapper around automattic/ignorefile.

Both autoload-by-attr.patterns and autoload-by-dir.patterns use pfaciana/includefile.

Example patterns:


Attribute Autoloading

Attribute autoloading scans PHP files for functions or public static methods marked with an attribute, then generates a bootstrap file that calls them.

By default, it looks for #[AutoRun].

Default output autoload file location:

Inputs

Key Default Notes
attribute "AutoRun" Attribute name to scan for. Can include default args.
patterns ["src"] Files/directories to scan from cwd.
output "autoload_bootstrap.php" Relative paths write to vendor/composer; absolute paths are used as-is.
header "" PHP code inserted before generated imports and calls.String\|String[].
footer "" PHP code inserted after generated imports and calls. String\|String[].
cwd project root Base directory for patterns.
maxDepth 25 Maximum directory depth.

#[AutoRun] Arguments

Argument Default Notes
priority 10 Lower numbers run earlier.
import require_once How to load the PHP file that defines an attributed function. See below.
check false Whether to guard function-file imports with function_exists. See below.

Supported Import type values:

Import argument

import controls how the generated bootstrap loads PHP files.

This matters because PHP functions are not class-autoloaded. If an attributed function lives in src/functions.php, the generated bootstrap must load that file before it can call the function.

Generated output includes the file import before the function call:

Static methods are different. Composer can autoload the class, so static method entries usually do not need a file import:

Use none when the function or file is already loaded somewhere else.

Directory autoloading also uses import; there it controls how each matched file is included.

Check argument

check is only useful for attributed functions.

When check: true, the generated bootstrap wraps the file import in function_exists checks. If the function already exists, the file is not imported again.

Generated output:

Use this when a function file might already be loaded before Composer's generated bootstrap runs. It helps avoid fatal "Cannot redeclare function" errors.

Custom Attribute

AutoRun is only the default. You can scan for a different attribute name:

The configured attribute can also set default argument values:

Runtime

AutoRunPlugin::runtime() is a runtime version of the Plugin. It operates outside the context of Composer. It scans source code only. It does not load scanned files during discovery, so runtime attribute usage must be simple and statically readable.

Runtime-only rules:

Avoid in runtime mode:

Use Composer/plugin generation when you need PHP reflection to resolve aliases, constants, or more complex attribute arguments.


Directory Autoloading

Directory autoloading scans files by pattern and generates a bootstrap file that imports each matched PHP file.

Default output:

Pattern Examples

These examples use Git-style include/exclude patterns through pfaciana/includefile.

String patterns can also be newline-separated:

Inputs

Key Default Notes
patterns ["*"] Files/directories to import from cwd.
import require_once Import strategy for each matched file.
output "autoload_directory_files.php" Relative paths write to vendor/composer; absolute paths are used as-is.
header "" PHP code inserted before generated imports. String\|String[].
footer "" PHP code inserted after generated imports. String\|String[].
cwd project root Base directory for patterns.
maxDepth 25 Maximum directory depth.

Runtime

AutoloadPlugin::runtime() is a runtime version of the Plugin. It operates outside the context of Composer.


Performance

cwd is the scan root. The plugin starts file discovery from cwd, then applies patterns.

This matters for performance. If cwd is the project root, the plugin must walk files and directories from the project root before patterns can include or exclude them.

Negated patterns like !vendor and !node_modules help, but they still require the scanner to start at the root and decide what to skip.

If you only need files under one directory, set cwd to that directory.

Less efficient:

More efficient:

Use project root as cwd only when you need to scan across multiple root-level directories.


Notes

Use separate attribute groups when combining AutoRun with other attributes.


All versions of composer-autoloader-plugin with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
composer-plugin-api Version ^2.0
pfaciana/includefile Version ~0.3
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package pfaciana/composer-autoloader-plugin contains the following files

Loading the files please wait ...