2017 © Pedro Peláez
 

symfony-bundle twigony-framework-bundle

Twigony FrameworkBundle

image

timonf/twigony-framework-bundle

Twigony FrameworkBundle

  • Friday, November 10, 2017
  • by timonf
  • Repository
  • 0 Watchers
  • 4 Stars
  • 14 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 3 Open issues
  • 4 Versions
  • 0 % Grown

The README.md

{{ Twigony FrameworkBundle }}

SensioLabsInsight, (*1)

Twigony is inspired by Symfony's TemplateController. Twigony provides default controller actions for common use cases. You are able to configure Twigony through your routing.yml file (like Symfony's TemplateController)., (*2)

Goals of Twigony:, (*3)

  • Easy to use (no own controllers are needed, an Entity and a template is all you need)
  • Usable for fast prototyping
  • Usable for simple pages
  • Much more frontend code (Twig) and less backend code (PHP/Symfony)
  • Covers common use cases (database listing, email…)

Information: This project is in development. If you want to support me or this project contact me on Slack (My name: @timon). If you don't have access to Slack, have a look here., (*4)


Installation

Create an empty project and use composer to install this bundle:, (*5)

$ symfony new your-new-project
$ composer require timonf/twigony-framework-bundle

Then, enable the bundle by adding it to the list of registered bundles in the app/AppKernel.php file of your project:, (*6)

<?php
// app/AppKernel.php

// ...
class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = array(
            // ...
            new \Twigony\Bundle\FrameworkBundle\TwigonyFrameworkBundle(),
        );
    }
}

Documentation

Example usages

Multiple static pages (TemplateController)

  1. Create two or more Twig templates (like app/views/info/hello.html.twig and app/views/info/about.html.twig)
  2. Extend your routing.yml:, (*7)

    info_pages:
        path: '/info/{page}'
        defaults:
            _controller: 'twigony.template_controller:templateAction'
            template:    'info/{page}.html.twig'

List entities (DoctrineORMController)

  1. Create an entity or use an existing one (e .g. src/AppBundle/Entity/Post.php)
  2. Create a template (like app/views/posts/all.html.twig)
  3. Extend your routing.yml:, (*8)

    posts:
        path: '/posts'
        defaults:
            _controller: 'twigony.orm_controller:listAction'
            template: 'posts/all.html.twig'
            entity: 'AppBundle\Entity\Post'
            options:
                as: 'posts' # Access variable for your Twig template. You can use it this way `{% for post in posts %}…`
                perPage: 50

Show single entity (DoctrineORMController)

  1. Create an entity or use an existing one (e .g. src/AppBundle/Entity/Post.php)
  2. Create a template (like app/views/posts/show.html.twig)
  3. Extend your routing.yml:, (*9)

    show_post:
        path: '/posts/{id}' # Make sure, you are using "id" as id parameter!
        defaults:
            _controller: 'twigony.orm_controller:viewAction'
            template: 'posts/show.html.twig'
            entity:   'AppBundle\Entity\Post'
            options:
                as: 'post' # Access variable for your Twig template. You can use it this way `{{ post.title }}…`

The Versions