maslosoft/hedron 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

maslosoft/hedron

最新稳定版本:2.0.2

Composer 安装命令:

composer require maslosoft/hedron

包简介

PHP source code class header applier

README 文档

README

Hedron Logo Maslosoft Hedron

PHP source code class header applier

Latest Stable Version License

Quick Install

composer require maslosoft/hedron

Documentation

Full Hedron Documentation

Keeping class headers consitent

When developing projects, we ofter require that file containing PHP class should have some predefined comment header. This might include package information, licensing, homepage address etc.

Apply all at once

This tools provides facility to modify class headers in entire project in a safe way - using PHP Tokenizer, so that it will only modify file if it's 100% safe to change it.

Hedron helps you make your class headers up to date and consistent. It will apply predefined header to all files containing namespaced class definitions.

Instalation

composer require maslosoft/hedron --dev

Usage

Preview list of files to apply headers

vendor/bin/hedron preview

Display rendered template

vendor/bin/hedron show

Apply header to all class files.

Backup/commit your project before continue. This will write headers to files.

vendor/bin/hedron commit

Configuration

Configuration can be provided in yaml file .hedron.yml in root of your project. Hedron also uses composer.json to make your config easier, or even unnessesary.

Here is how config might look like with example values (see .hedron.example.yml):

# All paths are realtive to your project root
# Root path or paths with sources. If blank will use composer.autoload paths.
sources: ""
# Path to template file, if blank will use vendor/maslosoft/hedron/templates/default.html (no it's not html)
template: ""
# Filter configuration, by default empty. Below is some example filter.
filter:
	whitelist:
		include:
			- app/*
		exclude:
			- app/cache/*
	blacklist:
		include:
			- app/controllers/*
		exclude:
			- app/cache/CacheProvider.php
# Reserved 
# This contains composer.json as array
composer: ""
tmp: ""

All of this configuration is available in template.

Template

Template uses handlebars as templating engine. It contains all data from .hedron.yml and composer.json.

Here is example, default template:

This software package is licensed under {{composer.license}} license.

@package {{composer.name}}
@licence {{composer.license}}
{{#each composer.authors}}
@copyright Copyright (c) {{name}} <{{email}}>
{{/each}}
{{#if composer.homepage}}@link {{composer.homepage}}{{/if}}

And after rendering it looks like that:

/**
 * This software package is licensed under New BSD license.
 *
 * @package maslosoft/hedron
 * @licence New BSD
 *
 * @copyright Copyright (c) Peter Maselkowski <pmaselkowski@gmail.com>
 *
 * @link http://maslosoft.com/hedron/
 */

Replacing

This script modifies source files en masse. For safety and robustness it uses native php tokenizer and replaces everything before namespace token. Only that. If there is no namespace declaration file will not be modified.

Resources

统计信息

  • 总下载量: 5.72k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 0
  • 依赖项目数: 9
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: AGPL-3.0-only
  • 更新时间: 2015-01-06