burdamagazinorg/thunder-dev-tools
Composer 安装命令:
composer require burdamagazinorg/thunder-dev-tools
包简介
Developer tools for Thunder distribution
README 文档
README
Code Style Guidelines
Thunder code style guidelines are in agreement with Drupal code styles. For general validation of files is used Drupal Coder. More detailed validation of JavaScript code is made by ESLint with predefined Drupal settings.
Drupal Coder
In order that Drupal Coder works, following steps should be executed.
- Install Composer (* this step can be skipped if composer already exists on system)
- Please follow guide on official page
- Install Drupal/Coder in global Composer directory
- Please follow installation guide on Packagist
Usage from command line:
# check Code for Drupal coding standards phpcs --standard=Drupal --extensions=php,module,inc,install,test,profile,theme '--ignore=*.md' -p <project root directory> # autocorrect code for Drupal coding standards phpcbf --standard=Drupal --extensions=php,module,inc,install,test,profile,theme '--ignore=*.md' <project root directory>
Additionally both commands can be used with option --standard=DrupalPractice for checking defined Drupal best practices.
ESLint
In order that ESLint works, following steps should be executed
- Install Node.js (* this step can be skipped if Node.js already exists on system)
- Official guide from Node.js page should be followed
- Install ESLint
npm install -g eslint
Usage from command line:
eslint <project root directory>
Thunder Guidelines Checker
This script is provided by Thunder Development Tools. It's wrapper for phpcs and eslint tools.
To initialize project with requirements execute:
vendor/bin/check-guidelines.sh --init
Please take in consideration that vendor/bin path could be customized in your root composer.json file.
Then some basic options for checking of code style guidelines can be used:
-cs, --phpcs use PHP Code Sniffer with Drupal code style standard -js, --javascript use ESLint with usage of project defined code standard -ac, --auto-correct apply auto formatting with validation of code styles
For example to check and correct php and javascript files with auto correction:
vendor/bin/check-guidelines.sh --phpcs --javascript --auto-correct
Integrate Code Style checking in PHPStorm
Drupal Coder
- In PHPStorm preferences search for:
Code Sniff - Select option
Languages & Frameworks | PHP | Code Sniffer - Open configuration dialog by pressing edit button [...]
- In Configuration dialog add new configuration or edit existing Local. Set correct path for phpcs by pressing edit button [...]. Path should be:
<composer home directory>/vendor/bin/phpcsand save that settings for Code Sniffer - To configure usage of PHP Code Sniffer select
Editor | Inspections - Option PHP Code Sniffer validation should already be filtered by Search. Enable that option.
- And for that validation procedure change Coding standard option to Drupal. (* sometimes PHPStorm doesn't recognize that coding standard has been changed if Drupal is preselected. It's sufficient just to select other coding standard and then put back to Drupal)
After these settings are saved in PHPStorm warnings with prefix phpcs: will be displayed in editor.
ESLint
- In PHPStorm preferences search for:
ESLint - Select option
Languages & Frameworks | JavaScript | Code Quality Tools | ESLint - Enable it
Default settings can be preserved. ESLint will automatically search for installed eslint command and also coding style configuration files from project will be used.
Git Hooks
Git Pre Commit Hook
To check is code valid before commit, git pre commit hook can be used with execution of thunder guideline checker script. Create script file .git/hooks/pre-commit in your project folder, with following content:
#!/bin/sh
vendor/bin/check-guidelines.sh --phpcs --javascript
Make sure that the file is executable. That will automatically validate files before commit and display possible problems and additionally commit will not be executed unless everything is correct and valid.
burdamagazinorg/thunder-dev-tools 适用场景与选型建议
burdamagazinorg/thunder-dev-tools 是一款 基于 Shell 开发的 Composer 扩展包,目前已累计 35.3k 次下载、GitHub Stars 达 5, 最近一次更新时间为 2016 年 06 月 26 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 burdamagazinorg/thunder-dev-tools 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 burdamagazinorg/thunder-dev-tools 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 35.3k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 5
- 点击次数: 12
- 依赖项目数: 11
- 推荐数: 0
其他信息
- 授权协议: GPL-2.0
- 更新时间: 2016-06-26