Just a super-simple naked PHP application, useful for small projects and quick prototypes.
MINI is an extremely simple and easy to understand skeleton PHP application, reduced to the max.
MINI is NOT a professional framework and it does not come with all the stuff real frameworks have.
If you just want to show some pages, do a few database calls and a little-bit of AJAX here and there, without
reading in massive documentations of highly complex professional frameworks, then MINI might be very useful for you.
MINI is easy to install, runs nearly everywhere and doesn’t make things more complicated than necessary.
MINI has a smaller brother, named TINY. It’s similar to MINI, but runs without
mod_rewrite in nearly every environment. Not suitable for live sites, but nice for quick prototyping.
MINI also has a bigger brother, named MINI+. It’s in development and comes with an improved architecture,
SASS-compiling, Twig, Unit Tests, etc.
application/config/config.php_installation/-folder (with PHPMyAdmin for example).MINI runs without any further configuration.
TODO
TODO
The script makes use of mod_rewrite and blocks all access to everything outside the /public folder.
Your .git folder/files, operating system temp files, the application-folder and everything else is not accessible
(when set up correctly). For database requests PDO is used, so no need to think about SQL injection (unless you
are using extremely outdated MySQL versions).
MINI comes with a little customized PDO debugger tool (find the code in
application/libs/helper.php), trying to emulate your PDO-SQL statements. It’s extremely easy to use:
$sql = "SELECT id, artist, track, link FROM song WHERE id = :song_id LIMIT 1";
$query = $this->db->prepare($sql);
$parameters = array(':song_id' => $song_id);
echo Helper::debugPDO($sql, $parameters);
$query->execute($parameters);
This project is licensed under the MIT License.
This means you can use and modify it for free in private or commercial projects.
If you want to support MINI, then rent your next server at
A2Hosting or donate a coffee via
PayPal,
GitTip or
Flattr.
coming soon
The application’s URL-path translates directly to the controllers (=files) and their methods inside
application/controllers.
example.com/home/exampleOne will do what the exampleOne() method in application/controllers/home.php says.
example.com/home will do what the index() method in application/controllers/home.php says.
example.com will do what the index() method in application/controllers/home.php says (default fallback).
example.com/songs will do what the index() method in application/controllers/songs.php says.
example.com/songs/editsong/17 will do what the editsong() method in application/controllers/songs.php says and
will pass 17 as a parameter to it.
Self-explaining, right ?
Let’s look at the exampleOne()-method in the home-controller (application/controllers/home.php): This simply shows
the header, footer and the example_one.php page (in views/home/). By intention as simple and native as possible.
public function exampleOne()
{
// load views
require APP . 'views/_templates/header.php';
require APP . 'views/home/example_one.php';
require APP . 'views/_templates/footer.php';
}
Let’s look into the index()-method in the songs-controller (application/controllers/songs.php): Similar to exampleOne,
but here we also request data. Again, everything is extremely reduced and simple: $this->model->getAllSongs() simply
calls the getAllSongs()-method in application/model/model.php.
public function index()
{
// getting all songs and amount of songs
$songs = $this->model->getAllSongs();
$amount_of_songs = $this->model->getAmountOfSongs();
// load views. within the views we can echo out $songs and $amount_of_songs easily
require APP . 'views/_templates/header.php';
require APP . 'views/songs/index.php';
require APP . 'views/_templates/footer.php';
}
For extreme simplicity, all data-handling methods are in application/model/model.php. This is for sure not really
professional, but the most simple implementation. Have a look how getAllSongs() in model.php looks like: Pure and
super-simple PDO.
public function getAllSongs()
{
$sql = "SELECT id, artist, track, link FROM song";
$query = $this->db->prepare($sql);
$query->execute();
return $query->fetchAll();
}
The result, here $songs, can then easily be used directly
inside the view files (in this case application/views/songs/index.php, in a simplified example):
<tbody>
<?php foreach ($songs as $song) { ?>
<tr>
<td><?php if (isset($song->artist)) echo htmlspecialchars($song->artist, ENT_QUOTES, 'UTF-8'); ?></td>
<td><?php if (isset($song->track)) echo htmlspecialchars($song->track, ENT_QUOTES, 'UTF-8'); ?></td>
</tr>
<?php } ?>
</tbody>
MINI is the successor of php-mvc. As php-mvc didn’t provide a real MVC structure (and several people complained
about that - which is totally right!) I’ve renamed and rebuild the project.
… MINI is just a simple helper-tool I’ve created for my daily work, simply because it was much easier to setup and to
handle than real frameworks. For daily agency work, quick prototyping and frontend-driven projects it’s totally okay,
does the job and there’s absolutely no reason to discuss why it’s “shit compared to Laravel”, why it does not follow
several MVC principles or why there’s no personal unpaid support or no russian translation or similar weird stuff.
The trolling against Open-Source-projects (and their authors) has really reached insane dimensions.
I’ve written this unpaid, voluntarily, in my free-time and uploaded it on GitHub to share.
It’s totally free, for private and commercial use. If you don’t like it, don’t use it.
If you see issues, then please write a ticket (and if you are really cool: I’m very thankful for any commits!).
But don’t bash, don’t complain, don’t hate. Only bad people do so.
Please commit into the develop branch (which holds the in-development version), not into master branch
(which holds the tested and stable version).
November 2014
October 2014
September 2014
August 2014
June 2014
April 2014
January 2014