2014-08-28 64 views
0

我使用作曲家安装了“autoPrefixer PHP”,并尝试了如github页面(https://github.com/vladkens/autoprefixer-php)所示的示例。 很简单的例子autoprefixer PHP不能正常工作,如示例

$autoprefixer = new Autoprefixer(); 
$css  = 'a { transition: transform 1s }'; 
$prefixed = $autoprefixer->compile($css); 

只输出$ CSS不变。但是,如果我使用自定义参数启动autprefixer对象,它会输出正确的前缀css。

$autoprefixer = new Autoprefixer('last 2 versions'); 

还初始化与PARAMATERS对象如图所示的例子中,给出“未知的浏览器要求“IE8”错误

$autoprefixer = new Autoprefixer(array('ff > 2', '> 2%', 'ie8')); // many rules 

所以什么都可以错在我的安装?事实上,我没有手动做任何事情,只是由作曲家安装。

回答

0

你需要像样板间 “即” 和 “8”,一个空格:

$autoprefixer = new Autoprefixer(array('ff > 2', '> 2%', 'ie 8')); // many rules 
0

一个快速浏览一下vladkens Autoprefixer PHP编译方法的代码:

$nodejs = proc_open('node ' . __DIR__ . '/vendor/wrap.js', 
    array(array('pipe', 'r'), array('pipe', 'w')), 
    $pipes 
); 

OK, proc_open节点..它使用Note.js和vladkens自述文件中的介绍他写道:

此库提供PHP与N ode.js应用程序。

,并在自述安装部分,他写道太

首先,你需要在你的服务器上安装Node.js的。


它看起来像目前还没有真正的PHP编译重建的人没有自己的服务器,主机托管服务提供商卫生组织支持Note.js,有了这样的咕噜/咕嘟咕嘟经验罗盘或没有MAC的CodeKit(不错软件,以前找到它,但不能直接在Linux上使用它)。

当我的PHP软件在智能缓存中使用scss,sass,less或其他css PHP修改时,添加autoprefixer也是一个好主意。


结论

你需要你的服务器和权限上的Node.js在PHP执行proc_open()。