PHPackages                             theseer/autoload - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. theseer/autoload

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

theseer/autoload
================

A tool and library to generate autoload code.

1.29.4(5mo ago)393193.5k↓27.3%45[2 issues](https://github.com/theseer/Autoload/issues)[1 PRs](https://github.com/theseer/Autoload/pulls)7BSD-3-ClausePHPPHP &gt;=5.3CI passing

Since Nov 13Pushed 5mo ago13 watchersCompare

[ Source](https://github.com/theseer/Autoload)[ Packagist](https://packagist.org/packages/theseer/autoload)[ GitHub Sponsors](https://github.com/theseer)[ RSS](/packages/theseer-autoload/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (2)Versions (51)Used By (7)

PHP Autoload Builder
====================

[](#php-autoload-builder)

The PHP AutoloadBuilder CLI tool **phpab** is a command line application to automate the process of generating an autoload require file with the option of creating static require lists as well as phar archives.

Features
--------

[](#features)

- scan multiple directories recursively in one run, optionally follow symlinks, wildcards or based on composer.json
- Cache scan results
- Template based autoload code
- Custom variables for templates
- Compatibility mode for PHP 5.2 compliant autoloader
- Case sensitive as well as case insensitive classname mapping
- Phar generation, with or without compression and openssl key signing
- Static require list generation
- Opcache warming list generation
- Linting of generated code

Requirements
------------

[](#requirements)

- PHP 5.3+ (Runtime, for development / tests: 7.2+)
- Fileinfo (ext/fileinfo)
- Tokenizer (ext/tokenizer)
- For PHAR generation support:
    - ext/phar (write enabled: phar.readonly = Off)
    - ext/gzip (optional)
    - ext/bzip2 (optional)
    - ext/openssl (optional, for phar signing only)

Installation
------------

[](#installation)

### Executable PHAR

[](#executable-phar)

The recommended way to install **phpab** is by using [phive](https://phar.io):

```
phive install phpab

```

#### Manual install

[](#manual-install)

If you do not have phive installed or want to install manually, you can download the PHAR archive from the [Releases](https://github.com/theseer/Autoload/releases) tab.

*Please note:*On Linux/Unix based system the phar needs to be marked executable for direct execution:

```
[theseer@rikka ~]$ chmod +x phpab*.phar

```

Other Downloads
---------------

[](#other-downloads)

- [Latest development snapshot](https://github.com/theseer/Autoload/archive/master.zip) (ZIP Archive)
- [Releases (Source)](https://github.com/theseer/Autoload/tags)

Usage
-----

[](#usage)

```
Usage: phpab [switches]  [...]

  -i, --include       File pattern to include (default: *.php)
  -e, --exclude       File pattern to exclude

      --blacklist     Blacklist classname or namespace (wildcards supported)
      --whitelist     Whitelist classname or namespace (wildcards supported)

  -b, --basedir       Basedir for filepaths
  -t, --template      Path to code template to use

  -o, --output        Output file for generated code (default: STDOUT)

  -p, --phar          Create a phar archive (requires -o )
      --all           Include all files in given directory when creating a phar
      --alias         Specify explicit internal phar alias filename (default: output filename)
      --hash          Force given hash algorithm (SHA-1, SHA-256 or SHA-512) (requires -p, conflicts with --key)
      --bzip2         Compress phar archive using bzip2 (requires -p) (bzip2 required)
      --gzip          Compress phar archive using gzip (requires -p) (gzip required)
      --key           OpenSSL key file to use for signing phar archive (requires -p) (openssl required)

  -c, --compat        Generate PHP 5.2 compatible code
  -s, --static        Generate a static require file

  -w, --warm          Generate a static opcache warming file
      --reset         Add opcache reset call when generating opcache warming file

  -1, --prepend       Register as first autoloader (prepend to stack, default: append)
  -d, --no-exception  Do not throw exception on registration problem (default: throw exception)

  -n, --nolower       Do not lowercase classnames for case insensitivity

  -q, --quiet         Quiet mode, do not output any processing errors or information

      --cache   Enable caching and set filename to use for cache storage

      --follow        Enables following symbolic links (not compatible with phar mode)
      --format        Dateformat string for timestamp
      --linebreak     Linebreak style (CR, CRLF or LF, default: LF)
      --indent        String used for indenting or number of spaces (default: 16 (compat 12) spaces)

      --tolerant      Ignore Class Redeclarations in the same file
      --once          Use require_once instead of require when creating a static require file

      --trusting      Do not check mimetype of files prior to parsing (default)
      --paranoid      Do check mimetype of files prior to parsing

      --var name=foo  Assign value 'foo' to variable 'name' to be used in (custom) templates

      --lint          Run lint on generated code and exit
      --lint-php      PHP binary to use for linting (default: /usr/bin/php or c:\php\php.exe)

  -h, --help          Prints this usage information
  -v, --version       Prints the version and exits

```

### Usage Examples

[](#usage-examples)

```
[theseer@rikka ~]$ phpab -o src/autoload.php -b src composer.json

[theseer@rikka ~]$ phpab -o opcache_warming.php -w --reset src

[theseer@rikka ~]$ phpab -o src/autoload.inc.php src

[theseer@rikka ~]$ phpab -c -o src/autoload.inc.php src

[theseer@rikka ~]$ phpab -o src/core/autoload.inc.php -b src src

[theseer@rikka ~]$ phpab -p -o framework.phar -b src composer.json

[theseer@rikka ~]$ phpab -p -o framework.phar framework/src

[theseer@rikka ~]$ phpab -p -o framework.phar --bzip2 --key sign.key framework/src

[theseer@rikka ~]$ phpab -b . --tolerant -o zf1_autoload.php -e '*/Test/*' Zend

```

### Automation

[](#automation)

When using *phpab* it is necessary to recreate the autoload file every time a new class is created. This usually also happens after pulling from a repo or when switchting branches. Using a git `post-checkout` hook placed in `.git/hooks/post-update` this can be automated for most cases.

#### Basic Sample:

[](#basic-sample)

```
#!/bin/bash
phpab -c -o src/autoload.inc.php src
```

#### Sample using an `ant build.xml` file.

[](#sample-using-an-ant-buildxml-file)

```
#!/bin/bash
if [ -f build.xml ]; then
    ant -p | grep phpab > /dev/null

    if [ $? -eq 0 ]; then
        ant phpab > /dev/null &
    fi
fi
```

Template Variables
------------------

[](#template-variables)

The generated code is based uppon templates provided by default in the templates subfolder. The template engine allows for simply replacing of name based placeholders. For now, only a few default variables are defined but API hooks / CLI parameters exist to set custom variables.

Known variables are:

- `___CREATED___` Set to a timestamp of creation, format can be adjusted
- `___CLASSLIST___` The found list classes in form of a generated map
- `___BASEDIR___` If a Basedir is set, the value will get removed from the file path and get replaced by **DIR**

Used in PHAR Mode only:

- `___PHAR___` The filename of the generated phar or it's alias when --alias is given (see src/templates/phar.php.tpl)

Custom variables as defined by passing --var name=value via cli are accessed by pre- and appending \_\_\_ to it:

- `___name___` Going to be replaced by the value provided via cli param

Changelog
---------

[](#changelog)

The [changelog](https://github.com/theseer/Autoload/blob/master/CHANGELOG.md) moved to its own document

###  Health Score

60

—

FairBetter than 99% of packages

Maintenance71

Regular maintenance activity

Popularity53

Moderate usage in the ecosystem

Community35

Small or concentrated contributor base

Maturity71

Established project with proven stability

 Bus Factor1

Top contributor holds 84% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~90 days

Recently: every ~202 days

Total

50

Last Release

162d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/0fc8fe1ac311fb26137cc3b26cd6c1bbb58c9ac4f287eb9d8242a741cef9a502?d=identicon)[theseer](/maintainers/theseer)

---

Top Contributors

[![theseer](https://avatars.githubusercontent.com/u/111333?v=4)](https://github.com/theseer "theseer (398 commits)")[![remicollet](https://avatars.githubusercontent.com/u/270445?v=4)](https://github.com/remicollet "remicollet (28 commits)")[![sebastianbergmann](https://avatars.githubusercontent.com/u/25218?v=4)](https://github.com/sebastianbergmann "sebastianbergmann (14 commits)")[![hco](https://avatars.githubusercontent.com/u/156839?v=4)](https://github.com/hco "hco (7 commits)")[![edorian](https://avatars.githubusercontent.com/u/247397?v=4)](https://github.com/edorian "edorian (5 commits)")[![jrfnl](https://avatars.githubusercontent.com/u/663378?v=4)](https://github.com/jrfnl "jrfnl (4 commits)")[![martin-rueegg](https://avatars.githubusercontent.com/u/6409516?v=4)](https://github.com/martin-rueegg "martin-rueegg (4 commits)")[![gooh](https://avatars.githubusercontent.com/u/370948?v=4)](https://github.com/gooh "gooh (3 commits)")[![suve](https://avatars.githubusercontent.com/u/5345765?v=4)](https://github.com/suve "suve (1 commits)")[![unfunco](https://avatars.githubusercontent.com/u/1716636?v=4)](https://github.com/unfunco "unfunco (1 commits)")[![corburn](https://avatars.githubusercontent.com/u/1938738?v=4)](https://github.com/corburn "corburn (1 commits)")[![zonuexe](https://avatars.githubusercontent.com/u/822086?v=4)](https://github.com/zonuexe "zonuexe (1 commits)")[![Erkan-Yilmaz](https://avatars.githubusercontent.com/u/642286?v=4)](https://github.com/Erkan-Yilmaz "Erkan-Yilmaz (1 commits)")[![glensc](https://avatars.githubusercontent.com/u/199095?v=4)](https://github.com/glensc "glensc (1 commits)")[![GrahamCampbell](https://avatars.githubusercontent.com/u/2829600?v=4)](https://github.com/GrahamCampbell "GrahamCampbell (1 commits)")[![hpbuniat](https://avatars.githubusercontent.com/u/214626?v=4)](https://github.com/hpbuniat "hpbuniat (1 commits)")[![ktomk](https://avatars.githubusercontent.com/u/352517?v=4)](https://github.com/ktomk "ktomk (1 commits)")[![martin-helmich](https://avatars.githubusercontent.com/u/2538958?v=4)](https://github.com/martin-helmich "martin-helmich (1 commits)")[![owenvoke](https://avatars.githubusercontent.com/u/1899334?v=4)](https://github.com/owenvoke "owenvoke (1 commits)")

### Embed Badge

![Health badge](/badges/theseer-autoload/health.svg)

```
[![Health](https://phpackages.com/badges/theseer-autoload/health.svg)](https://phpackages.com/packages/theseer-autoload)
```

###  Alternatives

[theseer/phpdox

A fast Documentation generator for PHP Code using standard technology (SRC, DOCBLOCK, XML and XSLT) with event based processing

6012.4M145](/packages/theseer-phpdox)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
