Sylex is a tiny layer on top of Silex framework.
There is a controller base class with some handy shortcut methods. It will also inject the container into your controllers.
<?php
class ArticleController extends Sylex\Controller
{
public function listAction()
{
return $this->render(
'article/list.html.twig',
array('articles' => $this->get('manager.article')->findAll())
);
}
public function createAction(Request $request)
{
$form = $this->get('form.article');
if ('POST' == $request->getMethod()) {
$form->bindRequest($request);
if ($form->isValid()) {
$this->get('manager.article')->persistArticle($form->getData());
return $this->redirect($this->generateUrl('article_list'));
}
}
return $this->render(
'article/create.html.twig',
array('form' => $form->createView())
);
}
}
The recommended way to Sylex is through composer.
{
"require": {
"umpirsky/sylex": "*"
}
}
There are two ways to start using Sylex. You can use Sylex\Application
class
or register the service provider: $app->register(new Sylex\ServiceProvider());
.
Check Silex on Steroids demo application to see it in action.
To run the test suite, you need PHPUnit.
$ phpunit
Sylex is licensed under the MIT license.