简体   繁体   English

在OSX中将PHP tidy扩展安装到XAMPP中

[英]Install PHP tidy extension into XAMPP in OSX

I tired to find out the solution by googling, but there is only a little information no similar posts. 我厌倦了通过谷歌搜索找到解决方案,但是只有很少的信息没有类似的帖子。

I installed XAMPP 1.8.3 in OSX and I am trying to install tidy extension for php. 我在OSX中安装了XAMPP 1.8.3,并且正在尝试为php安装整洁的扩展。

However, from the result of researching, there are only some teaching how to install the extension to OSX but not XAMPP, or maybe I misunderstood the whole thing..... 但是,从研究的结果来看,只有一些关于如何将扩展安装到OSX而不是XAMPP的教导,或者也许我误解了整个过程.....

Yet, I am not familiar with the command line, 但是,我对命令行不熟悉,

can you tell me how can I install the extension to XAMPP (the command line??) or some sites that I can refer to?? 您能告诉我如何将扩展安装到XAMPP(命令行?)或我可以引用的某些站点吗?

Thank you very much!!! 非常感谢你!!!

In general: you have two options. 通常,您有两种选择。 Command line tidy (which is easy to install with Homebrew) and the PHP Extension. 命令行整洁(可通过Homebrew轻松安装)和PHP扩展。 You can test for both (for example from PHP) like this: 您可以像这样测试两者(例如从PHP):

1) Tidy 1)整洁

$command = "tidy -version";
exec($command, $return, $code);
if (count($return) > 0) {
    echo "Tidy available!";
}

2) PHP Tidy 2)PHP整理

if (extension_loaded("tidy")) {
    echo "PHP Tidy loaded!";
}

Since the first approach always has worked for me smoothly I never tried the PHP extension. 由于第一种方法始终对我有效,因此我从未尝试过PHP扩展。

So you will need the Terminal! 因此,您将需要终端!

An example (where tidy-in.xml is ugly file and tidy-out.xml the prettified version). 一个示例(tidy-in.xml是丑陋的文件,tidy-out.xml是经过修饰的版本)。 Optionally you can provide a config.xml with all kinds of tidy options. 您可以选择提供config.xml,其中包含各种整洁的选项。

$command = "tidy -indent -utf8 -xml -wrap 1000 tidy-in.xml > tidy-out.xml";
exec($command, $return, $code);
if ($code != 0) {
    throw new Exception(printf("Bugger! Something went wrong: %s (%s)", join('<br />', $return), $code));
} 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM