michaeluno / admin-page-framework-compiler
Admin Page Framework 的编译脚本,是一个 WordPress 开发框架。
1.2.0
2022-03-02 05:40 UTC
Requires
- php: >=5.6.20
- ext-curl: *
- ext-zip: *
- friendsofphp/php-cs-fixer: ^3.6
- matthiasmullie/minify: ^1.3
- michaeluno/php-classmap-generator: ^1.1.0
README
Admin Page Framework 的编译脚本,是一个 WordPress 开发框架。
安装
Composer
要使用 Composer 安装库,请运行
composer require michaeluno/admin-page-framework-compiler
基本用法
$oCompiler = new \AdminPageFrameworkCompiler\Compiler( $sSourceDirPath, $sDestinationDirPath ); $oCompiler->run();
选项
选项数组接受以下参数。
output_buffer
: (布尔值) 是否打印输出缓冲区。exclude_classes
: (数组) 包含要排除的类名的数组。css_heredoc_keys
: (数组,可选) 包含用于将 CSS 规则分配给变量的 heredoc/nowdoc 关键字的数组。对于 nowdoc 关键字,省略括号内的单引号。js_heredoc_keys
: (数组,可选) 包含用于将 JavaScript 脚本分配给变量的 heredoc/nowdoc 关键字的数组。对于 nowdoc 关键字,省略括号内的单引号。excludes
: (数组,可选) 存储不编译项信息的数组。这些项将被添加但不会格式化。classes
: (数组) 要从编译中排除的类名。paths
: (数组) 要从编译中排除的文件路径。file_names
: (数组) 要从编译中排除的具有文件扩展名的文件名。
combine
: (数组,可选) 合并选项inheritance
: (布尔值) 是否将同一目录中的具有层次关系的文件合并。exclude_classes
: (字符串|数组,可选) 要从合并中排除的类名。
search
: (数组) 目录搜索选项的参数。allowed_extensions
: (数组) 允许列出文件扩展名。例如[ 'php', 'inc' ]
exclude_dir_paths
: (数组) 要从列表中排除的目录路径。exclude_dir_names
: (数组) 要从列表中排除的目录基本名称。例如[ 'temp', '_bak', '_del', 'lib', 'vendor', ]
exclude_file_names
: (数组) 要从列表中排除的文件名子字符串。例如[ '.min' ]
exclude_substrings
: (数组) 要从列表中排除的路径子字符串。例如[ '.min', '_del', 'temp', 'library', 'vendor' ]
is_recursive
: (布尔值) 是否扫描子目录。ignore_note_file_names
: (数组) 忽略注释文件名,告知解析器跳过目录。当解析目录中存在其中一个文件时,将跳过该目录。默认:[ 'ignore-class-map.txt' ]
,
comment_header
: (数组,可选) 在生成的文件顶部插入的头部注释text
: (字符串,可选) 要设置的头部注释path
: (字符串,可选) 从中提取注释的文件路径class
: (字符串,可选) 使用其 doc-block 作为头部注释的类名type
: (字符串,可选) 指示要收集的数据类型。接受的值是DOCBLOCK
,CONSTANTS
。当type
是CONSTANTS
时,头部类的常量必须包括VERSION
,NAME
,DESCRIPTION
,URI
,AUTHOR
,COPYRIGHT
,LICENSE
。
class Sample_Registry { const VERSION = '1.0.0'; const NAME = 'Sample Project'; const DESCRIPTION = 'Provides an enhanced task management system for WordPress.'; const URI = 'https://en.michaeluno.jp/'; const AUTHOR = 'miunosoft (Michael Uno)'; const AUTHOR_URI = 'https://en.michaeluno.jp/'; const COPYRIGHT = 'Copyright (c) 2014, <Michael Uno>'; const LICENSE = 'GPL v2 or later'; const CONTRIBUTORS = ''; }
php_cs_fixer
: (数组,可选) PHP CS Fixer 选项。config
: (字符串,对象) 配置对象或配置文件路径。rules
: (数组) 包含自定义规则的数组。
code_formatters
: (数组,可选) 包含扩展自AbstractCodeFormatter
类的类名或对象实例的数组,用于格式化代码。当添加项目时,将调用get()
来检索过滤后的 PHP 代码。PHP 代码按文件逐个传递。
示例
$oCompiler = new \AdminPageFrameworkCompiler\Compiler( $sSourceDirPath, $sDestinationDirPath, [ 'output_buffer' => true, 'exclude_classes' => [], 'css_heredoc_keys' => [ 'CSSRULES' ], // to disable inline CSS minification, set an empty array 'js_heredoc_keys' => [ 'JAVASCRIPTS' ], // to disable inline JavaScript minification, set an empty array 'search' => [ 'allowed_extensions' => [ 'php' ], // e.g. array( 'php', 'inc' ) // 'exclude_dir_paths' => array( $sTargetBaseDir . '/include/class/admin' ), 'exclude_dir_names' => [ '_document', 'document', 'cli' ], 'exclude_dir_names_regex' => [ '/\.bundle$/' ], 'exclude_file_names' => [ 'AdminPageFramework_InclusionClassFilesHeader.php', 'AdminPageFramework_MinifiedVersionHeader.php', 'AdminPageFramework_BeautifiedVersionHeader.php', ], 'is_recursive' => true, ], 'include' => [ 'allowed_extensions' => [ 'js', 'css', 'map' ], // e.g. array( 'php', 'inc' ) ], 'comment_header' => [ 'path' => $sFilePath, ], ] ); $oCompiler->run();