{"id":15524166,"url":"https://github.com/theseer/autoload","last_synced_at":"2025-05-14T15:02:33.338Z","repository":{"id":731732,"uuid":"381060","full_name":"theseer/Autoload","owner":"theseer","description":"A lightweight php namespace aware autoload generator and phar archive builder","archived":false,"fork":false,"pushed_at":"2025-03-07T20:20:34.000Z","size":1714,"stargazers_count":389,"open_issues_count":3,"forks_count":47,"subscribers_count":14,"default_branch":"master","last_synced_at":"2025-04-11T16:24:09.386Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/theseer.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["theseer"]}},"created_at":"2009-11-21T22:18:19.000Z","updated_at":"2025-03-07T20:20:37.000Z","dependencies_parsed_at":"2023-07-05T18:31:59.927Z","dependency_job_id":"cf88615c-078b-4fa5-ab6d-178c346222a3","html_url":"https://github.com/theseer/Autoload","commit_stats":{"total_commits":426,"total_committers":24,"mean_commits":17.75,"dds":0.2535211267605634,"last_synced_commit":"39eb04ee16634af2110c646a224c81b1f04bcf1f"},"previous_names":[],"tags_count":63,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theseer%2FAutoload","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theseer%2FAutoload/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theseer%2FAutoload/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theseer%2FAutoload/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/theseer","download_url":"https://codeload.github.com/theseer/Autoload/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248438825,"owners_count":21103480,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-02T10:49:24.060Z","updated_at":"2025-04-11T16:24:16.132Z","avatar_url":"https://github.com/theseer.png","language":"PHP","funding_links":["https://github.com/sponsors/theseer"],"categories":[],"sub_categories":[],"readme":"# PHP Autoload Builder\n\nThe PHP AutoloadBuilder CLI tool **phpab** is a command line application to automate the process of generating\nan autoload require file with the option of creating static require lists as well as phar archives.\n\n## Features\n\n* scan multiple directories recursively in one run, optionally follow symlinks, wildcards or based on composer.json\n* Cache scan results\n* Template based autoload code\n* Custom variables for templates\n* Compatibility mode for PHP 5.2 compliant autoloader\n* Case sensitive as well as case insensitive classname mapping\n* Phar generation, with or without compression and openssl key signing\n* Static require list generation\n* Opcache warming list generation\n* Linting of generated code\n\n## Requirements\n\n* PHP 5.3+ (Runtime, for development / tests: 7.2+)\n* Fileinfo (ext/fileinfo)\n* Tokenizer (ext/tokenizer)\n* For PHAR generation support:\n    + ext/phar (write enabled: phar.readonly = Off)\n    + ext/gzip (optional)\n    + ext/bzip2 (optional)\n    + ext/openssl (optional, for phar signing only)\n\n## Installation\n\n### Executable PHAR\n\nThe recommended way to install **phpab** is by using [phive](https://phar.io):\n\n```\nphive install phpab\n```\n\n#### Manual install\n\nIf you do not have phive installed or want to install manually, you can download the PHAR archive\nfrom the [Releases](https://github.com/theseer/Autoload/releases) tab.\n\n_Please note:_\nOn Linux/Unix based system the phar needs to be marked executable for direct execution:\n```\n[theseer@rikka ~]$ chmod +x phpab*.phar\n```\n\n## Other Downloads\n\n* [Latest development snapshot](https://github.com/theseer/Autoload/archive/master.zip)\u003c/a\u003e (ZIP Archive)\n* [Releases (Source)](https://github.com/theseer/Autoload/tags)\n\n## Usage\n```\nUsage: phpab [switches] \u003cdirectory1|file1|/path/to/composer.json\u003e [...\u003cdirectoryN|fileN\u003e]\n\n  -i, --include       File pattern to include (default: *.php)\n  -e, --exclude       File pattern to exclude\n\n      --blacklist     Blacklist classname or namespace (wildcards supported)\n      --whitelist     Whitelist classname or namespace (wildcards supported)\n\n  -b, --basedir       Basedir for filepaths\n  -t, --template      Path to code template to use\n\n  -o, --output        Output file for generated code (default: STDOUT)\n  \n  -p, --phar          Create a phar archive (requires -o )\n      --all           Include all files in given directory when creating a phar\n      --alias         Specify explicit internal phar alias filename (default: output filename)\n      --hash          Force given hash algorithm (SHA-1, SHA-256 or SHA-512) (requires -p, conflicts with --key)\n      --bzip2         Compress phar archive using bzip2 (requires -p) (bzip2 required)\n      --gzip          Compress phar archive using gzip (requires -p) (gzip required)\n      --key           OpenSSL key file to use for signing phar archive (requires -p) (openssl required)\n\n  -c, --compat        Generate PHP 5.2 compatible code\n  -s, --static        Generate a static require file\n  \n  -w, --warm          Generate a static opcache warming file\n      --reset         Add opcache reset call when generating opcache warming file\n\n  -1, --prepend       Register as first autoloader (prepend to stack, default: append)\n  -d, --no-exception  Do not throw exception on registration problem (default: throw exception)\n\n  -n, --nolower       Do not lowercase classnames for case insensitivity\n\n  -q, --quiet         Quiet mode, do not output any processing errors or information\n\n      --cache \u003cfile\u003e  Enable caching and set filename to use for cache storage\n\n      --follow        Enables following symbolic links (not compatible with phar mode)\n      --format        Dateformat string for timestamp\n      --linebreak     Linebreak style (CR, CRLF or LF, default: LF)\n      --indent        String used for indenting or number of spaces (default: 16 (compat 12) spaces)\n\n      --tolerant      Ignore Class Redeclarations in the same file\n      --once          Use require_once instead of require when creating a static require file\n\n      --trusting      Do not check mimetype of files prior to parsing (default)\n      --paranoid      Do check mimetype of files prior to parsing\n\n      --var name=foo  Assign value 'foo' to variable 'name' to be used in (custom) templates\n\n      --lint          Run lint on generated code and exit\n      --lint-php      PHP binary to use for linting (default: /usr/bin/php or c:\\php\\php.exe)\n\n  -h, --help          Prints this usage information\n  -v, --version       Prints the version and exits\n```\n\n### Usage Examples\n\n    [theseer@rikka ~]$ phpab -o src/autoload.php -b src composer.json\n\n    [theseer@rikka ~]$ phpab -o opcache_warming.php -w --reset src\n\n    [theseer@rikka ~]$ phpab -o src/autoload.inc.php src\n\n    [theseer@rikka ~]$ phpab -c -o src/autoload.inc.php src\n\n    [theseer@rikka ~]$ phpab -o src/core/autoload.inc.php -b src src\n\n    [theseer@rikka ~]$ phpab -p -o framework.phar -b src composer.json\n\n    [theseer@rikka ~]$ phpab -p -o framework.phar framework/src\n\n    [theseer@rikka ~]$ phpab -p -o framework.phar --bzip2 --key sign.key framework/src\n\n    [theseer@rikka ~]$ phpab -b . --tolerant -o zf1_autoload.php -e '*/Test/*' Zend\n    \n\n### Automation\n\nWhen using *phpab* it is necessary to recreate the autoload file every time a new class is created.\nThis usually also happens after pulling from a repo or when switchting branches.\nUsing a git `post-checkout` hook placed in `.git/hooks/post-update` this can be automated for most cases.\n\n#### Basic Sample:\n\n```bash\n#!/bin/bash\nphpab -c -o src/autoload.inc.php src\n```\n\n#### Sample using an `ant build.xml` file.\n\n```bash\n#!/bin/bash\nif [ -f build.xml ]; then\n    ant -p | grep phpab \u003e /dev/null\n\n    if [ $? -eq 0 ]; then\n        ant phpab \u003e /dev/null \u0026\n    fi\nfi\n```\n\n## Template Variables\n\nThe generated code is based uppon templates provided by default in the templates subfolder. The template engine\nallows for simply replacing of name based placeholders. For now, only a few default variables are defined\nbut API hooks / CLI parameters exist to set custom variables.\n\nKnown variables are:\n* ```___CREATED___```     Set to a timestamp of creation, format can be adjusted\n* ```___CLASSLIST___```   The found list classes in form of a generated map\n* ```___BASEDIR___```     If a Basedir is set, the value will get removed from the file path and get replaced by __DIR__\n\nUsed in PHAR Mode only:\n* ```___PHAR___```         The filename of the generated phar or it's alias when --alias is given (see src/templates/phar.php.tpl)\n\nCustom variables as defined by passing --var name=value via cli are accessed by pre- and appending ___ to it:\n* ```___name___```         Going to be replaced by the value provided via cli param\n\n## Changelog\n\nThe [changelog](https://github.com/theseer/Autoload/blob/master/CHANGELOG.md) moved to its own document\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftheseer%2Fautoload","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftheseer%2Fautoload","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftheseer%2Fautoload/lists"}