Introduction to Symfony

  1. What Is Symfony?



  2. Installing Symfony

  3. curl -sS https://get.symfony.com/cli/installer | bash
    

    symfony -V
    

    symfony new my_project --webapp

    my_project/
    ├── assets/
    ├── bin/
    ├── config/
    ├── migrations/
    ├── public/
    ├── src/
    ├── templates/
    ├── tests/
    └── var/
    


  4. Symfony Directory Structure (Overview)



  5. Your First Symfony Route

  6. <?php
    // src/Controller/HomeController.php
    
    namespace App\Controller;
    
    use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
    use Symfony\Component\HttpFoundation\Response;
    use Symfony\Component\Routing\Annotation\Route;
    
    class HomeController extends AbstractController
    {
        #[Route('/', name: 'home')]
        public function index(): Response
        {
            return new Response('Hello from Symfony!');
        }
    }
    

    symfony serve



  7. Templates with Twig

  8. <!-- templates/home.html.twig -->
    <h1>Hello {{ name }}!</h1>
    

    #[Route('/hello/{name}', name: 'hello')]
    public function hello(string $name): Response
    {
        return $this->render('home.html.twig', [
            'name' => $name,
        ]);
    }
    


  9. Symfony and MVC

  10. Request → Controller → Service/Model → Response → Browser
    


  11. Database Support with Doctrine ORM

  12. symfony console make:entity
    

    <?php
    // src/Entity/Product.php
    
    namespace App\Entity;
    
    use Doctrine\ORM\Mapping as ORM;
    
    #[ORM\Entity]
    class Product
    {
        #[ORM\Id]
        #[ORM\GeneratedValue]
        #[ORM\Column]
        private ?int $id = null;
    
        #[ORM\Column(length: 100)]
        private string $name;
    
        #[ORM\Column]
        private float $price;
    
        // getters and setters...
    }
    

    symfony console make:migration
    symfony console doctrine:migrations:migrate
    


  13. Dependency Injection Container

  14. <?php
    class SluggerService
    {
        public function slugify(string $s): string
        {
            return strtolower(str_replace(' ', '-', $s));
        }
    }
    
    #[Route('/slug/{text}')]
    public function slug(SluggerService $slugger, string $text): Response
    {
        return new Response($slugger->slugify($text));
    }
    


  15. Symfony Flex and Bundles

  16. composer require annotations
    composer require twig
    composer require symfony/orm-pack
    


  17. Debugging Tools

  18. symfony console debug:router
    symfony console debug:config
    symfony console debug:container
    



Installing & Setting Up the Symfony Framework

  1. Overview of Symfony Installation



  2. Installing the Symfony CLI



  3. Creating a New Symfony Project



  4. Understanding the Symfony Directory Structure


  5. Running Symfony's Local Web Server



  6. Configuring Environment Variables



  7. Installing Useful Symfony Bundles



  8. Testing Your Symfony Setup



  9. Using Symfony's Console Tool



  10. Configuring a Database Connection



  11. Configuring Web Server (Apache / Nginx)



  12. Verifying Production-Ready Configuration



What Is Composer?

  1. Overview of Composer



  2. Installing Composer



  3. How Composer Works



  4. The composer.json File



  5. Installing Dependencies



  6. The Autoloader



  7. Scripts in Composer



  8. Composer Version Constraints Explained



  9. Global vs Local Composer Installation



  10. Packagist — The PHP Package Repository



  11. Updating Composer Itself



  12. Common Problems and Solutions



Symfony Architecture

  1. Overview of Symfony’s Architecture



  2. High-Level Request Lifecycle



  3. Front Controller (public/index.php)



  4. Routing Component



  5. HttpKernel & Event Dispatcher



  6. The Controller Layer



  7. View Layer (Twig Templating)



  8. Model Layer (Doctrine ORM)



  9. Service Container (Dependency Injection)



  10. Bundles: Modular Symfony Extensions



  11. Configuration System



  12. Symfony Flex



Symfony Components

  1. Overview of Symfony Components



  2. The HttpFoundation Component



  3. The Routing Component



  4. The EventDispatcher Component



  5. The DependencyInjection Component



  6. The Console Component



  7. The Finder Component



  8. The Yaml Component



  9. The Serializer Component



  10. The Validator Component



  11. The Form Component



  12. Other Useful Symfony Components

  13. Symfony Component Description
    Translation Internationalization (i18n) and localization support.
    Cache Cache adapters for Redis, Memcached, and filesystem caching.
    Process Execute and manage shell commands from PHP.
    Security Authentication and access control system.
    Messenger Message bus for CQRS, queues, and async processing.
    HttpClient Fast, modern HTTP client alternative to Guzzle.
    Mime Email handling and MIME type utilities.
    DomCrawler HTML and DOM parsing API.
    CssSelector CSS selector engine for querying DOM elements.
    Filesystem Convenient file and directory management tools.


  14. How Symfony Uses Components Internally



  15. Using Components Without the Framework



