{"id":13405340,"url":"https://github.com/panique/mini3","last_synced_at":"2025-04-04T08:08:24.636Z","repository":{"id":45635099,"uuid":"64694171","full_name":"panique/mini3","owner":"panique","description":" Just an extremely simple naked PHP application, useful for small projects and quick prototypes.","archived":false,"fork":false,"pushed_at":"2024-05-13T13:56:23.000Z","size":3022,"stargazers_count":275,"open_issues_count":19,"forks_count":99,"subscribers_count":34,"default_branch":"develop","last_synced_at":"2025-03-28T07:06:44.205Z","etag":null,"topics":["micro-framework","php"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/panique.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-08-01T19:07:31.000Z","updated_at":"2025-03-22T09:02:30.000Z","dependencies_parsed_at":"2025-01-01T11:05:17.681Z","dependency_job_id":"2b9f5a4f-37d8-4445-96ea-8ae557e59482","html_url":"https://github.com/panique/mini3","commit_stats":{"total_commits":267,"total_committers":21,"mean_commits":"12.714285714285714","dds":0.1797752808988764,"last_synced_commit":"30d1baa96e2b8e2edce674bf3b31a04df535b673"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/panique%2Fmini3","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/panique%2Fmini3/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/panique%2Fmini3/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/panique%2Fmini3/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/panique","download_url":"https://codeload.github.com/panique/mini3/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247142066,"owners_count":20890652,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["micro-framework","php"],"created_at":"2024-07-30T19:01:59.427Z","updated_at":"2025-04-04T08:08:24.619Z","avatar_url":"https://github.com/panique.png","language":"PHP","funding_links":["https://www.buymeacoffee.com/panique"],"categories":["PHP","Web framework for PHP"],"sub_categories":[],"readme":"![MINI3 - A naked barebone PHP application](_install/mini3.png)\n\n# MINI3\n\nMINI3 is an extremely simple and easy to understand skeleton PHP application, reduced to the max.\nMINI3 is NOT a professional framework and does not come with all the stuff real frameworks have.\nIf you just want to show some pages, do a few database calls and a little-bit of AJAX here and there, without\nreading in massive documentations of highly complex professional frameworks, then MINI3 might be very useful for you.\nMINI3 is easy to install, runs nearly everywhere and doesn't make things more complicated than necessary.\n\n\n[MINI](https://github.com/panique/mini) (original version) and [MINI2](https://github.com/panique/mini2) (used Slim router) were built by me (panique), MINI3 is an excellent and improved version\nof the original MINI, made by [JaoNoctus](https://github.com/JaoNoctus). Big thanks, man! :)\n\n## Features\n\n- extremely simple, easy to understand\n- simple but clean structure\n- makes \"beautiful\" clean URLs\n- demo CRUD actions: Create, Read, Update and Delete database entries easily\n- demo AJAX call\n- tries to follow PSR coding guidelines\n- uses PDO for any database requests, comes with an additional PDO debug tool to emulate your SQL statements\n- commented code\n- uses only native PHP code, so people don't have to learn a framework\n- uses PSR-4 autoloader\n\n## Requirements (but it's auto-installed)\n\n- PHP 8\n- MySQL\n- basic knowledge of Composer for sure\n- for auto-installation: VirtualBox, Vagrant\n\n## Forks\n\nThere are some nice upgraded versions of this mini framework, check it out at https://github.com/ribafs/php-router\n\n## Installation (in Vagrant, 100% automatic)\n\nTo keep things super-simple, we are using Vagrant here, a simple technology to run virtual machines for development.\nIt's outdated, but does the job, and is much easier to understand than Docker. Just install VirtualBox, Vagrant, then\ncopy this repo's code to a folder, go to that folder and type:\n\n```bash\nvagrant up\n```\n\nThis will create a virtual machine with the configs given in `Vagrantfile`: It will create an Ubuntu 2022.04 Jammy64\nVM with 1024MB RAM, sync the current folder to `/var/www/html` inside the VM, make the VM available on the IP\n`192.168.56.77` and start the bash script `bootstrap.sh`, which is just a set of commands that will install all \nnecessary software.\n\nIf the auto-installer is finished, go to http://192.168.56.77 in your browser and click around a bit ;)\n\n# OLD INSTALLATION TUTORIALS FROM 2016\n\nBelow you'll find installation tutorial for the old version of MINI3 from 2016.\n\n## Installation (in Vagrant, 100% automatic)\n\nIf you are using Vagrant for your development, then you can install MINI3 with one click (or one command on the\ncommand line) [[Vagrant doc](https://docs.vagrantup.com/v2/getting-started/provisioning.html)]. MINI3 comes with a demo\nVagrant-file (defines your Vagrant box) and a demo bootstrap.sh which automatically installs Apache, PHP, MySQL,\nPHPMyAdmin, git and Composer, sets a chosen password in MySQL and PHPMyadmin and even inside the application code,\ndownloads the Composer-dependencies, activates mod_rewrite and edits the Apache settings, downloads the code from GitHub\nand runs the demo SQL statements (for demo data). This is 100% automatic, you'll end up after +/- 5 minutes with a fully\nrunning installation of MINI3 inside an Ubuntu 14.04 LTS Vagrant box.\n\nTo do so, put `Vagrantfile` and `bootstrap.sh` from `_vagrant` inside a folder (and nothing else).\nDo `vagrant box add ubuntu/trusty64` to add Ubuntu 14.04 LTS (\"Trusty Thar\") 64bit to Vagrant (unless you already have\nit), then do `vagrant up` to run the box. When installation is finished you can directly use the fully installed demo\napp on `192.168.33.66`. As this just a quick demo environment the MySQL root password and the PHPMyAdmin root password\nare set to `12345678`, the project is installed in `/var/www/html/myproject`. You can change this for sure inside\n`bootstrap.sh`.\n\n## Auto-Installation on Ubuntu 14.04 LTS (in 30 seconds)\n\nYou can install MINI3 including Apache, MySQL, PHP and PHPMyAdmin, mod_rewrite, Composer, all necessary settings and\neven the passwords inside the configs file by simply downloading one file and executing it, the entire installation\nwill run 100% automatically. If you are stuck somehow, also have a look into this tutorial for the original MINI1,\nit's basically the same installation process:\n[Install MINI in 30 seconds inside Ubuntu 14.04 LTS](http://www.dev-metal.com/install-mini-30-seconds-inside-ubuntu-14-04-lts/)\n\n## Manual Installation\n\n1. Edit the database credentials in `application/config/config.php`\n2. Execute the .sql statements in the `_install/`-folder (with PHPMyAdmin for example).\n3. Make sure you have mod_rewrite activated on your server / in your environment. Some guidelines:\n   [Ubuntu 14.04 LTS](http://www.dev-metal.com/enable-mod_rewrite-ubuntu-14-04-lts/),\n   [Ubuntu 12.04 LTS](http://www.dev-metal.com/enable-mod_rewrite-ubuntu-12-04-lts/),\n   [EasyPHP on Windows](http://stackoverflow.com/questions/8158770/easyphp-and-htaccess),\n   [AMPPS on Windows/Mac OS](http://www.softaculous.com/board/index.php?tid=3634\u0026title=AMPPS_rewrite_enable/disable_option%3F_please%3F),\n   [XAMPP for Windows](http://www.leonardaustin.com/blog/technical/enable-mod_rewrite-in-xampp/),\n   [MAMP on Mac OS](http://stackoverflow.com/questions/7670561/how-to-get-htaccess-to-work-on-mamp)\n4. Install composer and run `composer install` in the project's folder to create the PSR-4 autoloading stuff from Composer automatically.\n   If you have no idea what this means: Remember the \"good\" old times when we were using \"include file.php\" all over our projects to include and use something ?\n   PSR-0/4 is the modern, clean and automatic version of that. Please have a google research if that's important for you.  \n   \nFeel free to commit your guideline for Ubuntu 16.04 LTS or other linuxes to the list!  \n\nMINI3 runs without any further configuration. You can also put it inside a sub-folder, it will work without any\nfurther configuration.\nMaybe useful: A simple tutorial on [How to install LAMPP (Linux, Apache, MySQL, PHP, PHPMyAdmin) on Ubuntu 14.04 LTS](http://www.dev-metal.com/installsetup-basic-lamp-stack-linux-apache-mysql-php-ubuntu-14-04-lts/)\nand [the same for Ubuntu 12.04 LTS](http://www.dev-metal.com/setup-basic-lamp-stack-linux-apache-mysql-php-ubuntu-12-04/).\n\n## Server configs for\n\n### nginx\n\n```nginx\nserver {\n    server_name default_server _;   # Listen to any servername\n    listen      [::]:80;\n    listen      80;\n\n    root /var/www/html/myproject/public;\n\n    location / {\n        index index.php;\n        try_files /$uri /$uri/ /index.php?url=$uri;\n    }\n\n    location ~ \\.(php)$ {\n        fastcgi_pass   unix:/var/run/php5-fpm.sock;\n        fastcgi_index  index.php;\n        fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;\n        include fastcgi_params;\n    }\n}\n```\n\nA deeper discussion on nginx setups can be found [here](https://github.com/panique/mini/issues/55).\n\n## Security\n\nThe script makes use of mod_rewrite and blocks all access to everything outside the /public folder.\nYour .git folder/files, operating system temp files, the application-folder and everything else is not accessible\n(when set up correctly). For database requests PDO is used, so no need to think about SQL injection (unless you\nare using extremely outdated MySQL versions).\n\n## How to include stuff / use PSR-4\n\nAs this project uses proper PSR-4 namespaces, make sure you load/use your stuff correctly:\nInstead of including classes with old-school code like `include xxx.php`, simply do something like `use Mini\\Model\\Song;` on top of your file (modern IDEs even do that automatically).\nThis would automatically include the file *Song.php* from the folder *Mini/Model* (it's case-sensitive!).\n \nBut wait, there's no `Mini/Model/Song.php` in the project, but a `application/Model/Song.php`, right ?\nTo keep things cleaner, the composer.json sets a *namespace* (see code below), which is basically a name or an alias, for a certain folder / area of your application,\nin this case the folder `application` is now reachable via `Mini` when including stuff.\n\n```\n{\n    \"psr-4\":\n    {\n        \"Mini\\\\\" : \"application/\"\n    }\n}\n```\n\nThis might look stupid at first, but comes in handy later. To sum it up:\n\nTo load the file `application/Model/Song.php`, write a `use Mini\\Model\\Song;` on top of your controller file.\nHave a look into the SongController to get an idea how everything works!\n\nFYI: As decribed in the install tutorial, you'll need do perform a \"composer install\" when setting up your application for the first time, which will\ncreate a set of files (= the autoloader) inside /vendor folder. This is the normal way Composer handle this stuff. If you delete your vendor folder \nthe autoloading will not work anymore. If you change something in the composer.json, always make sure to run composer install/update again!\n\n## Goodies\n\nMINI3 comes with a little customized [PDO debugger tool](https://github.com/panique/pdo-debug) (find the code in\napplication/libs/helper.php), trying to emulate your PDO-SQL statements. It's extremely easy to use:\n\n```php\n$sql = \"SELECT id, artist, track, link FROM song WHERE id = :song_id LIMIT 1\";\n$query = $this-\u003edb-\u003eprepare($sql);\n$parameters = array(':song_id' =\u003e $song_id);\n\necho Helper::debugPDO($sql, $parameters);\n\n$query-\u003eexecute($parameters);\n```\n\n## License\n\nThis project is licensed under the MIT License.\nThis means you can use and modify it for free in private or commercial projects.\n\n## Quick-Start\n\n#### The structure in general\n\nThe application's URL-path translates directly to the controllers (=files) and their methods inside\napplication/controllers.\n\n`example.com/home/exampleOne` will do what the *exampleOne()* method in application/Controller/HomeController.php says.\n\n`example.com/home` will do what the *index()* method in application/Controller/HomeController.php says.\n\n`example.com` will do what the *index()* method in application/Controller/HomeController.php says (default fallback).\n\n`example.com/songs` will do what the *index()* method in application/Controller/SongsController.php says.\n\n`example.com/songs/editsong/17` will do what the *editsong()* method in application/Controller/SongsController.php says and\nwill pass `17` as a parameter to it.\n\nSelf-explaining, right ?\n\n#### Showing a view\n\nLet's look at the exampleOne()-method in the home-controller (application/Controller/HomeController.php): This simply shows\nthe header, footer and the example_one.php page (in views/home/). By intention as simple and native as possible.\n\n```php\npublic function exampleOne()\n{\n    // load view\n    require APP . 'views/_templates/header.php';\n    require APP . 'views/home/example_one.php';\n    require APP . 'views/_templates/footer.php';\n}\n```  \n\n#### Working with data\n\nLet's look into the index()-method in the songs-controller (application/Controller/SongsController.php): Similar to exampleOne,\nbut here we also request data. Again, everything is extremely reduced and simple: $Song-\u003egetAllSongs() simply\ncalls the getAllSongs()-method in application/Model/Song.php (when $Song = new Song()).\n\n```php\nnamespace Mini\\Controller\n\nuse Mini\\Model\\Song;\n\nclass SongsController\n{\n    public function index()\n    {\n        // Instance new Model (Song)\n        $Song = new Song();\n        // getting all songs and amount of songs\n        $songs = $Song-\u003egetAllSongs();\n        $amount_of_songs = $Song-\u003egetAmountOfSongs();\n\n        // load view. within the view files we can echo out $songs and $amount_of_songs easily\n        require APP . 'views/_templates/header.php';\n        require APP . 'views/songs/index.php';\n        require APP . 'views/_templates/footer.php';\n    }\n}\n```\n\nFor extreme simplicity, data-handling methods are in application/model/ClassName.php. Have a look how getAllSongs() in model.php looks like: Pure and\nsuper-simple PDO.\n\n```php\nnamespace Mini\\Model\n\nuse Mini\\Core\\Model;\n\nclass Song extends Model\n{\n    public function getAllSongs()\n    {\n        $sql = \"SELECT id, artist, track, link FROM song\";\n        $query = $this-\u003edb-\u003eprepare($sql);\n        $query-\u003eexecute();\n\n        return $query-\u003efetchAll();\n    }\n}\n```\n\nThe result, here $songs, can then easily be used directly\ninside the view files (in this case application/views/songs/index.php, in a simplified example):\n\n```php\n\u003ctbody\u003e\n\u003c?php foreach ($songs as $song) { ?\u003e\n    \u003ctr\u003e\n        \u003ctd\u003e\u003c?php if (isset($song-\u003eartist)) echo htmlspecialchars($song-\u003eartist, ENT_QUOTES, 'UTF-8'); ?\u003e\u003c/td\u003e\n        \u003ctd\u003e\u003c?php if (isset($song-\u003etrack)) echo htmlspecialchars($song-\u003etrack, ENT_QUOTES, 'UTF-8'); ?\u003e\u003c/td\u003e\n    \u003c/tr\u003e\n\u003c?php } ?\u003e\n\u003c/tbody\u003e\n```\n\n## Contribute\n\nPlease commit into the develop branch (which holds the in-development version), not into master branch\n(which holds the tested and stable version).\n\n## Changelog\n\n**August 2016**\n\n- [panique] fix for weird lowercase/uppercase path problem (also big thanks to @snickbit \u0026 @ugurozturk for the fix!)\n- [panique] forking joanoctus's excellent PSR4 ersion of MINI to MINI3\n\n**January 2016**\n\n- [joanoctus] implementing PSR-4 autoloader\n\n**February 2015**\n\n- [jeroenseegers] nginx setup configuration\n\n**December 2014**\n- [panique] css fixes\n- [panique] renamed controller / view to singular\n- [panique] added charset to PDO creation (increased security)\n\n**November 2014**\n- [panique] auto-install script for Vagrant\n- [panique] basic documentation\n- [panique] PDO-debugger is now a static helper-method, not a global function anymore\n- [panique] folder renaming\n- [reg4in] JS AJAX calls runs now properly even when using script in sub-folder\n- [panique] removed all \"models\", using one model file now\n- [panique] full project renaming, re-branding\n\n**October 2014**\n- [tarcnux/panique] PDO debugging\n- [panique] demo ajax call\n- [panique] better output escaping\n- [panique] renamed /libs to /core\n- [tarcnux] basic CRUD (create/read/update/delete) examples have now an U (update)\n- [panique] URL is now config-free, application detects URL and sub-folder\n- [elysdir] htaccess has some good explanation-comments now\n- [bst27] fallback for non-existing controller / method\n- [panique] fallback will show error-page now\n- [digitaltoast] URL split fix to make php-mvc work flawlessly on nginx\n- [AD7six] security improvement: moved index.php to /public, route ALL request to /public\n\n**September 2014**\n- [panique] added link to support forum\n- [panique] added link to Facebook page\n\n**August 2014**\n- [panique] several changes in the README, donate-button changes\n\n**June 2014**\n- [digitaltoast] removed X-UA-Compatible meta tag from header (as it's not needed anymore these days)\n- [digitaltoast] removed protocol in jQuery URL (modern way to load external files, making it independent to protocol change)\n- [digitaltoast] downgraded jQuery from 2.1 to 1.11 to avoid problems when working with IE7/8 (jQuery 2 dropped IE7/8 support)\n- [panique] moved jQuery loading to footer (to avoid page render blocking)\n\n**April 2014**\n- [panique] updated jQuery link to 2.1\n- [panique] more than 3 parameters (arguments to be concrete) are possible\n- [panique] cleaner way of parameter handling\n- [panique] smaller cleanings and improvements\n- [panique] Apache 2.4 install information\n\n**January 2014**\n- [panique] fixed .htaccess issue when there's a controller named \"index\" and a base index.php (which collide)\n\n## Other stuff\n\nAnd by the way, I'm also blogging at [Dev Metal](http://www.dev-metal.com) :)\n\n## Support the project\n\n\u003ca href=\"https://www.buymeacoffee.com/panique\" target=\"_blank\"\u003e\u003cimg src=\"https://cdn.buymeacoffee.com/buttons/v2/default-yellow.png\" alt=\"Buy Me A Coffee\" style=\"height: 60px !important;width: 217px !important;\" \u003e\u003c/a\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpanique%2Fmini3","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpanique%2Fmini3","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpanique%2Fmini3/lists"}