一个轻量级的 php 命名空间感知自动加载生成器和 phar 存档构建器
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.
The recommended way to install phpab is by using phive:
phive install phpabIf you do not have phive installed or want to install manually, you can download the PHAR archive from the 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…[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/*' ZendWhen 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.
#!/bin/bash
phpab -c -o src/autoload.inc.php srcant build.xml file.#!/bin/bash
if [ -f build.xml ]; then
ant -p | grep phpab > /dev/null
if [ $? -eq 0 ]; then
ant phpab > /dev/null &
fi
fiThe 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 DIRUsed 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 paramThe changelog moved to its own document
暂无开放 Issues,或尚未同步最近议题。