我使用composer安装了“github”,并尝试了一些示例,如autoPrefixer页面(https://github.com/vladkens/autoprefixer-php)所示。非常简单的例子
$autoprefixer = new Autoprefixer();
$css = 'a { transition: transform 1s }';
$prefixed = $autoprefixer->compile($css);仅输出未更改的$css。但是,如果我用自定义参数初始化autprefixer对象,它会正确地输出带有前缀的css。
$autoprefixer = new Autoprefixer('last 2 versions');同样,使用示例中所示的参数初始化对象时,会给出“未知浏览器要求'ie8'”错误
$autoprefixer = new Autoprefixer(array('ff > 2', '> 2%', 'ie8')); // many rules那么在我的安装中可能会出现什么问题呢?事实上,我没有手动做任何事情,只是由composer安装。
发布于 2015-04-25 06:25:10
快速浏览一下vladkens Autoprefixer PHP compile方法的代码:
$nodejs = proc_open('node ' . __DIR__ . '/vendor/wrap.js',
array(array('pipe', 'r'), array('pipe', 'w')),
$pipes
);好的,proc_open节点..,它使用Note.js,在vladkens自述文件介绍中,他写道:
PHP这个库提供了与Node.js应用程序的
集成。
在readme安装部分,他也写道
首先,你需要在你的服务器上安装Node.js。
看起来目前还没有真正的PHP rebuild Compiler为那些没有自己的服务器,支持Note.js的主机,在Grunt/Gulp上有经验的人使用,比如Compass或者没有mac for CodeKit (很好的软件,以前可以找到,但不能直接在linux上使用)。
当我的PHP软件使用scss、sass、less或其他带有智能缓存的css PHP修改时,添加autoprefixer也是一个好主意。
结论
您需要在服务器上安装Node.js,并拥有在PHP语言中执行proc_open()的权限。
发布于 2015-03-31 20:59:35
在"ie“和"8”之间需要一个空格,如下例所示:
$autoprefixer = new Autoprefixer(array('ff > 2', '> 2%', 'ie 8')); // many ruleshttps://stackoverflow.com/questions/25542622
复制相似问题