PHP代码格式化-PHPCB

PHP代码格式化(EditPlus+PHPCB)
DW_CS4居然只会格式化HTML和CSS代码,
G来G去也只有PHPCB这一个N久没更新过的经典PHP代码格式工具了,
命令行的,
用法“phpcb file.php > newfile.php”。
PHPCB(PHP Co de Beautifier),
整合不到DW里,DW里也没有格式化PHP代码的功能或插件,不过PHPCB可以整合到EditPlus上,
方法:
整合PHPCB到EditPlus:
EidtPlus:工具》配置用户工具…》添加工具: 菜单文本:PHPCB 命令:浏览到PHPCB程序。
参 数:--space-after-if --optimize-eol --space-after-switch --space-after- while --space-before-start-angle-bracket --space-after-end-angle-bracket --extra-padding-for-case-statement --glue-amperscore --change-shell-comment-to-double-slashes-comment --indent-with-tab --force-large-php-code-tag --force-true-false-null-contant-lowercase --comment-rendering-style PEAR --equal-align-position 50 --padding-char-count 1 "$(FilePath)"
初始目录:$(FileDir)
打勾:“以文本筛选器运行”,
下拉选择“替换” “应用”按钮。
另外,只想更好地使用PHPCB的话,提供一个操作批处理:
操作PHPCB的一个批处理
phpformat.bat:
:: 此文件的核心为 PHPCB 程序,PHPCB是一个格式化PHP代码的软件。
:: PHPCB的语法为: phpcb file.php > newfile.php
:: 本文件的用法为:phpf file.php
:: 本文件交给phpcb的命令为:phpcb file.php > file.php.formated.php
:: 本文件把文件交给PHPDB格式化后会打开格式化后的文件(用系统默认的程序)。@echo off setlocal
::是否提供格式化文件 if "%1" == "" goto noFile::文件是否存在 set fileName=%1 if /i not exist %fileName% set fileName=%fileName%.php if /i not exist %fileName% goto noFile
::文件类型是否正确 set ext=%fileName:~-4,4% if /i not "%ext%" == ".php" goto extError
::开始格式化,并打开 phpcb %fileName% > %fileName%.formated.php && start %fileName%.formated.php goto end
::输出错误信息 :extError echo Wrong: File Type Error echo Usage: phpf file.php goto end:noFile echo Wrong: File not found echo Usage: phpf file.php:end PHPCB
 
posted @ 2014-08-17 17:07  yJken的博客  阅读(1074)  评论(0编辑  收藏  举报