How to implement SSE (Server-Sent Events) in PHP Laravel - php

I am new to PHP Laravel. I have little bit confuse to build SSE in PHP Laravel. I searched around 1 day. but I didn't find any good resources to meet my requirements. Helps and other reference will appreciate
Suggestions
- I have different RabbitMQ queues to listen status of the message.If a new event occurs need
to update the blade(Have different blades included in my page. need to update only one of them).
if you doesn't understand my requirement:
I am looking for I chat system. I need to trigger the status in to my blade. the status will comes in rabbitMQ I need to take the status from there and change in browser. Eg:- If I sent message status will be in wait state. if the message get processed a new event will trigger in the queue I need to pick that status and update in browser this is exact my requirement

Related

Call external api in laravel with queue

I am trying to develop site like insurance but I am stuck at one position like after taking input data from user I want to pass those input to multiple different external api and get those all api response on to page but if one of api response fails whole process fails and I also don't want to user to wait for too long. I was thinking of doing with queue but don't how to get response from queue. I even try to set up gearman but it's too complicated to work on. Any help would be appreciated..
You can give a try with Queue Job chaining..so that ur jobs will get dispatched sequentially..
To get ACK for API is being failed or success, create an callback API which will be hit when your queue object is dispatched with required statues..and can write logic whatever you are willing to.
I hope this will help to some extent..

Trigger Slack Bot by Direct Message

I'm realy new to this Bot stuff.
I want to create a simple PHP-Skript that is sending an answere every time the Bot is contacted by a user via Direct Message.
I read the Api-Docs but the only thing I found was the /-Command.
Currently I have a Cronjob thats checking the RTM-Api for new messages.
I think there must be a better way then running a Cron-Job every few seconds to check if there is a new message for the Bot.
I found the "EmojiBot" that is exactly responding in the way I want.
Using the RTM API to build a bot will work, but there is indeed an easier way: Use the new Event API from Slack.
The Event API allows you to subscribe to range of events. When the event happens, Slack will automatically call your php script. So you don't need to run a CRON loop. This also works with bot users and direct messages to bot users.
Check out the Event API documentation for details.
You can use Botonomous Framework which supports Events API. You should subscribe to the events, then update the framework configurations which is explained here. Finally you have got a nice event object and based on certain criteria you can send a message back to a Slack channel.

How can I set a queue status for Twilio SMS messages via PHP?

I've integrated Twilio for a client, but I need to incorporate their hours of operation. I know the sms messages have statuses, but how can I control the status when the message is created? I need the message to be created, but IF it's outside of hours of operation to NOT send the text... so put it in a queue... then when hours open again, send the text.
I see how I can query a sent message and see the status... but I want to specify the status and make sure it doesn't get sent until I specify when.
Please let me know how I can accomplish this. Thanks!
Megan from Twilio.
This is something you'll have to build into your application logic.
There are plenty of approaches you could take here such as scheduling a cron job or using a worker like Iron.io as seen in this post.
I hope this info helps.

Running background process in LAMP stack

I have an application running on LAMP stack.In USER model
after expiration of subscription deadline,I need to set user's current
subscription to default or free subscription.
So I need a background process which always checks for the expiration of user's subscription deadline and set to default subscription.
Is there any other efficient and manageable solution to run a background process which will update user's data ?
Application Environment:
CakePHP,Redis,MariaDB
Please edit if this question isn't good enough to describe my problem :(
So in general your question about recurring event,
if this event do changes in DB and also another actions like send emails or stop some services or connect to remote resource,, you have to use cron job
but if this event only related to DB then you can create recurring event like the following link
In case of PHP there is not so many out-of-the-box solutions. One of the available is rabbitmq-delayed-sample. It is built on top of rabbitmq messaging system.
Usage example:
$container->get('delayed_producer')->delayedPublish(5000, $messageBody, '');
where 5000 is an expiration period after that job will be executed. You can put such code to the new user creation place.

How to implement dynamic chat application in Ios using php, Something related to Skype like application

I am trying to implement a chat application in IOS. In general We use two php files one for posting a message(sender) another for retrieving the message(receiver).
I want to accomplish the following:
Consider A(sender) and B (Receiver).
A sent message to B. And A is waiting for B's reply. So i need to call post-api.php for sending a message and at the receivers side(B) i need to retrieve using getapi.php
when B reply to A it must automatically appear in my inbox(live chatbox) of A, without calling getapi.php. I know this scenario is not possible. But is there any solution or method so that my chat application works like skype or facebookchat.
There is multiple way to implement the chat functionality.
Polling: Send request to server and process the response from the server in timely fashion after a particular time interval using NSTimer(But remember is will cause the battery drain).
Using APNS: Using the official Apple push notification implementation, whenever there is new entry in chat table on server side send the notification to particular device using push notification and handle the notification using the delegate methods (Although not 100% reliable).Using Push Notification
Using Socket Programming: Using the socket programming you can have dedicated connection between client(device) and server. I have provided the link having the source at the end of the tutorial.Using Socket Programming
As you know that without getapi.php it is not possible to update chat list so you need to make management something like: you need to use NSTimer and with the help of timer you need to call your getapi.php service after certain time interval let say after 2min so that chat can be refresh and user get the reply this is the only possible way at my knowledge.

Categories