abetter/toolkit

更好的 Laravel 工具包,用于构建异常快速的 Web 应用程序。

1.6.18 2021-11-10 16:03 UTC

README

Packagist Version Latest Stable Version Total Downloads License

ABetter Toolkit 是一个包含新指令和修改过的指令的包,用于快速开发基于组件的 Web 应用程序,重点在于可扩展的静态缓存。

要求

  • PHP 7.2+
  • Imagick 3+
  • MySQL 5.7+
  • Composer 1.6+
  • Laravel 5.8+
  • Deployer 6+
  • Node 10.0+
  • NPM 6.4+

安装

通过 Composer

composer require abetter/toolkit

Laravel 修改

向 app/Http/Kernel.php 中添加中间件

protected $middleware = [
	\ABetter\Toolkit\SandboxMiddleware::class,
];

注意:此中间件有助于 Blade 在开发多个嵌套组件时清除视图缓存。

指令

@component : 改进的组件注入指令

@component('<view.name>',[<variables>])
@component('<view.name>',TRUE)
@component('<view.name>') <slot-here> @endcomponent

如果 blade 文件与文件夹具有相同的 basename,则组件名称将自动解析。

您可以将 @component 与 TRUE 作为第二个参数自动终止,以避免编写 @endcomponent,例如当不使用任何插槽或嵌套内容时。

@inject : 改进的注入类作为变量的指令

@inject('<variable>','<relative-class-file>')
@inject('Menu','Menu.class.php')
@inject('Menu')

如果类文件位于组件文件夹中,则将自动解析。

@block : 插入包装的块部分

@block('<class-name>')
@block('block--typography')
@endblock

@style : 在 html 源代码中嵌入 sass/css

@style('<relative-filename>')
@style('menu.scss')

在开发模式下,嵌入的 Sass/CSS 文件将被渲染为外部文件以支持 browsersync 实时,但在 Stage/Production 上将嵌入到 html 源中以获得更好的缓存。

@script : 在 html 源代码中嵌入 js

@script('<relative-filename>')
@script('menu.js')

在开发模式下,嵌入的 JS 文件将被渲染为外部文件以支持 browsersync 实时,但在 Stage/Production 上将嵌入到 html 源中以获得更好的缓存。

@svg : 在 html 源代码中嵌入 svg

@svg('<filename-relative-to-resources>')
@svg('/images/logo.svg')

@lipsum : 插入模拟文本

@lipsum('<variables>')
@lipsum('medium')

@pixsum : 插入模拟图像

@pixsum('<variables>','<options>')
@pixsum('photo:tech')
@pixsum('photo:tech','img:w500')

@logosum : 插入模拟 svg 标志

@logosum('<variables>')
@logosum('My Brand Name')

贡献者

Johan Sjöland johan@sjoland.com
高级产品开发者:ABetter Story Sweden AB。

许可证

MIT 许可证。有关更多信息,请参阅许可证文件