wiki:members/GRIP-UQAM/Symfony

Version 4 (modified by Grip Uqam, 8 years ago) ( diff )

--

Symfony Programming

Tutorials

Software using Symfony

EZ Plateform

Symfony Programming Tools

Hacking

autoload.php

MicroKernel

Components

Form

Translation
  • see Bundle-Form-Translation
  • see Bundle-Admin-Translation

Guard (New in 2.8!)

Use in Symfony framework

Routing

RouteCollection vs RouteCollectionBuilder

RouteCollection

RouteCollectionBuilder

add(string $name, Route $route)

$this addRoute(Route $route, string|null $name = null)

Route add(string $path, string $controller, string|null $name = null

new RouteCollection()->add('root', new Route('/', [
    '_controller' => 'FrameworkBundle:Redirect:redirect',
    'route'       => 'sonata_admin_dashboard',
    'permanent'   => true,
])); // to check
new RouteCollectionBuilder()->addRoute(new Route('/', [
    '_controller' => 'FrameworkBundle:Redirect:redirect',
    'route'       => 'sonata_admin_dashboard',
    'permanent'   => true,
]),
    'root'
); // to check

Does not exist: cf $loader->import(...)

RouteCollectionBuilder import(mixed $resource, string|null $prefix = '/', string $type = null)

Does not exist: cf addCollection

mount($prefix, RouteCollectionBuilder $builder)

$collection = new RouteCollection();
$routing = $loader->import(
    "@SonataAdminBundle/Resources/config/sonata_admin.xml"
);
$routing->setPrefix('/admin');
$collection->addCollection($routing);
$routes->mount('/admin', $routes->import('@SonataAdminBundle/Resources/config/routing/sonata_admin.xml'));

Bundles

symfony/framework-standard-edition

  • WebProfilerBundle (in dev/test env) - Adds profiling functionality and the web debug toolbar
  • SensioDistributionBundle (in dev/test env) - Adds functionality for configuring and working with Symfony distributions
  • sensio/generator-bundle SensioGeneratorBundle fr (in dev/test env) - Adds code generation capabilities
    • Choosing the annotation format expects the SensioFrameworkExtraBundle to be installed
    • There should be one line of imports in the config.yml file! (otherwise changes may not be added to it!)
    • Generating a New Bundle Skeleton
      • in composer.json (for autoload):
            "autoload": {
                "psr-4": {
                    "": "src/"
                }
            }
        
        $ php bin/console generate:bundle --namespace=AppBundle --bundle-name=AppBundle --format=annotation --dir=../src --no-interaction
        
          Bundle generation
        
        > Generating a sample bundle skeleton into app/../src/AppBundle OK!
        > Checking that the bundle is autoloaded: OK
        > Enabling the bundle inside /...app/AppKernel.php: OK
        > Importing the bundle\'s routes from the app/config/routing.yml file: OK
        > Importing the bundle\'s services.yml from the app/config/config.yml file: OK
        
          Everything is OK! Now get to work :).  
        
      • files touched:
        • app/../src/AppBundle (directory and content generated)
        • app/AppKernel.php
        • app/config/routing.yml
        • app/config/config.yml (see note about line of import)
  • DebugBundle (in dev/test env) - Adds Debug and VarDumper component integration

Bundles documented by symfony.com

User

  • friendsofsymfony/user-bundle

Social Login

OAuth
HybridAuth
OpenID

Form related

Admin sonata-project/admin-bundle

Admin without Admin Bundle
Default value
Translation sonata-project/translation-bundle
Tree
Formatter
CKEditor

CKEditor

Tree

Tag and Taxonomy

News, Newsletter

Blog

Payment

Help Desk, Bug Tracking and Ticket

CLI code generation example

$ php bin/console generate:bundle --namespace=AppBundle --bundle-name=AppBundle --format=annotation --dir=../src --no-interaction
$ php bin/console assets:install ../web --symlink --relative
$ php bin/console doctrine:generate:entity --entity="AppBundle:Category" --fields="name:string(255)" --no-interaction
$ php bin/console doctrine:generate:entity --entity="AppBundle:BlogPost" --fields="title:string(255) body:text draft:boolean" --no-interaction
$ php bin/console doctrine:schema:create
$ php bin/console doctrine:schema:update # after modification

See

  • sensio/generator-bundle
  • doctrine/orm
Note: See TracWiki for help on using the wiki.