ishanvyas22/asset-mix
Composer 安装命令:
composer require ishanvyas22/asset-mix
包简介
Asset Mix plugin for CakePHP
README 文档
README
Provides integration with your CakePHP application & Laravel Mix.
This branch works with CakePHP 5.0+, see version map for more details.
❤️ Support The Development
Do you like this project? Support it by donating:
or Paypal me
Follow me
Installation
-
Install the AssetMix plugin with composer:
Via composer:
composer require ishanvyas22/asset-mix
-
Load plugin using below command:
bin/cake plugin load AssetMix
-
Generate basic Javascript, CSS & Sass scaffolding:
bin/cake asset_mix generate
Note: Above command will generate scaffolding for vue, but you can generate Bootstrap/jQuery, React or Inertia scaffolding too.
-
Install frontend dependencies
- Using npm:
npm install
or
- Using yarn:
yarn install
-
- For development:
npm run dev
- To watch changes:
npm run watch
- For production:
npm run prod
-
Load
AssetMixhelper from the plugin into yourAppView.phpfile:$this->loadHelper('AssetMix.AssetMix');
Usage
After compiling your assets(js, css) with laravel mix, it creates a mix-manifest.json file into your webroot directory which contains information to map the files.
- To generate script tag for compiled javascript file(s):
echo $this->AssetMix->script('app');
Above code will render:
<script src="/js/app.js" defer="defer"></script>
As you can see it works same as HtmlHelper. There is not need to provide full path or even file extension.
- To generate style tag for compiled css file(s):
echo $this->AssetMix->css('main');
Output:
<link rel="stylesheet" href="/css/main.css">
If versioning is enabled, output will look something like below:
<link rel="stylesheet" href="/css/main.css?id=9c4259d5465e35535a2a">
Generate command
The generate command is used to generate starter code for your Javascript application to get you started developing your frontend.
Get help:
bin/cake asset_mix -h
Generate default scaffolding (with vue):
bin/cake asset_mix generate
Above command will generate:
package.jsonwebpack.mix.jsassets/css/js/sass/
assets/ directory is where you will store your js, css files which will compile down into your respective webroot/ directory.
Custom directory name:
bin/cake asset_mix generate --dir=resources
You can also use custom directory name instead of default assets directory, above command will create resources directory where you can put your js, css, etc asset files.
Don't want to use Vue.js? Don't worry this plugin doesn't dictate on which Javascript library you should use. This plugin provides ability to quickly generate scaffolding for Vue as well as Bootstrap, and React.
Generate basic Bootstrap/jQuery scaffolding:
bin/cake asset_mix generate bootstrap
Generate React scaffolding:
bin/cake asset_mix generate react
Generate scaffolding for Inertia.js:
# for vue bin/cake asset_mix generate inertia-vue # or for react bin/cake asset_mix generate inertia-react
Generate React scaffolding inside resources directory:
bin/cake asset_mix generate react --dir=resources
Serving CakePHP out of a Subdirectory
Please see docs/ServingFromSubdirectory
Version map
| AssetMix version | Branch | CakePHP version | PHP minimum version |
|---|---|---|---|
| 2.x | cake5 | >=5.0.0 | >=8.1 |
| 1.x | cake4 | >=4.0.0 | >=7.2 |
| 0.x | cake3 | >=3.5.0 | >=5.6 |
Changelog
Please see CHANGELOG for more information about recent changes.
Reference
To see this plugin into action you can refer to this project, which will provide more insight.
License
The MIT License (MIT). Please see License File for more information.
ishanvyas22/asset-mix 适用场景与选型建议
ishanvyas22/asset-mix 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 76.81k 次下载、GitHub Stars 达 33, 最近一次更新时间为 2019 年 10 月 26 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「assets」 「javascript」 「cakephp」 「sass」 「less」 「minifier」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 ishanvyas22/asset-mix 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 ishanvyas22/asset-mix 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 ishanvyas22/asset-mix 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
CakePHP 4.x AdminLTE Theme.
Generates a Blade directive exporting all of your named Laravel routes. Also provides a nice route() helper function in JavaScript.
Asset Management for PHP
Caching and compression for Twig assets (JavaScript and CSS).
A pretty nice way to expose your translation messages to your JavaScript.
PHP client for the Google Closure Compiler API in one file.
统计信息
- 总下载量: 76.81k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 34
- 点击次数: 4
- 依赖项目数: 2
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-10-26