daa/project-tools
Composer 安装命令:
composer create-project daa/project-tools
包简介
Project development tools
README 文档
README
Composer based project tools to automate the following:
- Check php files for syntax errors
- Check php files for PSR Coding Standads
- Check php files for possible bugs, unused parameters, suboptimal code, etc.
- Ensure all project tests are being passed
- Lint assets (js, css, etc)
INSTALLATION:
Simply add daa/project-tools as a composer dependency.
# composer.json
"require-dev": {
...
"daa/project-tools": "~1.0"
}
USAGE:
If you are using git for your project use the scripts provided to configure the automate checks.
# composer.json
"scripts": {
"post-update-cmd": "Project\\Script\\GitHooks::setup",
"post-install-cmd": "Project\\Script\\GitHooks::setup"
}
After a composer update --dev, when ever you carry out a git commit, it will ensure there are no errors, coding standard issues or failing tests before processing the commit.
Note: May not work in some IDEs (eg. git hooks are ignored in Netbeans). I tend to use the command line.
You can configure the the pre-commit rules by modifying the $conf array in .git/hooks/pre-commit, the defaults are:
$conf = array(
'excludeTests' => false,
'codingStandard' => 'PSR2',
'messRules' => 'controversial',
''
);
and advanced configuration can be:
$conf = array(
'excludeTests' => true,
'codingStandard' => array('PSR2', 'symfony2'),
'messRules' => array('controversial', 'codesize', 'unusedcode'),
'customChecks' => array(
array('cmd' => 'scss-lint', 'ext' => 'css'),
array('cmd' => 'jscs --preset=jquery', 'ext' => 'js')
)
);
As you can see, in this example we hve added linters for our assets, but these extra checks could be anything.
ALTERNATIVE USE:
If you are not using git or don't want the checks to be automated hooks, you can use the tools manually.
use Project\Tool\CodeQualityTool;
// check an entire composer project
$tool = new CodeQualityTool();
$tool->run();
// check an entire composer project but without executing tests
$tool = new CodeQualityTool();
$tool->excludeTests();
$tool->run();
// check a set of files
$files = array('file1.php', 'file2.php');
$tool = new CodeQualityTool($files);
$tool->run();
// check a set of files without executing tests
$files = array('file1.php', 'file2.php');
$tool = new CodeQualityTool($files, true);
$tool->run();
You can also use individual modules
use Project\Tool\Checker\SyntaxErrorChecker;
use Project\Tool\Checker\CodingStandardsChecker;
// example of how to use a checker to check whole project
$checker = new SyntaxErrorChecker($projectDir);
if (!$checker->check()) {
throw new \Exception('There are syntax errors!');
}
// example of how to use a checker to check a set of files
$files = array('file1.php', 'file2.php');
$checker = new SyntaxErrorChecker($projectDir);
if (!$checker->check($files)) {
throw new \Exception('There are syntax errors!');
}
Have a look at Hooks/git/pre-commit and Tools/CodeQualityTool.php for more usage information.
daa/project-tools 适用场景与选型建议
daa/project-tools 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 26.03k 次下载、GitHub Stars 达 5, 最近一次更新时间为 2015 年 01 月 14 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 daa/project-tools 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 daa/project-tools 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 26.03k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 5
- 点击次数: 6
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-01-14