Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SF5 #312

Closed
eerison opened this issue Nov 28, 2020 · 0 comments · Fixed by #314, #327, #328, #333 or #335
Closed

SF5 #312

eerison opened this issue Nov 28, 2020 · 0 comments · Fixed by #314, #327, #328, #333 or #335
Assignees

Comments

@eerison
Copy link
Collaborator

eerison commented Nov 28, 2020

  • PHP
  • HTTP
    • Client / Server interaction
    • Status codes
    • HTTP request
    • HTTP response
    • HTTP methods
    • Cookies
    • Caching
    • Content negotiation
    • Language detection
    • Symfony HttpClient component
  • Symfony Architecture
    • Symfony Flex
    • License
    • Components
    • Bridges
    • Code organization
    • Request handling
    • Exception handling
    • Event dispatcher and kernel events
    • Official best practices - Added prefix for component files #327 Improve smoke tests #328
    • Release management
       Starting from the Symfony 3.x branch, the number of minor versions is limited to five per branch 
       (X.0, X.1, X.2, X.3 and X.4).
      The last minor version of a branch (e.g. 4.4, 5.4) is considered a long-term support version 
      and the other ones are considered standard versions:
      
    • Backward compatibility promise
    • Deprecations best practices
    trigger_deprecation
    @ deprecated
    
    • Framework overloading
    • Release management and roadmap schedule
    • Framework interoperability and PSRs
    • Naming conventions
  • Controllers
    use Symfony\Bundle\FrameworkBundle\Controller\AbstractController
    
    • Naming conventions
    • The base AbstractController class
    • The request
    • The response
    use Symfony\Component\HttpFoundation\Request;
    use Symfony\Component\HttpFoundation\Response;
    
    • The cookies
    $request->cookies
    • The session
    use Symfony\Component\HttpFoundation\Session\SessionInterface;
    
    • The flash messages
    • HTTP redirects
    • Internal redirects
    • Generate 404 pages
    • File upload
    $request->files
    • Built-in internal controllers
  • Routing Changed security router using priority #333
    use Symfony\Component\Routing\Annotation\Route
     /**
       * @Route("/blog", name="blog_list")
       */
    • Configuration (YAML, XML, PHP & annotations)
    • Restrict URL parameters
    • Set default values to URL parameters
    • Generate URL parameters
    • Trigger redirects
    • Special internal routing attributes
    • Domain name matching
    • Conditional request matching
    • HTTP methods matching
    • User's locale guessing
    • Router debugging
  • Templating with Twig
    • Auto escaping
    • Template inheritance
    • Global variables
    • Filters and functions
    • Template includes
    • Loops and conditions
    • URLs generation
    • Controller rendering
    • Translations and pluralization
    • String interpolation
    • Assets management
    • Debugging variables
  • Forms
    • Forms creation
    • Forms handling
    • Form types
    • Forms rendering with Twig
    • Forms theming
    • CSRF protection Added CSRF token in register form #335
    • Handling file upload
    • Built-in form types
    • Data transformers
    $builder->get('tags')
              ->addModelTransformer(new CallbackTransformer(
                  function ($tagsAsArray) {
                      // transform the array to a string
                      return implode(', ', $tagsAsArray);
                  },
                  function ($tagsAsString) {
                      // transform the string back to an array
                      return explode(', ', $tagsAsString);
                  }
              ))
    • Form events
    use Symfony\Component\Form\FormEvent;
    use Symfony\Component\Form\FormEvents;
    
    $listener = function (FormEvent $event) {
      // ...
    };
    
    $form = $formFactory->createBuilder()
      // ... add form fields
      ->addEventListener(FormEvents::PRE_SUBMIT, $listener);
    During FormEvents::PRE_SET_DATA, Form::setData() is locked and will throw an exception if used.
    If you wish to modify data, you should use FormEvent::setData() instead.
    

Screenshot 2020-12-25 at 21 07 23

  • Form type extensions
