A simple but powerful PHP nanoframework for building APIs at light speed.

1.0.0 2016-12-08 04:24 UTC


Rad Logo

A PHP nanoframework for building APIs at light speed.


Rad provides the following basic classes to get you started building an API.


A base class that does a whole lot of stuff I don't have time to write about.


A basic but robust router, which takes a HTTP-Request-URI as the constructor argument: __construct($route).

Provides various methods to perform actions based on the given URI.


$router = Rad\Router($currentURI);
$entity = Rad\Base;

$router->get('/users', function ($params, $query) {

$router->get('/users/:userID', function ($params, $query) {


A class which provides a basic API controller. Automatically gathers data sent to php://input as $this->input, and other cool things I'll write about sooner or later.


A class which provides a collection of commonly-used (in my experience) utilities, all accessible as static methods.

Recommended usage:

use Rad\Tools as Tools;

class MyClass {
	public function example () {
		echo Tools::firstName('Austin Billings');
		# Returns "Austin"

See more at their documentation.


A class which extends Rad\Base and lets you easily prepare and send email server-side via Sendgrid, Mandrill, Amazon SES, or vanilla PHP with little to zero effort.

Quick CLI Example (can easily also be used as a web service)

From terminal:

composer require austinbillings/rad
touch MySendScript.php

Now, the fun part:

# MySendScript.php


# $blast is the HTML content of our email message
# As long as the first character of the HTML is '<',
# a plaintext version is automatically generated and sent as well.
# It can be specified separately by the #setMessage() function,
# or by using an associative array here, like this:
# $blast = ["text" => $myTextMessage, "html" => $myHtmlVersion];
$blast = file_get_contents(__DIR__ . '/blast.html');
echo "Blast size is ".strlen($blast)." chars\n\n";

# Let's use dat Courier.
$sender = new Rad\Courier([
  "system" => "SendGrid", # case insensitive, accepts sendgrid, mandrill, ses, defaults to PHP
  "sendGridKey"=> "SG.abcdefghijklm_abcdefgh.1-gabby0123456789abcdefghijklmnopqrstuvwxyz",
  "to" => $someListOfEmails, # You can use a string OR an array here
  "from" => "austin@awesome-marketing.net", # Address of the SENDER
  "name" => "GroundUP Music Festival", # Name of the SENDER
  "subject" => "GroundUp Music Festival lands on Miami Beach next week!",


# ->send() synchronously returns a boolean: true if all sent, false if any failure.
echo ($sender->send() ? 'Sent successfully!' : 'Send failed.')."\n";

# ----------------------------------------------------------------------
#                       yeah, it's that easy!
# ----------------------------------------------------------------------

Then, simply run your script to send out the email blast.

php MySendScript.php
> Blast size is 3175 chars
> Sent successfully!