Wallogit.com
2017 © Pedro Peláez
A simple framework
Frmwrk is a simple and young framework. It's currently only composed of a View-Controller system (As soon as possible, model part will be included), but you can use your own database manager., (*1)
Just include the autoload.php file (generated by composer), init the config and instantiate it!, (*2)
<?php require __DIR__ . '/../vendor/autoload.php'; $config = [ 'controllers' => __DIR__ . '/../app/Controllers/', 'views' => __DIR__ . '/views/', 'web' => __DIR__ ]; \Frmwrk\Engine::init($config); $instance = \Frmwrk\Engine::getInstance(); $instance->render();
Configuration array has several parameters :, (*3)
The pretty url feature is only used to simplify urls. Here are some samples:, (*4)
http://domain.tld/CONTROLLER_NAME http://domain.tld/CONTROLLER_NAME/VAR_NAME_1/VAR_VALUE_1 http://domain.tld/CONTROLLER_NAME/VAR_NAME_1/VAR_VALUE_1/VAR_NAME_2/VAR_VALUE_2/ ect...
The first parameter, called CONTROLLER_NAME, is the name of the controller you want to load., (*5)
The next parameters always works by pair. The first one will always be the name of the variable and the second one will be the value., (*6)
http://domain.tld/index/lang/fr/ will load the controller 'index' and send him the variable lang which contains 'fr'.
These variables are sent in the init() function of the current Controller., (*7)
<?php
class index extends \Frmwrk\Controller
{
public function init($variables)
{
print_r($variables['_GET']); // Will display $_GET variables
print_r($variables['_POST']); // Will display $_POST variables
print_r($variables['_URL']); // Will display Pretty URL variables
// ...
}
}
You can now use php as tags in your views! It's currently a prototype version of the template parser, but it works. Foreach, if/elseif/else and echo are available and here how to use them:, (*8)
<foreach var="array" as="value">
Value: {{_value_}}
</foreach>
<foreach var="array" key="k" as="value">
Key: {{_k_}}<br/>
Value: {{_value_}}
</foreach>
<if cond="_myvar_ == 20">
20
<elseif cond="_myvar_ > 50">
> 50
<else>
< 50 & != 20
</if>
{{_myvar_}}
/!\ It still is a prototype and will change!, (*9)
It's a good question, and I don't really know. The framework is updated every time I see that it's missing something. The most important feature is the database management, but there is also a real template system with cache management to do., (*10)
If you have any questions or if you think there are missing information in this readme.md, please notice me., (*11)