Slivework is a new metaframework which aims to share functinality through different PHP frameworks. It takes business logic from controller to service classes. The service layer leaves all http processing to current framework and moves all business into it. Controllers are forbidden to access database directly, all db operations is passed to service. Sliceworks uses Doctrine ORM + ODM.
- Each slice is a Symfony2 bundle
src/Slicework/UserBundle/ src/Slicework/UserMessagingBundle/ src/Slicework/UserInvitesBundle/ ....
- Dependency
- Slice
-- UserService
- Repository
- Entitiy
-- model
-- model
-- model
- Each independent slice is installed in this bundle by symfony command.
./app/sf slice:install UserMessaging
-
Schema should be updated
-
Each Slice can be extended in any other bundle MyBundle/Slice/UserService < Slicework/Slice/UserService
-
In controller you can use a service.
<?php
class PageController {
protected $service
function createAction($name, $body) {
$this->service = $this->container->get('slice.page_service');
$page_id = $this->service
->doBefore(function($page) { $page->setCreatedBy('user'); })
->doAfterUpdateAuthorProfile($user)
->create($name, $body);
return $this->render('AcmeHelloBundle:Hello:index.html.twig', array('page' => $this->service->fetch($page_id)));
}
}
?>