定制 ejetar/laravel-mix-php-function 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

ejetar/laravel-mix-php-function

最新稳定版本:v1.0.0

Composer 安装命令:

composer require ejetar/laravel-mix-php-function

包简介

A lightweight and simple library that adds Laravel Mix's mix() function to your PHP project 🚀

README 文档

README

About

A lightweight and simple library that adds Laravel Mix's mix() function to your PHP project 🚀

You can now use the mix() function of Laravel Mix independently, without needing Laravel and/or Blade and/or Vue...

Installation

composer require ejetar/laravel-mix-php-function

Get started

  1. Load the composer into your project;
  2. Call mix() at the desired location;
  3. And that's it, that's all, have fun!

Example

Let's say we have the following mix-manifest.json, in the public folder of our project:

{
    "/css/all.css": "/css/all.css?id=2fcc406cf38a7867b239",
    "/css/all.min.css": "/css/all.min.css?id=2fcc406cf38a7867b239", 
    "/js/all.js": "/js/all.js?id=2c80a6c15449d3e693ed", 
    "/js/all.min.js": "/js/all.min.js?id=2c80a6c15449d3e693ed"
}

Now suppose I want to retrieve the versioned URL from the /css/all.min.css file:

<?php require_once 'vendor/autoload.php'; //Load Composer ?><!doctype html>
<html>
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, user-scalable=yes, initial-scale=1.0">
        <meta http-equiv="X-UA-Compatible" content="ie=edge">
        <title>Example</title>
        
        <link rel="stylesheet" href="<?= mix('/css/all.min.css'); ?>">
        <!-- The result will be /css/all.min.css?id=2fcc406cf38a7867b239 -->
    </head>
    <body>
        <h1>\o/</h1>
    </body>
</html>

That simple!

Custom Mix Base URLs

You can also use custom mix base URLs, just as you would with Laravel.

Just define the constant MIX_ASSET_URL before using the mix function.

Example

<?php
require_once 'vendor/autoload.php'; //Load Composer
define('MIX_ASSET_URL', 'https://cdn.example.com');
?><!doctype html>
<html>
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, user-scalable=yes, initial-scale=1.0">
        <meta http-equiv="X-UA-Compatible" content="ie=edge">
        <title>Example</title>
        
        <link rel="stylesheet" href="<?= mix('/css/all.min.css'); ?>">
        <!-- The result will be https://cdn.example.com/css/all.min.css?id=2fcc406cf38a7867b239 -->
    </head>
    <body>
        <h1>\o/</h1>
    </body>
</html>

Changelog

Nothing for now...

Contributing

Contribute to this wonderful project, it will be a pleasure to have you with us. Let's help the free software community. You are invited to incorporate new features, make corrections, report bugs, and any other form of support. Don't forget to star in this repository! 😀

License

This library is a open-source software licensed under the MIT license.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-03-18