如何将 PHP_Beautifier 集成到 NuSphere PHPed IDE 中?

发布于 2024-07-26 23:00:20 字数 48 浏览 9 评论 0原文

任何人都可以列出将 PHP_Beautifier 集成到 phped 中的步骤吗?

Can anyone list the steps to integrate PHP_Beautifier in phped.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

情独悲 2024-08-02 23:00:20

您应该尝试此处的步骤。 这些是集成将代码返回到编辑器的任何脚本的一般步骤。

步骤 5 中的注意事项:

<?php

$f = fopen("php://stdin", "r");
$s = fread($f, 100000); // should be big enough
fclose($f);
echo "\"" . $s . "\"";

?>

这应该被忽略,并且非常草率。 它类似于发布在此处的其他 PHPed 脚本的格式。

现在要了解如何实际使用 PHP_beautifier,请参考文档

引用文档:

  // Create the instance
  $oBeautifier = new PHP_Beautifier(); 

  /* snip optional stuff*/

  // Define the input file
  $oBeautifier->setInputFile(__FILE__); 

  // Define an output file.
  // $oBeautifier->setOutputFile(__FILE__.'.beautified.php');  No need for this

  // Process the file. DON'T FORGET TO USE IT
  $oBeautifier->process();

  // Show the file (echo to screen)
  $oBeautifier->show();

  // Save the file
  //$oBeautifier->save(); No Need for this.

好的,所以我们需要给它一个文件,但我查看了主 Beautifier.php 文件,它似乎以某种方式接受 STDIN。 因此,让我们编写脚本:

<?php

class BeautifyCode
{

    public function run()
    {
        require_once('path/to/Beautifier.php'); // It's the main file in the PEAR package

        // Create the instance
        $oBeautifier = new PHP_Beautifier();

        // Define the input file
        // I believe you leave blank for STDIN, looking through the code **
        $oBeautifier->setInputFile();
        // If that doesn't work try:
        // $oBeautifier->setInputFile('php://stdin');

        $oBeautifier->process();

        $oBeautifier->show();

        // If that doesn't work, try this:
        // echo utf8_decode($oBeautifier->get());
    }

}

$bc = new BeautifyCode;
$bc->run();

?>

将其保存为 PHP 文件,然后根据第一个链接的步骤 3 调用它。 我会安全地使用 @php5@,因为 PHP_beautifier 可能需要它。

我提前道歉,我不太确定 PHP_beautifier 如何处理 STDIN 输入。 我查看了代码,但无法确定。 另一种选择是始终先保存要清理的 PHP 文件,然后查看 phpED 文档以了解如何获取已打开和正在清理的 PHP 文件的路径。

如果我有更多时间查看 PHP_beautifier 包,我可以给出更明确的答案。

You should try the steps located here. These are general steps for integrating any script which returns code back to the editor.

Note in Step 5:

<?php

$f = fopen("php://stdin", "r");
$s = fread($f, 100000); // should be big enough
fclose($f);
echo "\"" . $s . "\"";

?>

This should be ignored and is pretty sloppy. It'd be something like the format from other PHPed scripts posted here.

Now to see how to actually use PHP_beautifier, refer to the documentation.

To quote the documentation:

  // Create the instance
  $oBeautifier = new PHP_Beautifier(); 

  /* snip optional stuff*/

  // Define the input file
  $oBeautifier->setInputFile(__FILE__); 

  // Define an output file.
  // $oBeautifier->setOutputFile(__FILE__.'.beautified.php');  No need for this

  // Process the file. DON'T FORGET TO USE IT
  $oBeautifier->process();

  // Show the file (echo to screen)
  $oBeautifier->show();

  // Save the file
  //$oBeautifier->save(); No Need for this.

OK so we need to give it a file instead, but I've looked in the main Beautifier.php file and it seems to accept STDIN in some manner. So let's make the script:

<?php

class BeautifyCode
{

    public function run()
    {
        require_once('path/to/Beautifier.php'); // It's the main file in the PEAR package

        // Create the instance
        $oBeautifier = new PHP_Beautifier();

        // Define the input file
        // I believe you leave blank for STDIN, looking through the code **
        $oBeautifier->setInputFile();
        // If that doesn't work try:
        // $oBeautifier->setInputFile('php://stdin');

        $oBeautifier->process();

        $oBeautifier->show();

        // If that doesn't work, try this:
        // echo utf8_decode($oBeautifier->get());
    }

}

$bc = new BeautifyCode;
$bc->run();

?>

So save this anywhere as a PHP file, and then call it according to Step 3 of the first link. I would be safe and use @php5@, as PHP_beautifier probably requires it.

I apologize in advance, I'm not exactly certain how PHP_beautifier handles the STDIN input. I looked through the code but could not tell for certain. Another option is to always save the PHP file you're cleaning first, and then look through the phpED documentation for how to get the path to the PHP file you have open and are cleaning.

If I had more to time to look through the PHP_beautifier package I could give a more definite answer.

究竟谁懂我的在乎 2024-08-02 23:00:20

您可以使用 STDIN 和 STDOUT 作为输入或输出

    // Create the instance
    $oBeautifier = new PHP_Beautifier();

    // Define the input file
    // I believe you leave blank for STDIN, looking through the code **
    $oBeautifier->setInputFile(STDIN);
    $oBeautifier->setOutputFile(STDOUT);
    $oBeaut->process();
    $oBeaut->save();

You can use STDIN and STDOUT as input or output

    // Create the instance
    $oBeautifier = new PHP_Beautifier();

    // Define the input file
    // I believe you leave blank for STDIN, looking through the code **
    $oBeautifier->setInputFile(STDIN);
    $oBeautifier->setOutputFile(STDOUT);
    $oBeaut->process();
    $oBeaut->save();
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文