Skip to content
/ amini Public

amini project inspire by panique/mini, may be another mini php mvc framework for quick create web/cli/prototypes job, so i name it with amini. it will be keep thin size and easy read code. amini support multi module

Notifications You must be signed in to change notification settings

mgckid/amini

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MINI - A naked barebone PHP application

MINI

this project inspire by panique/mini, may be another mini php mvc framework for quick create web/cli/prototypes job, so i name it with amini. it will be keep thin size and easy read code. amini support multi module

Used Libs or inspire by

Installation

 in php intenel http server:
   1. cd "your amini project public root "
   2. php -S 127.0.0.1:88 -t your amini project public root 
   
   for example:
       cd D:\www\gitea\amini\public\
       php -S 127.0.0.1:88 -t D:\www\gitea\amini\public\
    
  than you can open http://127.0.0.1:88 in your brower to access this demo site
    
   

Features

  • extremely simple, easy to understand
  • simple but clean structure
  • makes "beautiful" clean URLs
  • demo CRUD actions: Create, Read, Update and Delete database entries easily
  • demo AJAX call
  • tries to follow PSR 1/2 coding guidelines
  • uses PDO for any database requests, comes with an additional PDO debug tool to emulate your SQL statements
  • commented code
  • uses only native PHP code, so people don't have to learn a framework

Requirements

  • PHP 7.0+ (when first released), now it works fine with current stable versions PHP 7 and 7.1, 7.2., 7.3 and 7.4. The latest PHP 8.0 is not tested yet but should also work fine.
  • SQLITE

Security

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).

Goodies

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);

Why has the "Error" class been renamed to "Problem"?

The project was written in PHP5 times, but with the release of PHP7 it's not possible anymore to name a class "Error" as PHP itself has a internal Error class now. Renaming was the most simple solution, compared to other options like "ErrorController" etc. which would add new problems like uppercase filenames etc. (which will not work properly on some setups).

License

This project is licensed under the MIT License. This means you can use and modify it for free in private or commercial projects.

Quick-Start

The structure in general

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 ?

Showing a view

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 view
    require APP . 'views/_templates/header.php';
    require APP . 'views/home/example_one.php';
    require APP . 'views/_templates/footer.php';
}

Working with data

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 view. within the view files 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>

History

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.

Dear haters, trolls and everything-sucks-people...

... 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.

Contribute

Please commit into the develop branch (which holds the in-development version), not into master branch (which holds the tested and stable version).

Changelog

December 2025

  • [panique] init version

Support the project

About

amini project inspire by panique/mini, may be another mini php mvc framework for quick create web/cli/prototypes job, so i name it with amini. it will be keep thin size and easy read code. amini support multi module

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages