Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Notify Task Bundle Laravel Package

creavo/notify-task-bundle

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Setup

  1. Installation

    composer require creavo/notify-task-bundle
    

    For Laravel (not Symfony), use:

    composer require creavo/notify-task-bundle
    

    Then register the service provider in config/app.php under providers:

    Creavo\NotifyTaskBundle\CreavoNotifyTaskBundle::class,
    
  2. Publish Config

    php artisan vendor:publish --provider="Creavo\NotifyTaskBundle\CreavoNotifyTaskBundle" --tag="config"
    

    This creates config/notify_task.php. Update with your preferences (e.g., send_notification_immediately).

  3. Run Migrations

    php artisan migrate
    

    (If using Doctrine, follow Symfony docs; Laravel users should adapt the schema to migrations.)

  4. First Use Case Trigger a notification via a command or event:

    use Creavo\NotifyTaskBundle\Service\NotificationService;
    
    $notification = $this->container->get(NotificationService::class);
    $notification->create([
        'title' => 'Task Completed',
        'message' => 'Your task is done!',
        'type' => 'success', // or 'error', 'warning'
        'user_id' => 1,
    ]);
    

Implementation Patterns

Core Workflows

  1. Event-Driven Notifications Bind to Laravel events (e.g., job.processed) and dispatch notifications:

    use Creavo\NotifyTaskBundle\Events\NotificationCreated;
    
    event(new NotificationCreated($data));
    
  2. Queue-Based Delayed Notifications Disable send_notification_immediately in config and use queues:

    $notification->create($data, ['delay' => 3600]); // Delay 1 hour
    
  3. Multi-Channel Notifications Enable pushover_enabled and email_enabled in config. The bundle auto-routes to configured channels.

  4. Custom Notification Types Extend the Notification entity or create a custom service:

    $notification->create([
        'type' => 'custom',
        'custom_data' => ['key' => 'value'],
    ]);
    

Integration Tips

  • Laravel Mixins: Use traits to inject notification logic into controllers:
    use Creavo\NotifyTaskBundle\Traits\Notifiable;
    
    class TaskController {
        use Notifiable;
        // ...
    }
    
  • API Responses: Attach notifications to API responses:
    return $this->notifyAndReturn($request, 'Task updated', $response);
    
  • Testing: Mock NotificationService in tests:
    $this->partialMock(NotificationService::class, ['create']);
    

Gotchas and Tips

Pitfalls

  1. Symfony vs. Laravel Confusion

    • The bundle assumes Symfony’s Kernel and config.yml. For Laravel:
      • Ignore AppKernel.php instructions.
      • Use config/notify_task.php (published via vendor:publish).
      • Replace doctrine:schema:update with Laravel migrations.
  2. Queue Configuration

    • If using queues, ensure send_notification_immediately = false and the notify_task:send queue is processed:
      php artisan queue:work
      
  3. Pushover/Email Dependencies

    • Enable pushover_enabled/email_enabled only after configuring their respective tokens/mailers. Unconfigured channels will throw errors.
  4. Database Schema

    • The bundle creates a notifications table. Customize via migrations if extending:
      Schema::table('notifications', function (Blueprint $table) {
          $table->string('custom_field')->nullable();
      });
      

Debugging

  • Logs: Check storage/logs/laravel.log for notification failures.
  • Queue Jobs: Inspect notify_task:send jobs with:
    php artisan queue:failed-table
    php artisan queue:retry <job-id>
    
  • Configuration Overrides: Use environment variables to override config:
    NOTIFY_TASK_PUSHOVER_ENABLED=true
    NOTIFY_TASK_EMAIL_FROM=no-reply@example.com
    

Extension Points

  1. Custom Channels Implement Creavo\NotifyTaskBundle\Channel\ChannelInterface:

    class SlackChannel implements ChannelInterface {
        public function send(Notification $notification) { ... }
    }
    

    Register in config/notify_task.php:

    'channels' => [
        'slack' => Creavo\NotifyTaskBundle\Channel\SlackChannel::class,
    ],
    
  2. Notification Filters Use middleware to filter notifications:

    $notification->create($data, [
        'middleware' => [YourMiddleware::class],
    ]);
    
  3. Webhooks Extend the bundle to support webhook notifications by adding a webhook channel and configuring endpoints in the Notification entity.

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
craftcms/url-validator
directorytree/privacy-filter-classifier
directorytree/privacy-filter
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony
develia/geo-bundle
dreamzy/livewire-charts
touchestate-sdk/php-sdk
22h/doctrine-garbage-collection-bundle
agtp/agtp-php
agtp/mod-php
splash/sonata-admin
splash/metadata
splash/openapi
splash/scopes
splash/toolkit
testo/output-teamcity
testo/bridge-symfony