imatic/controller-bundle

Bundle to write simple controllers

Installs: 3 101

Dependents: 1

Suggesters: 0

Security: 0

Stars: 1

Watchers: 7

Forks: 0

Open Issues: 0

Type:symfony-bundle

v5.0.7 2023-07-31 10:21 UTC

README

Build Status License: MIT

ImaticControllerBundle

This bundle makes it easy to write simple controllers for all kinds of actions. It heavilly uses ImaticDataBundle. So you you should read it's documentation first if you didn't yet.

The bundle allows you to write simple actions in 2 forms

  • using fluent interface
<?php

use Imatic\Bundle\ControllerBundle\Controller\Api\ApiTrait;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\Routing\Annotation\Route;

/**
 * @Route("/user")
 */
class UserController extends Controller
{
    use ApiTrait;

    /**
     * @Route("", name="app_user_list", methods={"GET"})
     */
    public function listAction()
    {
        return $this
            ->listing(new UserListQuery())
            ->setTemplateName('AppImaticControllerBundle:Test:list.html.twig')
            ->getResponse();
    }
}
  • using yaml
imatic_controller:
    resources:
        app_user_list:
            config:
                route: { path: /user }
                entity: User
                query:
                    list: UserListQuery
                fields:
                    - { name: name, format: text }
                    - { age: age, format: number }
            actions:
                list: ~

Further reading

  • Visit our documentation to learn about all features of this bundle.