cmrcx/phptidy 问题修复 & 功能扩展

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

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

cmrcx/phptidy

Composer 安装命令:

composer require cmrcx/phptidy

包简介

PHP code formatter

README 文档

README

====== phptidy README ======


=== Description ===

This is a little tool for formatting PHP code. It aims to make the code better
readable and thus better understandable.

Unlike other beautifiers, phptidy does not completely reformat the code and
remove formatting, which was intended by the author. It only touches things
which are usually not intended. In case of doubt, phptidy will not touch
anything. Because of this strategy it is also very unlikely, that phptidy by
fault changes the functionality of the code.

phptidy is useful in many situations:

- You can use it on your own code during development to keep the code tidy,
  wasting no time on indenting and formatting by hand.

- In a project with more than one person coding you have less trouble with
  people who do not confirm to the style guide.

- If you use a version control system you can require all participating people
  to run phptidy before committing changes. Then you won't have anymore trouble
  with unintended changes due to code formatting or with the trailing
  whitespace or wrong line breaks of some brain dead editors (or their users).

- If you have to maintain some ultimately ugly code of someone else. After
  running phptidy the code will be much better readable. Well, the code will
  not be perfect, but it's a big help anyway.

The used coding standard is mainly inspired by the PEAR Coding Standards:
http://pear.php.net/manual/en/standards.php

phptidy is released under the GPL and can be used for free.


=== System Requirements ===

- PHP 5 or 7
    phptidy does not work on PHP 4, because some functions introduced in PHP 5
    are used, and there are also some differences in the tokens. But it should
    be not too difficult to port it to PHP 4.

- PHP CLI SAPI
    http://php.net/manual/en/features.commandline.php

- PHP extension: Tokenizer
    http://php.net/manual/en/book.tokenizer.php

 Optional:

- diff
    The standard Unix diff utility or similar
    Default is to use colordiff.
    Only required if you want to use phptidy's "diff" command.

- PHP extension: mbstring
    http://php.net/manual/en/book.tokenizer.php
    Only required if you want to use the configration variable $encoding to
    check the encoding of your PHP files.

 phptidy should work on most operation systems where PHP works. I use it in
 Linux and MacOS X. Some people use it also on Windows.


=== Installation ===

phptidy consists of only one file, phptidy.php. Execute this file on command
line to use it.

  $ ./phptidy.php

There is actually no need to install phptidy, you can run it also with the path
to the file on command line.

  $ ~/src/phptidy/phptidy.php

To be able to call phptidy without having to supply the path, you can copy
phptidy.php to a directory in your PATH, e.g. ~/bin (only for you)

  $ cp phptidy.php ~/bin

or /usr/local/bin (for all users).

  # cp phptidy.php /usr/local/bin

In the following examples I assume you have installed phptidy in your PATH.


=== Basic usage ===

The most simple case: You have a PHP script example.php and you want to tidy it
up.

  $ phptidy.php suffix example.php

phptidy will create a file "example.php.phptidy.php" with the tidy version of
your script.

To see what changes phptidy would make to your script, you can use phptidy's
"diff" command:

  $ phptidy.php diff example.php

If you are happy with the displayed changes, you can now overwrite the original
file with the tidy version by using the "replace" command:

  $ phptidy.php replace example.php

You will find a backup of the original version of the file in the hidden file
".example.php.phptidybak~".

If you have a project consisting of multiple files, you can supply all these
files as arguments:

  $ phptidy.php replace *.php inc/*.php


=== Using config files ===

If you have a project with many files, you can write the list of files in a
config file. Then you do not have to supply the list on the command line
anymore. The config file has to be named ".phptidy-config.php" and has to be in
the project's top level directory. To have the same effect as in the last
example the config file would have to have the following content:

  <?php
  $project_files = array("*.php", "inc/*.php");

Then you can call phptidy without the files list:

  $ phptidy.php replace

Please notice that when using config files, you always have to call phptidy
from the project's top level directory where also the config file resides.
Otherwise phptidy won't be able to find the config file.

With a config file you can also adjust phptidy's default settings to the
specific requirements of your project. See the phptidy source comments for a
list of available variables and their default settings.


=== Perspective ===

Don't hesitate to write me about your experiences with phptidy. Write me which
features you miss, what did not work for you, or just that it works fine. I
hope phptidy helps you with your projects as much as it helps me!

Magnus Rosenbaum <phptidy@cmr.cx>

cmrcx/phptidy 适用场景与选型建议

cmrcx/phptidy 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 630.56k 次下载、GitHub Stars 达 45, 最近一次更新时间为 2015 年 09 月 03 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 cmrcx/phptidy 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 cmrcx/phptidy 我们能提供哪些服务?
定制开发 / 二次开发

基于 cmrcx/phptidy 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 630.56k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 46
  • 点击次数: 18
  • 依赖项目数: 12
  • 推荐数: 0

GitHub 信息

  • Stars: 45
  • Watchers: 9
  • Forks: 14
  • 开发语言: PHP

其他信息

  • 授权协议: GPL-2.0
  • 更新时间: 2015-09-03