Sublime Text 2 install PHP-Beautifier

環境:Windows 7 x64

  1. 安裝 PHP
    1.1 http://windows.php.net/download/,選擇Installer最新版本下載安裝
    1.2 將PHP安裝路徑加至Windows系統環境變數Path內

  2. 安裝php pear
    2.1 下載http://pear.php.net/go-pear.phar至PHP目錄下
    2.2 使用命令提示字元(以系統管理者啟動),切換至PHP目錄,輸入php go-pear.phar進行安裝
    2.3 PHP目錄下會產生Pear_ENV.reg檔案,將它加入至系統內

  3. PHP安裝PHP_Beautifier
    3.1 在PHP目錄下,輸入pear install PHP_Beautifier-0.1.15進行安裝
    3.2 修改PHP目錄下的php_beautifier,將error_reporting(E^ALL)修改為error_reporting(0),大約在第55行
    3.3 修改PHP目錄下的php_beautifier.bat,將所有的改為/
    3.4 修改PHPpearPHPBeautifierFilter目錄下的Pear.filter.php及phpBB.filter.php,將require_once (‘PEAR/Config.php’);註解

  4. Sublime Text 2安裝PHP_beautifier
    4.1 Sublime Text 2安裝Package Control,進入Console模式(ctrl+`),輸入import urllib2,os; pf=’Package Control.sublime-package’; ipp=sublime.installed_packages_path(); os.makedirs(ipp) if not os.path.exists(ipp) else None; urllib2.install_opener(urllib2.build_opener(urllib2.ProxyHandler())); open(os.path.join(ipp,pf),’wb’).write(urllib2.urlopen(‘http://sublime.wbond.net/’+pf.replace(‘ ‘,’%20’)).read()); print ‘Please restart Sublime Text to finish installation’
    4.2 Perference -> Package Control (Ctrl+Shift+p),輸入install,輸入php beautifier進行安裝
    4.3 Perference -> Browse Packages,進入Pcakages套件目錄,切換至Phpbeautifier目錄,編輯php_beautifier.py,將26行的cmd = “php_beautifier”修改為”cmd = “PHP目錄/php_beautifier.bat”” <== 注意這邊的符號要打成/

This entry was posted in PHP, Sublime Text 2. Bookmark the permalink.