Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mb-x/architect-bundle
[Deprecated] This Bundle provides an architecture to separate the different job layers in your Symfony application.
https://github.com/mb-x/architect-bundle
architecture symfony2-bundle symfony3-bundle
Last synced: 3 days ago
JSON representation
[Deprecated] This Bundle provides an architecture to separate the different job layers in your Symfony application.
- Host: GitHub
- URL: https://github.com/mb-x/architect-bundle
- Owner: mb-x
- Created: 2016-10-23T12:07:44.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2018-01-10T20:48:38.000Z (over 6 years ago)
- Last Synced: 2024-09-20T08:33:13.905Z (7 days ago)
- Topics: architecture, symfony2-bundle, symfony3-bundle
- Language: PHP
- Homepage:
- Size: 40 KB
- Stars: 7
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# ArchitectBundle
This Bundle provides an architecture to separate the different job layers in your Symfony application.
## 1. Installation
This bundle was tested with Symfony 2.8.14 and Symfony 3.0.9
### Step 1: Download ArchitectBundle using composer
Require the bundle with composer:
``` bash
$ composer require mb-x/architect-bundle
```### Step 2: Enable the bundle
Enable the bundle in the kernel:
``` php
id;
}
// ...
}
```### Step 2: Create the Manager and FormHandler classes
``` bash
$ php app/console mbx:generate AppBundle:Post
```this command will generate the Manager and FormHandler classes for Post Entity
### Step 3: Registering your Manager and FormHandler classes as a Service
```yaml
appbundle.post_manager:
class: AppBundle\Manager\PostManager
parent: mbx.abstract_entity_managerappbundle.post_form_handler:
class: AppBundle\FormHandler\PostFormHandler
parent: mbx.abstract_form_handler
arguments: ['@appbundle.post_manager']
```
### Step 4: The controllerYour controller will contain less code because all the logic and operations will be done in your Manager and FormHandler classes
``` php
/**
* Lists all post entities.
*
* @Route("/", name="post_index")
* @Method("GET")
*/
public function indexAction()
{
$posts = $this->get('appbundle.post_manager')->getRepository()->findAll();return $this->render('post/index.html.twig', array(
'posts' => $posts,
));
}/**
* Creates a new post entity.
*
* @Route("/new", name="post_new")
* @Method({"GET", "POST"})
*/
public function newAction(Request $request)
{
$post = new Post();
$formHandler = $this->get('appbundle.post_form_handler');if ($formHandler->processForm($post)) {
return $this->redirectToRoute('post_show', array('id' => $post->getId()));
}return $this->render('post/new.html.twig', array(
'post' => $post,
'form' => $formHandler->getForm()->createView(),
));
}/**
* Finds and displays a post entity.
*
* @Route("/{id}", name="post_show")
* @Method("GET")
*/
public function showAction(Post $post)
{
$formHandler = $this->get('appbundle.post_form_handler');
return $this->render('post/show.html.twig', array(
'post' => $post,
'delete_form' => $formHandler->createDeleteForm($post)->createView(),
));
}/**
* Displays a form to edit an existing post entity.
*
* @Route("/{id}/edit", name="post_edit")
* @Method({"GET", "POST"})
*/
public function editAction(Request $request, Post $post)
{
$formHandler = $this->get('appbundle.post_form_handler');
if ($formHandler->processForm($post)) {
return $this->redirectToRoute('post_edit', array('id' => $post->getId()));
}return $this->render('post/edit.html.twig', array(
'post' => $post,
'edit_form' => $formHandler->getForm()->createView(),
'delete_form' => $formHandler->createDeleteForm($post)->createView(),
));
}/**
* Deletes a post entity.
*
* @Route("/{id}", name="post_delete")
* @Method("DELETE")
*/
public function deleteAction(Request $request, Post $post)
{
$formHandler = $this->get('appbundle.post_form_handler');
if ($formHandler->processDeleteForm($post)) {
// $this->get('session')->getFlashBag()->add('Deleted Successfully');
}return $this->redirectToRoute('post_index');
}
```
## 3. Example[Demo Application](https://github.com/mb-x/ArchitectBundleDemo)
## 4. Suggestions
Much like every other piece of software `MbxArchitectBundle` is not perfect.
Any suggestion that can improve or add features to this bundle is appreciated.## 5. Reporting an issue or a feature request
Issues and feature requests are tracked in the [Github issue tracker](https://github.com/mb-x/architect-bundle/issues).
## 6. Friendly License
This bundle is available under the MIT license. See the complete license in the bundle:
Resources/meta/LICENSE
You are free to use, modify and distribute this software, as long as the copyright header is left intact (specifically the comment block which starts with /*)!