Fun project to make a real framework based on twittee container. (https://twittee.org/)
HowTo
-
use composer to get "yarooze/minime" from the github (and whatever modules you need)
-
Copy files from the "skeleton" dir into your project root dir
-
Overwrite base classes in "/src/app/" as you wish.
-
set up your stuff in "src/app.php" and configure in "/config/*"
-
For CLI use something like "internal/service.php" for web - "web/index.php"
-
Enjoy!
(This is only a brief description, for more information look into the code) Minime is a typical MVC framework, so the code is separated to:
Controllers
- have theactions
which are called if the route is matched. The action prepares the data and callsView
for the presentation.Core
- are the core parts of the framework:
2.1Config
- loads the config from theconfig/config_app.php
and is always available from the$app->config
2.2Flasher
- manages the flash messages
2.3HttpCache
- sendsHTTP/1.1 304 Not Modified
if needed
2.4I18n
- internationalization service
2.5Logger
- log service
2.6PDO
- data base connection service
2.7Request
- request data is here
2.8Router
- reads routes from theconfig/routing.php
and manages the whole routing stuff of the app
2.9Session
- user session is hereException
- custom exceptions are hereForm
- minime formsHelper
- helpers with additional functionsModel
- themodel
part of the MVC. The entities classes are hereSecurity
- all kinds of authentication and security stuff are hereService
- other servicesTemplates
- view and partial templatesView
- to prepare the headers and render the templates
This is a usual mimime
structure
garampel
├───bin <-- console tools like .bat or .sh files
├───cache <-- cache directory
├───config <-- app configs are here. The most important are `routing.php` and `config_app.php`
├───i18n <-- translation files like `en.php` for the I18n service.
├───internal <-- entry point to use your app as internal service
├───log <-- internal log directory if you don't use global logs directory
├───src <-- your app is here
│ └───app
│ ├───controller
│ ├───core
│ ├───exception
│ ├───form
│ ├───helper
│ ├───model
│ ├───security
│ ├───service
│ ├───templates
│ └───view
├───vendor <-- vendor stuff (usually installed by composer)
└───web <-- apache DocumentRoot is here
└───assets
├───css
├───img
└───js
There are two ways to use the application. internal
and web
.
- include
PATH/internal/service.php
in your another project - call
$yourMinimeApp = getMiniApp();
- now you can use the app services like
$yourMinimeApp->someService->getDataByName('some-id')
- Configure everything in the
config/config_app.php
. Also set the environment (env
) there todev
orprod
. - Make
web
to your apache project root directory. (rewrite roles will send all request to index.php) web/index.php
will call thesrc/bootstrap.php
andsrc/app.php
src/app.php
loads the services and starts the application- After everything is prepared (services are loaded route and request are parsed, session is loaded, user credentials are checked) the matched controller action will be called.
- Controller action will do some action stuff and then either make the redirect or put the data into view and call
View::render()
- View sends the headers and then renders the template.