nanjingboy/assets

PHP 资源管理器

v0.1.7 2014-11-14 05:26 UTC

This package is not auto-updated.

Last update: 2024-09-24 04:28:22 UTC


README

资源

Assets 是一个 PHP 资源管理器。

入门指南

  • 在应用程序根目录下创建 composer.json 文件
{
    "require": {
        "php": ">=5.4.0",
        "nanjingboy/assets": "*"
    },
    "config": {
        "bin-dir": "bin/"
    }
}
  • 通过 composer 安装

  • 在应用程序根目录下创建目录

 $ mkdir tmp/assets -p
 $ mkdir tmp/assetLoader -p
 $ chmod -R a+w tmp

 $ mkdir uglified/assets -p
 $ chmod -R a+w uglified
  • 在应用程序根目录下创建 configs/$assetEnv/assets.php($assetEnv 是名为 ASSETS_ENV 的环境值)
<?php
return array(
    'path' => array(
        'serverRoot' => string,
        'javascripts' => string, // relative to serverRoot path, default is the serverRoot path
        'stylesheets' => string, // relative to serverRoot path, default is the serverRoot path
        'images' => string, // relative to serverRoot path, default is the serverRoot path
        'fonts' => string // relative to serverRoot path, default is the serverRoot path
    ),
    'precompile' => array() // the file's extension must be js or css, and it's relative to root javascripts(stylesheets) path
);
  • 在 bootstrap.php 中初始化配置
<?php
require __DIR__ . '/vendor/autoload.php';
\Assets\Config::init($configFilePath);

依赖

如果你不使用 CoffeeScript、Sass 或 Less,你不需要安装 CoffeeScript、Sass 或 Less 编译器。

API

require & require_dir 指令

有关 require & require_dir 指令的更多详细信息,请参阅: assetloader

控制台行

$ bin/assets

assets version 0.1.7

Usage:
  [options] command [arguments]

Options:
  --help           -h Display this help message.
  --quiet          -q Do not output any message.
  --verbose        -v|vv|vvv Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug.
  --version        -V Display this application version.
  --ansi              Force ANSI output.
  --no-ansi           Disable ANSI output.
  --no-interaction -n Do not ask any interactive question.

Available commands:
  clean        Remove old compiled assets
  cleanup-tmp  Remove unuseful files in tmp/assets directory
  help         Displays help for a command
  list         Lists commands
  precompile   Compile all the assets named in $config["precompile"]

示例

test 获取示例

许可

MIT