wiki:members/GRIP-UQAM/Symfony

Symfony

Related Page

Versions

3.3

app/autoload.php suppressed

https://github.com/symfony/symfony-standard/blob/v3.2.11/app/autoload.php

  • This file has been suppressed! Yeah!

Dependency Injection

Debugging

Bugs

Bugs as such cannot be reported. They have to be brought to light in a development version of Symfony with strong arguments and it is recommended to correct them on a fork and to make a pull request. So it may be better to go around at first development time and to correct only then really needed. 2017-01

Templating

There is a problem using twig array loader in Symfony framework, template including for statement produce an error. Tested in 2.8.16 and 3.2.2. symfony/templating

Form

(Warning: Form concentrates a huge quantity of issues in Symfony. It seems best to favor use of long term version (LTS) of Symfony then using this component.)

  • In version 3.2.2, the instructions in the official manual for separate component use result in no form beeing displayed, with Whoops an uninformative error can be obtained. It has not been tested if symfony/debug component can see something.
  • In 2.8 instructions are different and it works, the API seems to have change between versions.

symfony/form

Symfony Programming

Tutorials

Software using Symfony

EZ Plateform

Symfony Programming Tools

Hacking

autoload.php

MicroKernel

Components

Some popular Components

https://phppackages.org/s/symfony

Console

http://phppackages.org/p/symfony/console/badge/rank.svg https://www.versioneye.com/php/symfony:console/reference_badge.svghttps://img.shields.io/packagist/dm/symfony/console.svg

...

Yaml

http://phppackages.org/p/symfony/yaml/badge/rank.svg https://www.versioneye.com/php/symfony:yaml/reference_badge.svg https://img.shields.io/packagist/dm/symfony/yaml.svg

...

Process

http://phppackages.org/p/symfony/process/badge/rank.svg https://www.versioneye.com/php/symfony:process/reference_badge.svg https://img.shields.io/packagist/dm/symfony/process.svg

...

Config

http://phppackages.org/p/symfony/config/badge/rank.svg https://www.versioneye.com/php/symfony:config/reference_badge.svg https://img.shields.io/packagist/dm/symfony/config.svg

...

HttpFoundation

http://phppackages.org/p/symfony/http-foundation/badge/rank.svg https://www.versioneye.com/php/symfony:http-foundation/reference_badge.svg https://img.shields.io/packagist/dm/symfony/http-foundation.svg

...

Finder

http://phppackages.org/p/symfony/finder/badge/rank.svg https://www.versioneye.com/php/symfony:finder/reference_badge.svg https://img.shields.io/packagist/dm/symfony/finder.svg

...

DependencyInjection

http://phppackages.org/p/symfony/dependency-injection/badge/rank.svg https://www.versioneye.com/php/symfony:dependency-injection/reference_badge.svg https://img.shields.io/packagist/dm/symfony/dependency-injection.svg

...

HttpKernel

http://phppackages.org/p/symfony/http-kernel/badge/rank.svg https://www.versioneye.com/php/symfony:http-kernel/reference_badge.svg https://img.shields.io/packagist/dm/symfony/http-kernel.svg

...

EventDispatcher

http://phppackages.org/p/symfony/event-dispatcher/badge/rank.svg https://www.versioneye.com/php/symfony:event-dispatcher/reference_badge.svg https://img.shields.io/packagist/dm/symfony/event-dispatcher.svg

...

Form

http://phppackages.org/p/symfony/form/badge/rank.svg https://www.versioneye.com/php/symfony:form/reference_badge.svg https://img.shields.io/packagist/dm/symfony/form.svg

...

Validator

http://phppackages.org/p/symfony/validator/badge/rank.svg https://www.versioneye.com/php/symfony:validator/reference_badge.svg https://img.shields.io/packagist/dm/symfony/validator.svg

...

Filesystem

http://phppackages.org/p/symfony/filesystem/badge/rank.svg https://www.versioneye.com/php/symfony:filesystem/reference_badge.svg https://img.shields.io/packagist/dm/symfony/filesystem.svg

...

CssSelector

http://phppackages.org/p/symfony/css-selector/badge/rank.svg https://www.versioneye.com/php/symfony:css-selector/reference_badge.svg https://img.shields.io/packagist/dm/symfony/css-selector.svg

