HTTPie – Command line HTTP client

httpie

HTTPie (pronounced aych-tee-tee-pie) is a command line HTTP client. Its goal is to make CLI interaction with web services as human-friendly as possible. It provides a simple http command that allows for sending arbitrary HTTP requests using a simple and natural syntax, and displays colorized output. HTTPie can be used for testing, debugging, and generally interacting with HTTP servers.

HTTPie — A command line HTTP client, a user-friendly cURL replacement →

ping.gg – The world’s most simple monitoring service.

~$# start monitoring your server with a single curl command.
~$curl ping.gg/me@example.org/104.28.13.51
[ ok ] Ping alert created for host '104.28.13.51' and email 'me@example.org'. Check your email to activate it.
 
~$# activate the first and the next ones are activated automatically.
~$curl ping.gg/me@example.org/example.org
[ ok ] Ping alert created for host 'example.org' and email 'me@example.org'.
 
~$# you can skip the IP if you run it from the server, watch out for proxies, etc.
~$curl ping.gg/me@example.org
[ ok ] Ping alert created for host '104.28.12.51' (your IP) and email 'me@example.org'.

No website or admin panel or whatever. Just some simple HTTP requests. I love the simplicity in this.

Ping.gg – The world’s most simple monitoring service →

ANSI Control Functions and ANSI Control Sequences (Colors, Erasing, etc.) for PHP CLI Apps

As a side project for Monolog Colored Line Formatter (which int itself also is a side project for Mixed Content Scan) I just published is ANSI PHP.

bramus/ansi-php is a set of classes to working with ANSI Control Functions and ANSI Control Sequences (ANSI Escape Sequences) on text based terminals.

  • ANSI Control Functions control an action such as line spacing, paging, or data flow.
  • ANSI Control Sequences allow one to clear the screen, move the cursor, set text colors, etc.

When it comes to ANSI Escape Sequences bramus/ansi-php supports SGR (Select Graphic Rendition) and ED (Erase Display)

  • SGR affords one to manipulate text styling (bold, underline, blink, colors, etc.).
  • ED allows one to erase the display.

Other Control Sequences – such as moving the cursor – are not (yet) supported.

It differs from other “PHP ANSI Color” attempts by not being limited to SGR only – it can easily be extended to support other ANSI Escape Sequences – and by supporting all SGR parameters.

The library ships with an Ansi helper class to easily use it.

use \Bramus\Ansi\Ansi;
use \Bramus\Ansi\ControlSequences\EscapeSequences\Enums\SGR;

// Create Ansi Instance
$a = new Ansi();

// Output some styled text on screen, along with a Line Feed and a Bell
echo $a->color(array(SGR::COLOR_FG_RED, SGR::COLOR_BG_WHITE))
       ->blink()
       ->text('My text will be white on a red background and I will be blinking.')
       ->nostyle()
       ->lf()
       ->text('I will be normally styled. Oh, a bell is coming up ...')
       ->bell()
       ->get();

Installation of course is possible via Composer:

composer require bramus/ansi-php ~2.0

ANSI PHP — ANSI Control Functions and ANSI Control Sequences (Colors, Erasing, etc.) for PHP CLI Apps →

Did this help you out? Like what you see?
Consider donating.

I don’t run ads on my blog nor do I do this for profit. A donation however would always put a smile on my face though. Thanks!

☕️ Buy me a Coffee ($3)

Batch install dependencies in all subfolder-organised projects

As a lecturer ICT I have to correct the work our students make. Therefor I collect all solutions and put them in a subfolder-organised structure on disk: per student I create a subfolder and put their solution into that folder(*).

$ tree -L 1
.
├── student1
├── student2
├── ...
└── studentN

As – from the 2nd year on – most of our projects use some sort of dependency manager I often found myself manually cding into folders and running the command to install the dependencies.

Today I knocked up a one-liner to install all PHP dependencies (using Composer) in subfolder-organised projects. My first attempt was pretty awful, yet with a hint by Frank I eventually cleaned it up:

find . -name composer.json -maxdepth 2 -execdir composer install \;

With some minor modifications the command can also be used to installing dependencies using npm:

find . -name package.json -maxdepth 2 -execdir npm install \;

(*) actually, a handy app created by a colleague of mine bash script I wrote does this automatically for me, but that’s not the gist of this post

Did this help you out? Like what you see?
Consider donating.

I don’t run ads on my blog nor do I do this for profit. A donation however would always put a smile on my face though. Thanks!

☕️ Buy me a Coffee ($3)