承接 paulbunyannet/autoversion 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

paulbunyannet/autoversion

最新稳定版本:1.2.0

Composer 安装命令:

composer require paulbunyannet/autoversion

包简介

Auto versioning class for front end assets.

README 文档

README

#paulbunyannet/autoversion

Build Status Latest Version

paulbunyannet/autoversion Cache busting mechanisim for front end assets, used with the cache busting mechanism provided by the HTML5 Boilerplate Apache .htaccess configuration.

Installation

In your terminal, just run:

composer require "paulbunyannet/autoversion":"~1.0"

Configuration

This package is framework agnostic, the configuration process is:

// Auto-load composer packages
use Pbc\AutoVersion\AutoVersion;
require 'vendor/autoload.php';

// Create new AutoVersion object and configure the document root
$auto = new AutoVersion($_SERVER['DOCUMENT_ROOT']);

Add to your .htaccess file, before any other routing mod rewrites

<IfModule mod_rewrite.c>
     RewriteEngine On
     RewriteCond %{REQUEST_FILENAME} !-f
     RewriteRule ^(.+)\.(\d+)\.(bmp|css|cur|gif|ico|jpe?g|js|png|svgz?|webp|webmanifest)$ $1.$3 [L]
</IfModule>

Usage

In your views, just call:

// $pathToAsset is relative to the document root configured above, 
$auto->file($pathToAsset);

for example:

<link rel="stylesheet" href="<?=$auto->file('/css/main.css') ?>">
<script src="<?=$auto->file('/js/main.js') ?>"></script>

which will output file names with their modified time appended to file name:

<link rel="stylesheet" href="/css/main.1234567890.css">
<script src="/js/main.1234567890.js"></script>

统计信息

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

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-08-18