m2collective/laravel-blade-directive 问题修复 & 功能扩展

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

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

m2collective/laravel-blade-directive

Composer 安装命令:

composer require m2collective/laravel-blade-directive

包简介

README 文档

README

This package simplifies and systematizes the creation and registration of user directives.

Laravel PHP

Installation

You can install the package via composer:

composer require m2collective/laravel-blade-directive

The package will automatically register itself.

Usage

By installing the package, you can create and register directives in a simpler and more intuitive way.

Default Directive

Creating a simple directive for displaying or formatting incoming arguments.

use M2Collective\BladeDirective\DefaultBladeDirective;

final class Example implements DefaultBladeDirective
{
    /**
     * @return string
     */
    public function tag(): string {
        return 'example';
    }
    
    /**
     * @param mixed $expression
     * @return string
     */
    public function handler(mixed $expression) : string
    {
        //...
    }
}

Logical Directive

Creating a logical directive that satisfies certain conditions.

use M2Collective\BladeDirective\LogicalBladeDirective;

final class Example implements DefaultBladeDirective
{
    /**
     * @return string
     */
    public function openingTag(): string {
        return 'example';
    }
    
    /**
     * @param mixed $expression
     * @return string
     */
    public function openingHandler(mixed $expression) : string
    {
        //...
    }
    
    /**
     * @return string
     */
    public function elseTag(): string {
        return 'elseExample';
    }
    
    /**
     * @param mixed $expression
     * @return string
     */
    public function elseHandler(mixed $expression) : string
    {
        //...
    }
    
    /**
     * @return string
     */
    public function closingTag(): string {
        return 'endExample';
    }
    
    /**
     * @param mixed $expression
     * @return string
     */
    public function closingHandler(mixed $expression) : string
    {
        //...
    }
}

Registering Directives

New directives are registered through the service provider.

use M2Collective\BladeDirective\Concerns\RegisterBladeDirectives;

final class ExampleServiceProvider extends ServiceProvider
{
    use RegisterBladeDirectives;
    
    /**
     * @return void
     */
    public function boot(): void
    {
        $this->registerBladeDirective(
            new ExampleDirective()
        );
        
        // or
        
        $this->registerBladeDirectives([
            new ExampleDirective(),
            //...
        ]);
    }
}

License

The MIT License (MIT). Please see the License file for more information.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-06-17

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固