Celestial Framework

Celestial Framework is a new kind of framework designed for front-end developers. Spend less time writing PHP and more time shipping UIs.

Celestial Framework comes prebuilt with pages, templates like the header and footer, functions, forms, buttons, and anything you could think of. It can help you jumpstart your projects and get to the fun part: the coding. No more figuring out what meta tags your site needs, or where the include(); needs to go without breaking the page. Celestial Framework handles all this for you.

So Why Another Framework?

Laravel & Lumen, CakePHP, Symfony, Yii, Spring, and Django are all great systems and are wonderful for skilled back-end developers to build complex and efficient sites. They're great at what they were designed for: back-end development. But what if you aren't a backend developer? What if you aren't that familiar with backend code, but you are interested in launching your own website? That's where Celestial Framework comes in.

The framework is written from the ground up to be front-end developer-centric. It takes into account the Developer Experience, and makes sure that you know exactly what code you are writing whenever you write it. For example, I wrote Celestial Framework to have common language functions like "Create -> PhoneNumber" instead of using technical jargon. No more guessing what the Laravel class function is called when you want to query the database.

Laravel

namespace App\Http\Controllers;

use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\DB;

class UserController extends Controller
{
/**
* Show a list of all of the application's users.
*
* @return \Illuminate\Http\Response
*/

public function index()
{
$users = DB::table('users')->get();

return view('user.index', ['users' => $users]);
}
}

Celestial Framework

// Pull all users
$users = $db->Select("SELECT * FROM Users");

// Automatically return the global $data value
$data['page']['users'] = $users;
<table>
<tbody>
{% for user in page.users %}
<tr>
<td>{{ user.name }}</td>
<td>{{ user.email }}</td>
</tr>
{% endfor %}
</tbody>
</table>

Using straight to the point, and clear method names, you can grab any content you want from the database using the $db class, and the Select method. From then, you can assign it to the global $data under any key name you want, and the framework will automatically provide that to you in your Twig templates. You reference it just like a JSON value in javascript. Calling page.users inside your Twig code will provide you the entire array list of users and the associated content.

It should be noted that the above Laravel example isn't entirely fair. It has a lot of advanced features such as caching, and other important things. My main issue with the previously listed frameworks is how the documentation is written and how the code itself is laid out. Its not very beginner friendly.

Security

Out of the box, Celestial Framework uses prepared statements with no additional setup. Prepared statements protect your database from malicious users trying to access or gain control of your back-end system. It also has the Twig templating engine powering the front-end code, adding another level of security to prevent XSS attacks.

The Twig templating engine is also very IDE friendly, and lets you map out entire layouts without using broken PHP partial files like Wordpress, and other home grown systems.

The Built In APIs

There are two main ways to deal with data through Celestial Framework. The Create and Show APIs.

When you need to take content from a user and insert it into the database, or create something new to store, you use the Create API. It has a lot of handy functions like...

// Convert any string into a valid number.
// Automatically strips white space, non-numeric characters
// And converts to an Integer format
$Create->Number('000-111-2222'); // int 1112222

// This functions takes a valid phone number of any type
// and converts it to a string format with no special characters
// This is used in tandem with $Show->PhoneNumber(); function
$Create->PhoneNumber('012-345-6789'); // string '0123456789'

// This creates a web-safe slug URL of whatever string is passed through
$Create->URL('My New Blog Post'); // 'my-new-blog-post'

// This creates a cryptographically secure string
$Create->Random(); // 60 character long string

// This connects into mailing services like MailGun
// to send email using custom email templates defined
// in the "email" folder
$Create->Mail(
$To,
$Subject,
$EmailTemplate,
$EmailContent = [],
$Type = "mail"
);

And many many more.

These functions are written to be as developer-friendly as possible. It isn't necessary to call specific libraries on each page you build. In Celestial Framework, the APIs are kept lean and mean, and are available on any page you work on. For the most part, you'll only use these when you are defining your pages or building a custom API (which is very fun to do!). There's a single api.php file and a router.php file that stores all of your project specific PHP code.

Everything is built on Twig.

The Front-End

<!doctype html>
<html lang="en">
<head>
<title>{{ title }}</title>
</head>
<body>
{% include "components/header.twig" %}

<div id="main">
{# Load the requested page. #}
{% include page.template ~ '.twig' %}
</div><!-- end main -->

{% include "components/footer.twig" %}
</body>
</html>

Whole. Complete. Templates. No more guessing if you closed a div tag in the header, or if you left something open in the footer. The templates render as one solid block and compile to cached HTML for super fast access.

From here on out, you can build your HTML however you like. You can pass any data from the backend using easy-to-use, and heavily documented APIs (with lots of examples!).

In Closing

This was a huge undertaking and I learned so much about the PHP ecosystem, along with learning MySQL, and how package managers like Composer work. Although it took a while to get Version 1 off the ground (working a full time job and working on other personal projects simultaneously will do that to you!), it was important to me to contribute to the open-source community. I'm happy to say that there are a couple of sites out in the wild running the Celestial Framework, so that keeps me inspired to keep the project going. Version 2 is in the works and should be an even greater improvement on the Developer Experience ✌.

If you want more, check it out for yourself!

The Celestial Framework Website

Finito! (The End)

Thanks for reading!