承接 oldtimeguitarguy/laravel-event-subscriber 相关项目开发

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

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

oldtimeguitarguy/laravel-event-subscriber

Composer 安装命令:

composer require oldtimeguitarguy/laravel-event-subscriber

包简介

This makes your event subscribers a little cleaner

README 文档

README

Installation

  1. composer require oldtimeguitarguy/laravel-event-subscriber
  2. Add OldTimeGuitarGuy\LaravelEventSubscriber\EventSubscriberProvider::class, to the providers array in config/app.php
  3. Run php artisan vendor:publish to copy the config file to config/event_subscriber.php

Usage

  1. Create subscribers with php artisan make:event-subscriber SubscriberName
  2. Add custom event classes in config/event_subscriber.php

Description

The basic premise of this evolved from here.

I love the idea, but I don't like how you have to define that subscribe method.

This class eliminates that.

Basically create your event subscriber class just like the documentation says, but now, if you extend from this class, you never have to write the subscribe method.

Instead, just prefix all of your event names with on as public methods.

So you would do something like this:

class MyEventSubscriber extends EventSubscriber
{
    public function onUserLogin($event)
    {
        // do stuff
    }

    public function onUserLogout($event)
    {
        // do stuff
    }
}

That's it. There are a couple of caveats:

  1. It looks for the events in Laravel's app/Events directory. (or any class you add to the classmap in the config file)
  2. You can have a maximum of one subdirectory under app/Events/
  3. Be careful about name collisions, even if the event classes exist in different subdirectories under app/Events

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-07-09

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固