承接 erickcomp/laravel-stacked-components 相关项目开发

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

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

erickcomp/laravel-stacked-components

Composer 安装命令:

composer require erickcomp/laravel-stacked-components

包简介

Provides components that will be inserted into a given stack

README 文档

README

Latest Stable Version Total Downloads License

Use Blade Components syntax to insert (push/prepend) content to stacks

This package provides some blade components that you can use to insert content into stacks, most notably, scripts and styles.

The vanilla-Blade way

To push some JS file/code to a stack, you have to (from Laravel docs):

@push('scripts')
    <script src="{{ asset("/example.js") }}"></script>
@endpush

or, for inline JS:

@push('scripts')
    <script>
        document.addEventListener("DOMContentLoaded", (event) => {
            alert("Alert 2!!!");
        });
    </script>
@endpush

It, of course, works. But when using Blade Components, the intention is stay closer to HTML whenever possible

The Stacked Components Ways

####JS component:

<x-js src="/example.js" stack="scripts"/>

or, for inline JS:

<x-js stack="scripts">
    document.addEventListener("DOMContentLoaded", (event) => {
        alert("Alert 2!!!");
    });
</x-js>

This package automatically calls Laravel's asset function by default. You can override this behavior to call you own callable or to call nothing at all. To do either of these, you can set the environment variable

STACKED_ASSETS_COMPONENTS_DEFAULT_ASSET_FUNCTION

or the config value

stacked-components.asset-function

To call any callable, you can use one of the following options the PHP's callable syntax or the Laravel's "@" syntax (MyNamespace\MyClass@myAssetFunction). To call no function by default you must set the config value or the environment variable with the value false.

Note that if decide to use objects (anonoymous functions, invokable objects, first-class callables), you won't be able to use Laravel's config cache, since it does not support cache for these types of config values.

Content component:

<x-stacked-component stack="scripts">
    <script src="/example.js"></script>
</x-stacked-component>

or, for inline JS:

<x-stacked-content stack="scripts">
    <script src="/example.js">
                  document.addEventListener("DOMContentLoaded", (event) => {
                          alert("Alert 2!!!");
                  });
    </script>
</x-stacked-content >

Other components

This package provides 4 components

  • js
  • css
  • stacked-div
  • stacked-content

For the CSS and JS components, you can set a default stack in config/env and omit it when using the component, like this:

.env file:

STACKED_ASSETS_COMPONENTS_DEFAULT_STACK_JS="scripts"
STACKED_ASSETS_COMPONENTS_DEFAULT_STACK_CSS="styles"

and in your view file:

<x-js src="/example.js" />

Resolving name collisions with other components

This package provides the js and the css components. If your app already defined this, or even a library you're using did this, you have 2 options:

1 - Register a namespace for the components of this package. To do so, you can set the environment variable

STACKED_ASSETS_COMPONENTS_COMPONENT_NAMESPACE

or the config value

stacked-components.component-namespace

If you set the namespace with the bool value "true", it will use the namespace "stacked". If you set it to any string, the set string will be used as the blade components namespace. For more information on components namespaces check the Laravel docs

2 - Set the config values

stacked-components.component-name-js
stacked-components.component-name-css

or the environment variables

STACKED_ASSETS_COMPONENTS_COMPONENT_NAME_JS
STACKED_ASSETS_COMPONENTS_COMPONENT_NAME_CSS

To specify alternate names for the js and css components

Remember to clear the views caches when changing any of these values. To clear the view cache run the view:cache artisan command:

php artisan view:clear

License

The MIT License (MIT). Please see License File for more information.

erickcomp/laravel-stacked-components 适用场景与选型建议

erickcomp/laravel-stacked-components 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 204 次下载、GitHub Stars 达 0, 最近一次更新时间为 2024 年 11 月 25 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

围绕 erickcomp/laravel-stacked-components 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-11-25