aura/asset-bundle 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

aura/asset-bundle

Composer 安装命令:

composer require aura/asset-bundle

包简介

Asset management for aura v2

README 文档

README

Asset management for PHP.

Foreword

Requirements

This package requires PHP 5.3 or later. Unlike Aura library packages, this asset package has userland dependencies:

Installation

This asset-bundle is installable and autoloadable via Composer with the following require element in your composer.json file:

"require": {
    "aura/asset-bundle": "2.*"
}

Tests

Build Status

composer install
phpunit -c tests/unit

PSR Compliance

This kernel attempts to comply with PSR-1, PSR-2, and PSR-4. If you notice compliance oversights, please send a patch via pull request.

Community

To ask questions, provide feedback, or otherwise communicate with the Aura community, please join our Google Group, follow @auraphp on Twitter, or chat with us on #auraphp on Freenode.

Structure of Package

Assume you have a Vendor.Package. All your assets should be in the web folder. The folder names css, images, js can be according to your preffered name.

├── src
│   ├── Cli
│   └── Web
├── tests
└── web
    ├── css
    │   └── some.css
    ├── images
    │   ├── another.jpg
    │   └── some.png
    └── js
        └── hello.js

Assuming you have the same structure, now in your template you can point to /asset/vendor/package/css/some.css, /asset/vendor/package/js/hello.js, /asset/vendor/package/images/another.jpg.

Onething you still need to make sure in the name asset/vendor/package

vendor/package which is the composer package name.

Usage in any project

Add path to the router, according to the router you are using so that vendor, package and file name can be extracted from it.

An example of usage with Aura.Router and Aura.Dispatcher is given below. The dispacther is used for it need to recursively call the __invoke method. Else action will return responder, then you need to invoke responder to get the response and finally do send the response.

<?php
$map = array(
    'my/package' => '/path/to/web/where/css/js/etc/',
    'my/package2' => '/path/to/web/where/css/js/etc/of/packag2'
);
$types = array();
$router->add('aura.asset', '/asset/{vendor}/{package}/{file}')
    ->setValues([
        'action' => 'aura.asset',
    ])
    ->addTokens(array(
        'file' => '(.*)'
    ));

$dispatcher->setObject(
    'aura.asset',
    function () use ($map, $types) {
        $action = new \Aura\Asset_Bundle\AssetAction(
            new \Aura\Asset_Bundle\AssetService($map, $types),
            new \Aura\Asset_Bundle\AssetResponder()
        );
        return $action;
    }
);

In your layout or view

<link href="/asset/<vendor>/<package>/css/bootstrap.min.css" rel="stylesheet">

Usage in Aura.Web_Kernel

<?php
    // more code
    public function define(Container $di)
    {
        $di->params['Aura\Asset_Bundle\AssetService']['map']['cocoframework/example'] = dirname(__DIR__) . '/web';
    }

Make sure you have router helper defined for Aura.View.

<link rel="stylesheet" href="<?php echo $this->router()
      ->generateRaw('aura.asset',
          array(
              'vendor' => 'cocoframework',
              'package' => 'example',
              'file' => '/css/syntax.css'
          )
      ); ?>">

aura/asset-bundle 适用场景与选型建议

aura/asset-bundle 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 199 次下载、GitHub Stars 达 6, 最近一次更新时间为 2014 年 06 月 07 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 aura/asset-bundle 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 aura/asset-bundle 我们能提供哪些服务?
定制开发 / 二次开发

基于 aura/asset-bundle 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 199
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 6
  • 点击次数: 0
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 6
  • Watchers: 1
  • Forks: 3
  • 开发语言: PHP

其他信息

  • 授权协议: BSD-2-Clause
  • 更新时间: 2014-06-07