dev-master
9999999-dev https://github.com/nikis/MocaDatabase and Cache providers
MIT
The Requires
- php >=5.3.0
by Nikolay Tsanov
database cache
Wallogit.com
2017 © Pedro Peláez
Database and Cache providers
Easy code scaling for Silex framework., (*1)
<?php
use Moca\Application\Controller;
class Page extends Controller {
public function index() {
return $this->view('index');
}
public function about() {
return $this->view('about');
}
public function contacts() {
return $this->view("contacts");
}
public function post_contacts() {
$form = $this->app['request']->get('contacts');
return $this->app->json(array('message' => 'Success'));
}
}
Next mount your controller, (*2)
<?php
$app->mount('/', new Page());
index
protected, private or parent method will be skipped/
post_routename or head_routename
render are used to display the Twig templates. By default tempalte file extension is .phtml, if you want to change you can set option $ app['twig.options']['extension'] = '.html
view is seeking template filename defined in the View folder Default Twig folder + current name of the Controller
before, after, beforeRender and afterRender
/contacts will accept only post, (*3)
<?php
use Moca\Application\Controller;
class Page extends Controller {
public function index() {
return $this->view('index');
}
public function about() {}
public function post_contacts() {}
}
Will load the template from the folder View/Page/index.phtml, (*4)
<?php
use Moca\Application\Controller;
class Page extends Controller {
public function index() {
return $this->view('index');
}
}
Will load the template from the folder View/Block/index.phtml, (*5)
<?php
use Moca\Application\Controller;
class User extends Controller {
public function index() {
return $this->render('Block/index');
}
}
Composer, (*6)
{
"require": {
"moca/moca": "dev-master"
}
}
Project structure, (*7)
vendor/
web/
app/
Controller/
Page.php
User.php
View/
Page/
Index.phtml
User/
Index.phtml
Layout/
Default.phtml
Database and Cache providers
MIT
database cache