Skip to content

PHP RabbitMQ consumer stops consuming events

I have a php daemon, which uses php-amqplib, that consumes messages from RabbitMQ server. Here is a gist of it (though it’s a bit more complex than that): When I run it in the background, it handles the events, writes output and errors to various logs and I can see in RabbitMQ control panel that the que…

post request allowed although denied

I started ajax post request to a php file like this: And I get a response, but this should not be possible, because my php file only allows GET instead of POST: Where is my fault? Answer The Access-Control-Allow-Methods header is used in the preflight response to give the client a hint at which methods are al…

Handle Method not being called in Laravel Redis Queue

When adding an item to the queue, for some reason the handle method is not being called. The Log entry in __construct is appearing but when attempting to log in handle(), nothing appears. The method i’m using to dispatch is ProcessImport::dispatch($path, $task->task_id); My queue service is configure…

How to convert numbers to day of the week name?

My code for reference: I need the numbers stored within this array to be converted to weekday names, for example: 1 = Sunday. I would also like to know if this can be done natively in PHP, or will it be necessary to use a library? Answer I think with “with everyone’s” you want to create the …

PHP Websocket Client – Keep connection open

I am using PHP-WSS in a laravel application and need to keep a websocket client open to receive various messages from the websocket server. So far I built a CLI php script that I can execute and wait for messages to arrive. I built the following function to test… The question is, to keep the connection …

Turning a CSV into a nested JSON object in PHP, Drupal 8

I’m trying to turn a CSV into a JSON object made of nested arrays for each row within the file. I’ve tried a handful of similar SO questions but haven’t found quite the right solution. I’m attempting to set up a JSON object with a handful of nested objects, based on the first value in …