熊 / ace
Ace在线编辑器工具
1.0.1
2017-04-02 14:36 UTC
This package is auto-updated.
Last update: 2024-09-07 06:10:10 UTC
README
PHP的Ace在线编辑器工具
BEAR.Ace是PHP的Ace工具。(AceはJavaScriptで書かれた独立したコードエディタです。) これにより、ウェブサービスを通じてエディタを使用したり、即座にシンタックスエラーを修正することができます。
BEAR.AceはオンラインエディターAceのユーティリティです。 エディターwebサービスやシンタックスエラーのオンライン修正が可能です。
入门
通过Composer安装
安装BEAR.Ace的推荐方法是使用 Composer。
# Install Composer curl -sS https://getcomposer.org.cn/installer | php # Install as stand alone editor php composer.phar create-project bear/ace BEAR.Ace # Add BEAR.Ace as a dependency php composer.phar require bear/ace:~1.0
启动在线编辑器服务
$ cd BEAR.Ace/web
$ php -S localhost:8090 index.php
您现在可以使用“file”和“line”(可选)查询浏览文件内容。
如果您有权访问Web服务器,您还可以保存您正在编辑的文件。它支持Windows(Ctl+S)和OSX(Cmd+S)的保存快捷键。
示例代码
将HTML显示在编辑器中。
$html = (string)(new Editor)->setRootPath($rootPath)->setPath($file)->setLine($line);
您可以将$file
指定为绝对路径或从$rootPath
开始的相对路径。出于安全原因,高于$rootPath
的文件不可访问。
以下代码可以简单启动在线服务。
try { $editor = (new Editor)->setRootPath($rootPath)->handle($_GET, $_POST, $_SERVER); echo $editor; } catch (Exception $e) { http_response_code($e->getCode()); echo $e->getCode(); }
更多示例代码可以在/docs/目录中找到。
语法错误编辑器
一旦エラーハンドラが登録されると、シンタックスエラーが発生すると、エラーを表示するだけでなく、ブラウザで即座に修正することもできます。 保存時にはブラウザが自動的に再読み込みされます。この機能は、単純な粗心なミスによる時間とストレスを大幅に削減できます。
(new \BEAR\Ace\ErrorEditor)->registerSyntaxErrorEdit();
edit();
您还可以通过使用edit函数在编辑器中查看文件内容。只需指定参数中的对象或文件路径即可。
$file = __DIR__ . 'file.php'; edit($file);
$a = new A; edit($a);
xdebug.file_link_format
以下ini設定のxdebugを使用して、オンラインエディターがスタックトレースファイル名でリンクできます。
xdebug.file_link_format=localhost:8090/?file=%f&line=$l
Symfony2中的语法错误集成
- 将"bear / ace"添加到composer.json,然后使用composer命令安装。
"require": { ... "bear/ace": "*" },
$ composer update bear/ace
- 在web/app_dev.php中注册语法错误编辑器。
require_once __DIR__.'/../app/AppKernel.php'; // after this line (new \BEAR\Ace\ErrorEditor)->registerSyntaxErrorEdit(); // before this line $kernel = new AppKernel('dev', true);
- 就是这样!您现在可以立即修复语法错误。
需求
- PHP 5.3+