Symfony Service Container

  1. Introduction to the Service Container



  2. What Is a Service?



  3. How Dependency Injection Works



  4. Service Registration



  5. Autowiring



  6. Autoconfiguration



  7. Service Visibility (Public vs Private)



  8. Accessing the Container



  9. Service Tags



  10. Service Aliases



  11. Container Compilation



  12. Debugging Services



Symfony Events & Event Listeners

  1. Introduction to Symfony’s Event System



  2. What Is the EventDispatcher?



  3. Symfony’s Built-In Kernel Events



  4. Creating a Custom Event



  5. Dispatching an Event



  6. Creating an Event Listener



  7. Creating an Event Subscriber



  8. Event Priorities



  9. Modifying Responses with Events



  10. Handling Exceptions with Events



Symfony Expression Language

  1. What Is the Symfony Expression Language?



  2. Basic Syntax of Expressions



  3. Using Expression Language in PHP Code



  4. Expressions in Security (Most Common Use Case)



  5. Expressions in Service Container



  6. Expressions in Workflow Component



  7. Expressions in Routing



  8. Creating Custom Functions for Expression Language



  9. Expression Caching



Symfony Bundles

  1. What Is a Symfony Bundle?



  2. Bundle Structure



  3. Core Symfony Bundles



  4. Installing Third-Party Bundles



  5. Creating Your Own Bundle



  6. Bundle Configuration with Extension Classes



  7. Configuring a Bundle Externally



  8. Bundle Best Practices (Modern Symfony)



  9. Examples of Popular Third-Party Bundles

  10. Bundle Description
    FOSUserBundle User management (registration, login, profiles).
    ApiPlatformBundle Automatic REST and GraphQL API generation.
    EasyAdminBundle Admin dashboard and CRUD backend generation.
    LiipImagineBundle Advanced image manipulation and caching.
    HWIOAuthBundle OAuth client integration (Google, Facebook, GitHub…).
    KnpPaginatorBundle Pagination utilities for Doctrine queries and arrays.
    SymfonyCasts VerifyEmailBundle Email verification workflow for user registration.


  11. How Bundles Integrate into the Kernel



  12. Bundle Overrides (Resource Inheritance)



Symfony Controllers

  1. What Is a Symfony Controller?



  2. Controller Classes



  3. Routing to Controllers



  4. Returning Responses



  5. Request Object Injection



  6. Autowiring Services into Controllers



  7. Handling Route Parameters



  8. Param Converters (Doctrine Integration)



  9. Using Flash Messages



  10. Returning JSON Responses



  11. Controller Traits and Base Features



  12. API Controllers (Stateless)



Symfony Routing

  1. What Is Routing in Symfony?



  2. Defining Routes Using PHP Attributes (Recommended)



  3. Defining Routes in YAML



  4. Defining Routes in XML



  5. Dynamic Route Parameters



  6. Parameter Requirements (Regex Constraints)



  7. HTTP Method Constraints



  8. Host-Based Routing



  9. Route Conditions (Expression Language)



  10. Route Priority (Order of Matching)



  11. Generating URLs in Controllers and Twig



  12. Loading Routes from Controllers Automatically



  13. Debugging Routes



Symfony View Engine (Twig Templating)

  1. What Is the Symfony View Engine?



  2. Serving a Twig Template from a Controller



  3. Twig Template Syntax Basics



  4. Template Inheritance (Layouts)



  5. Including Templates



  6. Variables in Twig



  7. Loops and Conditionals



  8. Filters



  9. Functions



  10. Twig and Symfony Forms



  11. Custom Twig Extensions



  12. Using Assets (CSS, JS, Images)



  13. Error Pages via Twig



  14. Debugging Twig Templates



Symfony Doctrine ORM

  1. What Is Doctrine ORM?



  2. Installing Doctrine ORM



  3. Creating Your First Entity



  4. Running Migrations



  5. Reading & Writing Data (EntityManager)



  6. Doctrine Repositories



  7. Custom Repository Methods



  8. Doctrine Relationships



  9. Lazy Loading vs Eager Loading



  10. Lifecycle Callbacks



  11. Using the QueryBuilder



  12. Doctrine Migrations



  13. Flushing Strategy



  14. Entity Validation (with Symfony Validator)



  15. Advanced Topics



Symfony Forms

  1. What Are Symfony Forms?



  2. Installing the Form Component



  3. Creating a Form Type



  4. Rendering the Form in a Controller



  5. Rendering the Form in Twig



  6. Handling Form Submission



  7. Mapping Forms to Entities



  8. Form Field Options



  9. Built-in Form Field Types



  10. ChoiceType (Dropdowns, Radios, Checkboxes)



  11. Validation Integration



  12. File Uploads with FileType



  13. CSRF Protection



  14. Rendering Individual Controls



  15. Handling Forms in API Applications



  16. CollectionType (Dynamic Forms)



