- Easy and flexible routing system with pretty urls 😍
- Powerful Handlebars templates
- Convenient MYSQL CRUD functionality
- Helpful utility functions (for working with cookies, http requests, email, etc)
- Sensible (and minimal) front-end boilerplate ✨
- Straightforward application structure
- Works with most shared web hosting providers
STEREO is designed to function with most LAMP stacks, and will support very old systems. Minimum requirements: PHP: 5.3, MYSQL: 3.0, Apache: 2.4. (NGINX is also supported, see docs for configuration)
** Easiest installation: download the latest release and put the files on your server or dev environment 👍
Next-easiest installation: clone the latest version of the master branch with degit
npx degit hxgf/stereo
- Edit your global settings (site title, DB connection): ./settings.php
- Set up some routes: ./controllers/_routes.php
- Make some templates: ./pages/index.hbs
- Build something cool!
Let's render a handlebars template with a global base template with data from PHP arrays!
First, in ./controllers/_routes.php:
$app->get('/favorite-planets', function(){
$planets[] = array(
'title' => 'Mercury',
'nickname' => 'Swift Planet'
);
$planets[] = array(
'title' => 'Venus',
'nickname' => 'The Morning Star'
);
$planets[] = array(
'title' => 'Earth',
'nickname' => 'Big Blue'
);
$planets[] = array(
'title' => 'Nibiru',
'nickname' => 'Planet X'
);
$GLOBALS['app']->render_template(array(
'template' => 'planets',
'title' => 'Cool Planets',
'data' => array(
'reader_name' => 'Chad',
'planets' => $planets
)
));
});
and then in ./pages/planets.hbs:
<div class="mw8 center pa5">
Greetings, {{reader_name}}! Allow me to provide you with a list of my favorite planets:
<ul>
{{#each planets}}
<li>{{title}} ({{nickname}})</li>
{{/each}}
</ul>
</div>
Can you guess what will be rendered?
Go here to find out: https://stereotk.com/favorite-planets
Render a single PHP / HTML document:
$app->get('/normal-page', function(){
require __DIR__ . '/pages/whatever.html';
});
Render a PHP array as a JSON response:
$app->post('/json-response', function(){
// do something magic here...crunch some data? web scraping? make some API calls? idk, math??
$GLOBALS['app']->render_json(array(
'righteous_content' => 'for sure',
'planets' => array(
'Mercury', 'Venus', 'Earth', 'Nibiru'
)
));
});
Set headers / do redirects:
$app->get('/party', function(){
header("Location: http://partyphysics.com/");
});
...and that's just the beginning!
STEREO has abstraction tools to help you build all kinds of functionality!
Check out the full documentation to see everything you can do: https://stereotk.com/docs
Contributions, issues, and feature requests are welcomed and appreciated (although a timely response is not guaranteed). Check the issues page if you're interested in helping out 🙌 🙏
Copyright © 2010-2020 HXGF. This project is MIT licensed.