GithubHelp home page GithubHelp logo

laravel-queue-s3event's Introduction

Laravel Queue S3 Event Serivice Provider

Installation

Edit your composer.json

Add Repositories

"repositories": [
    {
        "type": "vcs",
        "url": "https://github.com/maimai-swap/laravel-queue-s3event.git"
    }
],

Add Require

"require": {
	"maimai-swap/laravel-queue-s3event": "dev-master"
}

Next, update Composer from the Terminal:

composer update
  1. Configuration

add the service provider. Open app/config/app.php, and add a new item to the providers array.

'MaimaiSwap\LaravelQueueS3Event\LaravelQueueS3EventServiceProvider'
  1. Usage

Open app/config/queue.php, and set a configuration. 'class' => 'MyJob' is your queue job class name

<?php

return array(

	'default' => 's3sqs-con',

	'connections' => array(

        's3sqs-con' => array(
            'driver' => 's3sqs',
            'key'    => '<your key>',
            'secret' => '<your secret>',
            'queue'  => '<queue url>',
            'region' => '<queue region>',
			'class' => 'MyJob'
        ),

	),

);

Create php class like this in app/models/MyJob.php

<?php
use Illuminate\Queue\Jobs\Job;
use Illuminate\Support\Facades\Log;

class MyJob {

    function __construct()
    {

    }

    /**
     * @param Job $job
     * @param array $data SQS Payload
     */
    public function fire(Job $job, array $data)
    {

        // Data Array
        if (@$data["Records"]) {

            Log::info("S3 Event.");

            $region = $data["Records"][0]["awsRegion"];
            $bucket = $data["Records"][0]["s3"]["bucket"]["name"];
            $key = $data["Records"][0]["s3"]["object"]["key"];

            // Logic
            Log::info(get_class($this)." Region $region Bucket $bucket Key $key File Uploaded.");

        }

        // Delete Job
        $job->delete();

    }

}

laravel-queue-s3event's People

Contributors

maimai-swap avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Forkers

tarurata

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.