Understanding CSRF (Cross-Site Request Forgery)

  1. What Is CSRF?



  2. How CSRF Works (Attack Scenario)



  3. Why Are Cookies Automatically Sent?



  4. CSRF vs XSS



  5. How CSRF Tokens Prevent Attacks



  6. CSRF Tokens in Symfony



  7. What CSRF Does Not Protect Against



  8. Other Defenses Against CSRF



  9. Why CSRF Is Still Important



Symfony Validation

  1. What Is Symfony Validation?



  2. Installing the Validator Component



  3. Adding Validation Using PHP Attributes



  4. Validating Objects Manually



  5. Validation with Symfony Forms



  6. Common Validation Constraints



  7. Custom Error Messages



  8. Validating Nested Objects



  9. Using Groups for Conditional Validation



  10. Validation Using YAML or XML



  11. Custom Validation Constraints



  12. Using the Validation Profiler



Symfony File Uploading

  1. Overview of File Uploading in Symfony



  2. Creating a Form for File Uploading



  3. Rendering the Upload Form in Twig



  4. Processing the Uploaded File in the Controller



  5. Configuring Upload Directory



  6. Displaying Uploaded Files



  7. File Validation Rules



  8. Handling Multiple File Uploads



  9. Deleting Uploaded Files



  10. Upload Error Handling



Symfony AJAX Control

  1. What Is AJAX in Symfony?



  2. Creating a Route for AJAX



  3. Sending AJAX Requests Using fetch()



  4. CSRF Protection for AJAX



  5. Returning JSON Responses



  6. Returning Partial HTML for Dynamic Updates



  7. Sending Form Data via AJAX



  8. Handling File Uploads via AJAX



  9. Detecting AJAX Requests in Symfony



  10. Returning Error Responses



  11. Using Stimulus & Symfony UX for AJAX Enhancements



Symfony Cookies and Session Management

  1. Overview of Cookies and Session Management in Symfony



  2. Understanding Cookies



  3. Creating a Cookie in Symfony



  4. Reading Cookies



  5. Deleting Cookies



  6. Understanding Session Management



  7. Writing Data to Session



  8. Reading Session Data



  9. Removing Session Data



  10. Using Flash Messages (Session-Based)



  11. Session Storage Backends



  12. Preventing Session Fixation



  13. Cookies Security Best Practices


  14. Session Best Practices



Symfony Internationalization (i18n)

  1. What Is Internationalization (i18n)?



  2. Installing and Enabling the Translation Component



  3. Translation File Structure



  4. Using Translations in Twig



  5. Using Translations in Controllers and Services



  6. Pluralization



  7. Translation Domains



  8. Setting and Detecting Locale



  9. Locale Switcher (Language Selector)



  10. Translating Form Labels



  11. Translating Validation Messages



  12. Translating Flash Messages



Symfony Logging

  1. What Is Logging in Symfony?



  2. Installing Monolog (Usually Installed by Default)



  3. Understanding Log Levels



  4. Logging in a Controller or Service



  5. Customizing Log Messages



  6. Where Logs Are Stored



  7. Configuring Monolog Handlers



  8. Daily Log Rotation



  9. Using the Fingers Crossed Handler



  10. Logging from Twig Templates



  11. Channel-Based Logging



  12. Logging Exceptions



  13. Viewing Logs in the Symfony Profiler



Symfony Email Management

  1. What Is Email Management in Symfony?



  2. Installing the Symfony Mailer Component



  3. Configuring Email Transport



  4. Sending a Basic Email



  5. Sending Templated Emails (Twig)



  6. Attaching Files



  7. Using Inline Images



  8. Multiple Recipients



  9. Transport Failover and Load Balancing



  10. Sending Emails Asynchronously (Messenger Integration)



  11. Testing Emails in Development



  12. Logging and Debugging Email Sending



Symfony Unit Testing

  1. What Is Unit Testing in Symfony?



  2. Installing PHPUnit



  3. Test Directory Structure



  4. Writing Your First Unit Test



  5. Testing Symfony Services



  6. Using Mocks



  7. Testing Exception Handling



  8. Data Providers



  9. Testing Private / Protected Methods



  10. Testing Entities and Value Objects



  11. Functional Testing vs Unit Testing



  12. Running Unit Tests with Coverage



  13. Organizing Tests



Symfony Advanced Concepts

  1. Overview of Advanced Symfony Concepts



  2. Service Decoration



  3. Compiler Passes



  4. Custom Configuration & Bundle Extensions



  5. Advanced Event Subscribers



  6. Security Voters



  7. Serializer Component (Advanced Usage)



  8. Messenger Component (Advanced Message Bus)



  9. HTTP Caching & Reverse Proxy



  10. Custom Annotations / Attributes



  11. Environment Variable Processing