php - autoprefixer PHP 无法正常工作,如示例所示

标签 php css autoprefixer

我使用 composer 安装了“autoPrefixer PHP”,并尝试了 github 页面 (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 安装。

最佳答案

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

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

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

This library provides PHP integration with Node.js application.

在自述安装部分他也写了

First you need install Node.js in your server.


看起来目前没有真正的 PHP 重建编译器供没有自己的服务器的人、支持 Note.js 的主机、使用 Compass 或没有 mac 的 Grunt/Gulp 经验使用 CodeKit (不错的软件,以前找过,但是在linux上不能直接用)。

当我的 PHP 软件使用 scss、sass、less 或其他具有智能缓存的 css PHP 修改时,添加自动前缀也是一个好主意。


结论

您的服务器上需要 Node.js 以及在 PHP 中执行 proc_open() 的权限。

关于php - autoprefixer PHP 无法正常工作,如示例所示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25542622/

相关文章:

php - TideSDK PHP通过SSH连接

php - 通过送货方式在感谢页面上添加自定义消息

css - TRAC - 更改 css 但在页面加载时被覆盖

html - 在每个域本地更改 CSS

reactjs - 如何在开发中禁用 Emotion 11 中的前缀?

css - 如何使用自动前缀和缩小为 sass 文件生成正确的源映射

php - 是否有仅管理内容的 CMS?不是布局/CSS/SEO

javascript - 如何将结构化文本文档保存到sql中的表中?

CSS z-index 问题

gruntjs - Autoprefixer 不为 IE 添加前缀