use Symfony\Component\Form\AbstractTypeExtension;
  • Data Validation

    use Symfony\Component\Validator\Constraints as Assert;
    use Symfony\Component\Validator\Validator\ValidatorInterface;
    
    /*
           * Uses a __toString method on the $errors variable which is a
           * ConstraintViolationList object. This gives us a nice string
           * for debugging.
           */
          $errorsString = (string) $errors;
          
          /**
       * @Assert\Choice(
       *     choices = { "fiction", "non-fiction" },
       *     message = "Choose a valid genre."
       * )
       */
      private $genre;
    
    
     /**
       * @Assert\NotBlank(message="author.name.not_blank")
       */
      public $name;
      
      ...
      # translations/validators.en.yaml
      author.name.not_blank: Please enter an author name.
    
    • PHP object validation
    • Built-in validation constraints
    • Validation scopes
      use Symfony\Component\Validator\Constraint;
      use Symfony\Component\Validator\ConstraintValidator;
      
    • Validation groups
    $errors = $validator->validate($author, null, ['registration']);
    /**
       * @Assert\NotBlank(groups={"registration"})
       * @Assert\Length(min=7, groups={"registration"})
       */
      private $password;
    
    • Group sequence
    /**
    * @Assert\GroupSequence({"User", "Strict"})
    */
    class 
    
    • Custom callback validators
     use Symfony\Component\Validator\Context\ExecutionContextInterface;
    
      /**
       * @Assert\Callback
       */
      public function validate(ExecutionContextInterface $context, $payload)
      {
          // ...
      }
      
      //or to static validate
      use Symfony\Component\Validator\Constraints as Assert;
    
     /**
      * @Assert\Callback({"Acme\Validator", "validate"})
      */
      class Author
      {
      }
    
    • Violations builder
  • Dependency Injection
    services.yaml

    _defaults:
        autowire: true
        autoconfigure: true
    • Service container
    • Built-in services
    • Configuration parameters
      php bin/console debug:container --env-vars
      php bin/console debug:container --env-var=FOO
      php bin/console debug:container --parameters
      
    • Services registration
    • Tags
    App\Handler\Two:
          tags: ['app.handler']
    
      App\HandlerCollection:
          # inject all services tagged with app.handler as first argument
          arguments:
              - !tagged_iterator app.handler
              
      public function __construct(iterable $handlers)
    

    priotiry

    App\Handler\One:
          tags:
              - { name: 'app.handler', priority: 20 }
              
     # or -----
         public static function getDefaultPriority(): int
      {
          return 3;
      }
      
      App\HandlerCollection:
          # inject all services tagged with app.handler as first argument
          arguments:
              - !tagged_iterator { tag: app.handler, default_priority_method: getPriority }
    

    key

    services:
      App\Handler\One:
          tags:
              - { name: 'app.handler', key: 'handler_one' }
    
      App\Handler\Two:
          tags:
              - { name: 'app.handler', key: 'handler_two' }
    
      App\HandlerCollection:
          arguments: [!tagged_iterator { tag: 'app.handler', index_by: 'key' }]
          
     namespace App\Handler;
    
    class HandlerCollection
    {
      public function __construct(iterable $handlers)
      {
          $handlers = iterator_to_array($handlers);
    
          $handlerTwo = $handlers['handler_two'];
      }
    }
    
    # or ----
    namespace App\Handler;
    
    class One
    {
      // ...
      public static function getDefaultIndexName(): string
      {
          return 'handler_one';
      }
    }
    
    
    
     App\HandlerCollection: 
     # use getIndex() instead of getDefaultIndexName() 
     arguments: [!tagged_iterator { tag: 'app.handler', default_index_method: 'getIndex' }]
    
    • Semantic configuration
    • Factories
    • Compiler passes
    • Services autowiring
  • Security

    • Authentication
    • Authorization
    • Configuration
    • Providers
      security.yaml
    security:
      providers:
          # the name of your user provider can be anything
          your_custom_user_provider:
              id: App\Security\UserProvider
    
    • Firewalls
      security:
      firewalls:
          secured_area:
              pattern: ^/admin
      
    • Users
    • Passwords encoders
    security:
      # ...
      encoders:
          App\Entity\User:
              algorithm: auto
              cost: 12
    
    namespace App\Entity;
    
    use Symfony\Component\Security\Core\Encoder\EncoderAwareInterface;
    use Symfony\Component\Security\Core\User\UserInterface;
    
    class User implements UserInterface, EncoderAwareInterface
    {
      public function getEncoderName()
      {
          if ($this->isAdmin()) {
              return 'harsh';
          }
    
          return null; // use the default encoder
      }
    }
    security:
      # ...
      encoders:
          app_encoder:
              id: 'App\Security\Encoder\MyCustomPasswordEncoder'
    
    • Roles
    • Access Control Rules
    • Guard authenticators
    • Voters and voting strategies Create voters #339
    use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted;
    @IsGranted("ROLE_USER", attributes="owner", subject="certification")
    

    example

  • HTTP Caching

    use Symfony\Bundle\FrameworkBundle\HttpCache\HttpCache;
    
    class CacheKernel extends HttpCache

    PSR-6

    • Cache types (browser, proxies and reverse-proxies)
    • Expiration (Expires, Cache-Control)
    • Validation (ETag, Last-Modified)
    • Client side caching
    • Server side caching
    • Edge Side Includes
  • Console

    use Symfony\Component\Console\Command\Command
    use Symfony\Component\Console\Input\InputInterface;
    use Symfony\Component\Console\Output\OutputInterface;
    • Built-in commands
    • Custom commands
    • Configuration
    • Options and arguments
    use Symfony\Component\Console\Input\InputArgument;
    use Symfony\Component\Console\Command\Command;
    use Symfony\Component\Console\Input\InputInterface;
    use Symfony\Component\Console\Output\OutputInterface;
    
    
    protected function configure()
      {
          $this
              ->setDescription('Creates a new user.')
              ->setHelp('This command allows you to create a user...')
              ->addArgument('password', $this->requirePassword ? InputArgument::REQUIRED : InputArgument::OPTIONAL, 'User password')
          ;
      }
      use Symfony\Component\Console\Input\InputOption;
    
      $this
          ->addOption(
              'iterations',
              null,
              InputOption::VALUE_REQUIRED,
              'How many times should the message be printed?',
              1
          )
      ;
    • Input and Output objects
    • Built-in helpers
      Formatter Helper
      Process Helper
      Progress Bar
      Question Helper
      Table
       Debug Formatter Helper
      
    • Console events
    • Verbosity levels
    # increase verbosity of message
    php bin/console some-command -v
    
    # also informative messae
    php bin/console some-command -vv
    
    # all messages
    php bin/console some-command -vvv

Screenshot 2020-12-23 at 12 57 26

@eerison eerison self-assigned this Nov 28, 2020
@eerison eerison changed the title SF SF5 Nov 28, 2020
@eerison eerison linked a pull request Nov 30, 2020 that will close this issue
@eerison eerison reopened this Dec 1, 2020
@eerison eerison closed this as completed Dec 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment