Giter Site home page Giter Site logo

241e0905201f933eb0b6011a550f27fb's Introduction

Proses Register & Login menggunakan Redis Queue

oleh:mirzapurnandi

N|Solid

Membuat REST API untuk proses Register dan Login menggunakan Redis Queue ini membantu pengguna untuk melakukan register di suatu aplikasi dengan mudah tanpa menunggu proses pengiriman email yang memakan waktu mungkin beberapa detik. Untuk proses login juga di sertakan JWT untuk mendapatkan token login agar dapat digunakan di aplikasi lain.

Required:

  • PHP 7.4
  • ext-php: redis
  • ext-php: pgsql

Installasi

Ikuti langkah berikut

  • git clone https://github.com/mirzapurnandi/241e0905201f933eb0b6011a550f27fb
  • composer install
  • Ubah setting koneksi postgresql, file config/Connect.php
    $host = 'localhost';
    $port = '5432';
    $dbname = 'sending';
    $user = 'mirza';
    $password = '';
  • Ubah setting koneksi pengiriman Email, file config/MailConnect.php
    $this->mail->Host = 'smtp.mailtrap.io';
    $this->mail->SMTPAuth = true;
    $this->mail->Port = 2525;
    $this->mail->Username = '5751a43d1e1234';
    $this->mail->Password = '456798268195c6';
  • Selesai, jalankan sesuai installasi (misalnya menggunakan XAMPP)

REST API

Berikut ini list point api

METHOD KETERANGAN URL
POST Register http://send-mail.test/index.php/register
POST Login http://send-mail.test/index.php/login
GET Profile http://send-mail.test/index.php/me

CARA PENGGUNAAN

Gunakan Postman untuk dapat menjalankan API diatas.

Register

POST Register http://send-mail.test/index.php/register
body {
    "name": "Mirza",
    "email": "[email protected]",
    "password": "mirzapurnandi"
}

Login

POST Login http://send-mail.test/index.php/login
body {
    "email": "[email protected]",
    "password": "password"
}

Profile

GET Profile http://send-mail.test/index.php/me
header {
    "Authorization": "Bearer <token>"
}

WORKER

Ketika menggunakan Redis, maka dibutuhkan file worker untuk menjalankan key di redis yang masih tersimpan. di dalam folder ini sudah disediakan sebuah file worker.php, untuk menjalankannya harus menggunakan command dengan perintah berikut:

php worker.php

jika ingin melakukannya secara realtime maka di butuhkan aplikasi seperti Supervisor atau systemd yang dapat berjalan di background process yang berkelanjutan.

HASIL PENGERJAAN

  • proses Register register

  • proses Login login

  • proses Profile profile

  • Hasil Queue/Antrian di redis redis_queue

License

MIT regard, mirza

241e0905201f933eb0b6011a550f27fb's People

Contributors

mirzapurnandi avatar

Watchers

 avatar

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.