...

Templating

http://phppackages.org/p/symfony/templating/badge/rank.svg https://www.versioneye.com/php/symfony:templating/reference_badge.svg https://img.shields.io/packagist/dm/symfony/templating.svg

...

Debug

http://phppackages.org/p/symfony/debug/badge/rank.svg https://www.versioneye.com/php/symfony:debug/reference_badge.svg https://img.shields.io/packagist/dm/symfony/debug.svg

...

https://packagist.org/packages/symfony/

https://www.versioneye.com/php/symfony:yaml/reference_badge.svghttps://img.shields.io/packagist/dm/symfony/yaml.svg

...

Dependency Injection

Form

HttpFoundation

PSR-7

Routing

nikic/fast-route vs symfony/routing
RouteCollection vs RouteCollectionBuilder

Microkernel part buggy to be rewritten!

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'));

Written for 3.0

(Dynamic and Auto) Routing

(Bundles depends on components)

More about Routing

Security

Guard (New in 2.8!)

Use in Symfony framework

Stopwatch (also on PHP page)

Translation

Bundles

symfony/framework-standard-edition

Choosing bundles

Bundles not to choose

Admin: sonata-project/admin-bundle

Admin without Admin Bundle

Form related

Default value

(Other) Bundles documented by symfony.com

The list is there: http://symfony.com/doc/bundles/

Social Login

OAuth
HybridAuth
OpenID
Feed
Translation sonata-project/translation-bundle
Tree

Tree

Tag and Taxonomy

News, Newsletter

Spatial search

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

Symfony - Kotti

Using friendsofsymfony/user-bundle

Using a custom storage layer

UserInterface

UserInterface
interface UserInterface
string          getUsername()
(Role|string)[] getRoles()
string          getPassword() # This should be the encoded password.
                eraseCredentials()
string|null     getSalt()
AdvancedUserInterface
interface AdvancedUserInterface implements UserInterface
bool isAccountNonExpired()
bool isAccountNonLocked()
bool isCredentialsNonExpired()
bool isEnabled()
FOS\UserBundle UserInterface
  • FOS\UserBundle\Model\UserInterface
  • https://github.com/FriendsOfSymfony/FOSUserBundle/blob/master/Model/UserInterface.php
    interface UserInterface extends AdvancedUserInterface, \Serializable
    
    const ROLE_DEFAULT = 'ROLE_USER';
    const ROLE_SUPER_ADMIN = 'ROLE_SUPER_ADMIN';
    
    mixed             getId()
    
    # string          getUsername()
    self              setUsername(string $username)
    self              setUsernameCanonical(string $usernameCanonical)
    string            getUsernameCanonical()
    
    # (Role|string)[] getRoles()
    self              setRoles(array $roles)
    self              addRole(string $role)
    self              removeRole(string $role)
    bool              hasRole(string $role) # Never use this, instead: $authorizationChecker->isGranted('ROLE_USER')
    
    self              setSuperAdmin(bool $superAdmin)
    bool              isSuperAdmin()
    
    # string          getPassword()
    self              setPassword(string $password) # also hashed
    #                 eraseCredentials()
    self              setPlainPassword(string $password)
    string            getPlainPassword() # !! 2017-07
    # string|null     getSalt()
                      setSalt(string|null $salt)
    self              setPasswordRequestedAt(DateTime $date = null)
    int               isPasswordRequestNonExpired(int $ttl) # seconds
    self              setConfirmationToken(string $confirmationToken)
    string            getConfirmationToken()
    # bool            isCredentialsNonExpired()
    
    self              setEmail(string $email)
    string            getEmail()
    self              setEmailCanonical(string $emailCanonical)
    string            getEmailCanonical()
    
    # bool            isAccountNonExpired()
    # bool            isAccountNonLocked()
    # bool            isEnabled()
    self              setEnabled(bool $enabled)
    
    self              setLastLogin(DateTime $time = null)
    
User

UserManagerInterface

Model UserManager
Doctrine UserManager
Last modified 17 months ago Last modified on Jul 11, 2017, 7:02:18 AM