thecoderraman/laravel-assets-version 问题修复 & 功能扩展

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

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

thecoderraman/laravel-assets-version

Composer 安装命令:

composer require thecoderraman/laravel-assets-version

包简介

Laravel static assets versioning via query string: app.js → app.js?v=d41d8cd98f

README 文档

README

  license   laravel Latest Version on Packagist

logo

UyScuti

🦸‍♂️ About

By incorporating query strings, Laravel assets version facilitates static assets versioning, as exemplified by the transformation of app.js into app.js?d41d8cd98f. This method allows for efficient cache busting, ensuring that updated versions of static assets are promptly recognized and utilized by web browsers. Through the addition of unique query strings, such as the appended d41d8cd98f, the system effectively distinguishes between different versions of the same static asset, thereby enhancing performance and reliability within web development projects.

Empower your web development with Laravel's dynamic assets versioning, seamlessly integrating query strings to ensure efficient cache busting and swift recognition of updated versions.

👊 "Efficient cache busting with Laravel's dynamic versioning."

Major Technologies

  • laravel

Structure

├───config
├───resources
├───src
│   ├───Console
│   ├───Contracts
│   ├───Helpers
│   └───Support
│       └───Facades
└───tests
    ├───Concerns
    ├───Feature
    └───Unit

💫 Requirements

  • PHP >= 7.3

⚜️ Features

  • Supports multiple hash algorithms for generating asset file versions.
  • Supports different filters for filtering asset files during asset version generation.
  • Automatically assigns a version to asset URLs when using the asset_path() helper function..

Getting Started 🎉

These instructions will get you a copy of the library up and running on your local machine for production and development purposes.

👨‍💻 Production Environment

Install this package
$ composer require thecoderraman/laravel-assets-version
Publish the config file:
$ php artisan vendor:publish --tag=assets-version
Update Configuration File as Needed
edit: config/assets-version.php
Update Environment File as Needed
# Directory for assets
ASSET_PATH=assets
# Path to assets directory
ASSET_URL=http://localhost/assets

🕹️ Library Basic Usage

You can get the versioned url of any asset file by using the below helper function:
Using Helper Functions
# For Type Js
js_path('app.js');  // "assets/js/app.js?3085ede8f2"

# For Type Css
css_path('app.css');  // "assets/css/app.css?3ede8f2085"

# For Other Types
asset_path('images/logo.png');  // "assets/images/logo.png?e8f203ed85"
For Using inside laravel blade template
<link href="{{ asset_path('js/app.js') }}" rel="stylesheet">
Using Facades
<?php

namespace App\Http\Controllers;

use App\Http\Controllers\Controller;
use TheCoderRaman\AssetsVersion\Support\Facades\AssetsVersion;

class WelcomeController extends Controller
{
    /**
     * Display a listing of the resource.
     *
     * @return string
     */
    public function index()
    {
        // "assets/js/app.js?3085ede8f2"
        dump(AssetsVersion::jsPath('app.js'));

        // "assets/css/app.css?3ede8f2085"
        dump(AssetsVersion::cssPath('app.css'));

        // "assets/images/logo.png?e8f203ed85"
        dump(AssetsVersion::assetPath('images/logo.png'));
    }
}

⚠️ You have to run these commands every time you change any asset file content.

Assets Version Commands
# For generating assets version cache file
$ php artisan assets-version:cache

# For removing assets version cached file
$ php artisan assets-version:clear

🛠️ Development Environment

Clone this repository
$ git clone https://github.com/TheCoderRaman/laravel-assets-version.git
$ cd laravel-assets-version
$ composer install
PhpUnit Tests
# Run Tests
$ composer run-script phpunit
Testbench for testing integrations
# Use TestBench
$ composer run-script testbench
$ composer run-script testbench:serve
$ composer run-script testbench:build
$ composer run-script testbench:prepare
$ composer run-script testbench:clear

Repository Branches

  • master -> any pull request of changes this branch
  • main -> don´t modify, this is what is running in production

Contributions

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change. Please make sure to update tests as appropriate.

Pull Requests
  1. Fork the repo and create your branch: #[type]/PR description
  2. Ensure to describe your pull request: Edit the PR title by adding a semantic prefix like Added, Updated:, Fixed: etc. Title: #[issue] PR title -> #90 Fixed styles the button

Authors

Code of Conduct

In order to ensure that the Assets Version community is welcoming to all, please review and abide by the Code of Conduct.

Security Vulnerabilities

If you discover a security vulnerability within Assets Version, please send an e-mail to Raman Verma via e-mail. All security vulnerabilities will be promptly addressed.

License

The Assets Version is open-sourced software licensed under the MIT License

thecoderraman/laravel-assets-version 适用场景与选型建议

thecoderraman/laravel-assets-version 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 75 次下载、GitHub Stars 达 0, 最近一次更新时间为 2023 年 12 月 08 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「framework」 「assets」 「library」 「version」 「versioning」 「laravel」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

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

围绕 thecoderraman/laravel-assets-version 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-12-08