bit3/assetic-autoprefixer

此包已被废弃且不再维护。作者建议使用 netzmacht/assetic-autoprefixer 包。

为 kriswallsmith/assetic 的 autoprefixer-php 过滤器

1.0.2 2014-09-06 14:29 UTC

This package is not auto-updated.

Last update: 2022-02-01 12:38:35 UTC


README

Version Stable Build Status Upstream Build Status License Downloads

Autoprefixer 过滤器

这是一个在 PHP assetic 框架 中使用 Autoprefixer 的过滤器实现。

要求

需要在您的 php 项目中安装 kriswallsmith/assetic。需要在您的系统上安装 postcss/autoprefixer

使用 composer 安装 kriswallsmith/assetic

php composer.phar require kriswallsmith/assetic ~1.0

在您的系统上全局安装 autoprefixer

sudo npm install -g autoprefixer

在您的系统上本地安装 autoprefixer

npm install autoprefixer

在 PHP 中的使用

use Bit3\Assetic\Filter\Autoprefixer\AutoprefixerFilter;

// if you have installed autoprefixer globally
$autoprefixerBinary = '/usr/bin/autoprefixer';

// if you have installed autoprefixer locally
$autoprefixerBinary = '/../node_modules/.bin/autoprefixer';

$autoprefixerFilter = new AutoprefixerFilter($autoprefixerBinary);

// if node.js binary is not installed as /usr/bin/node
// (e.g. on debian/ubuntu the binary is named /usr/bin/nodejs)
$autoprefixerFilter->setNodeBin('/usr/bin/nodejs');

在 Symfony2 中的使用

该项目附带一个位于 config 目录中的 assetic 过滤器配置文件。

parameters.yml 中定义 autoprefixer 二进制路径

parameters:
  # if you have installed autoprefixer globally
  assetic.autoprefixer.bin: /usr/bin/autoprefixer

  # if you have installed autoprefixer locally
  assetic.autoprefixer.bin: %kernel.root_dir%/../node_modules/.bin/autoprefixer

  # if node.js binary is not installed as /usr/bin/node
  # (e.g. on debian/ubuntu the binary is named /usr/bin/nodejs)
  assetic.node.bin: /usr/bin/nodejs

然后在 assetic 配置章节中启用过滤器

# Assetic Configuration
assetic:
    filters:
        autoprefixer:
          resource: "%kernel.root_dir%/../vendor/bit3/assetic-autoprefixer/config/autoprefixer.xml"
          # if you like, you can use apply_to here :-)
          # otherwise you use the filter in your template with filter="autoprefixer"