Readable Streams are API responses that are broken into small chunks and sent to the client. As the client should be able to parse the chunks of received data as they arrive the conventional JSON responses are not ideal to be used for streams. So In most cases, streamable API endpoints should send the data… Continue reading Parsing ndjson stream API’s with PHP
Tag: PHP
Team Engagement, Randomly Pick a member in Slack
I’ve build a slack application that picks a random member of your channel, all in the name of team engagement.
Run PHP codes on the fly using phpExec
phpExec is a small tool I did to execute php snippets on the fly. Basically it is like jsfiddle for php which should be hosted by yourself. phpExec is a simple script written in php which provides an in-browser editor to write and run php codes. the only requirement would be having php binaries on… Continue reading Run PHP codes on the fly using phpExec
Detect MIME type and buffer it to browser using PHP
The following piece of code handles detection of mime type, file size and existence of the file for you. I always use this piece for buffering files into browser of my users. if (file_exists($fileLocation)) { header(‘Content-Description: File Transfer’); header(‘Content-Type: ‘ .mime_content_type($fileLocation)); header(‘Content-Disposition: attachment; filename=”‘.basename($fileLocation).'”‘); header(‘Expires: 0’); header(‘Cache-Control: must-revalidate’); header(‘Pragma: public’); header(‘Content-Length: ‘ . filesize($fileLocation)); readfile($fileLocation);… Continue reading Detect MIME type and buffer it to browser using PHP