Releases: volter9/mini_framework
Routing fix
2.0.0
There's a lot of changes happened to the mini_framework. The brief list of these changes:
- Namespaces for each module (almost every module) were added.
- Global refactoring (code readability improvement).
- Each API module can be initiated via
loader\api($module_name, $array_arguments)
. - Most of modules covered by unit-tests
Router module changes:
- Router now only accepts
callable
's as second parameter. - Actions were added (helpers for routing)
- Function
route
was renamed torouter\map
View module changes:
- Views now can be rendered from
view.directory
instead ofview.directory/template_name/html
ifview.template
is not specified in config - Function
view\capture
was added
Other modules changes:
- Validation returns only error codes instead of localized messages (
validation\validate_field
now can be used to validate only one value). - Pagination was improved (bug were fixed)
- Events' function
events
was removed, the functionevents\bind
now is the container i18n
function was renamed toi18n\get
load_language
function was renamed toi18n\load
load_model
function was renamed toloader\model
and works differently (because of namespaces)
Config specification changes:
templates
key in config is renamed toview
database
key is renamed todb
routing
key was removed (thereforebase_url
andsymbols
keys were removed)
Finally, in detail review of changes:
Namespaces
Namespaces were introduced to the 2.0.0. Now each module, controller and models should be contained in the namespace. Most of the API changed due to the namespace introduction (actions, loader\model
).
Module API
API modules are the core modules of mini_framework. Before 2.0, modules were loaded by function load_system
and initialized in system_load
function. Now, modules are loaded and initialized inside of loader\system
and to every init
function of every module (if init
function exists) passed an array of settings from config on app\boot
.
If you need to initialize module manually, by invoking loader\api
, you should also provide an array with expected keys and values.
Router changes
Because of namespaces it became harder to parse file:action
second argument to route
function. Instead of parsing, I introduced "actions".
Actions are basically functions which returns a closure which lazy-loads controller actions (functions in separate files). There's brief example:
router\map('GET page /page/:num', actions\controller(
'view', '\actions\page',
'app/actions/page'
));
If this route would be found and executed, actions\controller
would lazy load app/actions/page.php
, and invoke \actions\page\init
(if it exists) and \actions\page\view
.
1.2.3
- Internal modification of router therefore allowing to write different response processors
auto_dispatching
fixautoload.files
config key fix (which resulted to error if the key is missing in array)autoload.modules
config key was added – now you can pass modules names (in mini_framework) which you want to load instead of predefined ones- In each module there was added
@require
's to identify which other modules are dependencies of current module (most of them are dependent uponstorage
andarray
)
1.2.2
- Pagination was fixed and broken
view_path
now also accepts absolute path (it means that you can use any file, and not only views in templates)prepare
renamed todb_prepare
- DB now can accept raw DSN or DSN attributes ('key' => 'value' turns into 'key=value;' in DSN)
- New DB function
db_query
, which just performs a database query and returnsPDOStatement
- Loader isn't dependent on
repo
or any other component (however, functionsload_app_file
andload_api
need corresponding constants:MF_APP_DIR
andMF_API_DIR
)