Contents
Symfony
A framework for large projects: attribute routes, Twig templates, Doctrine, forms and security.
1.Getting started
- Meet SymfonyWhat Symfony is, how to create a project, how its folders are organised and how to write the first page.
- RoutingRoutes in Symfony: the Route attribute, parameters in the address, requirements, route names and generating links.
- ControllersSymfony controllers: AbstractController, the request object, templates, redirects, JSON responses and the 404 error.
- Twig templatesThe Twig template engine in Symfony: printing variables, conditions and loops, filters, template inheritance and includes.
- Sessions and cookiesSessions and cookies in Symfony: keeping data between requests, a cart in the session, setting and reading cookies.
- Twig: macros, custom filters, globalsAdvanced Twig in Symfony: variables and tests, macros, your own filters and functions, global values and embedding controllers.
2.Database
- Entities and migrationsDoctrine in Symfony: connecting a database, creating an entity, column attributes and migrations.
- Create, read, update, deleteWorking with data in Doctrine: the EntityManager, the persist and flush methods, finding records, automatic entity loading from the address.
- Repositories and queriesCustom queries in Doctrine: repository methods, the QueryBuilder, parameters, ordering, counting and the DQL language.
- Relationships between entitiesDoctrine relationships: ManyToOne and OneToMany, ManyToMany, the owning side, loading related data and the N+1 problem.
- Test dataFixtures in Symfony: DoctrineFixturesBundle, filling the database with sample records, the Faker library and references between fixtures.
- PaginationPagination in Symfony: the Doctrine Paginator, the page number from the address, links in a template and KnpPaginatorBundle.
- Transactions and Doctrine performanceDeeper Doctrine: transactions and locks, processing large tables, indexes, fetching arrays and raw SQL queries.
3.Application
- FormsForms in Symfony: the form class, field types, handling submission in a controller, rendering in Twig and CSRF protection.
- ValidationValidation in Symfony: Assert constraints on an entity, custom messages, uniqueness, validating by hand and your own rules.
- Login and access controlSecurity in Symfony: the user entity, a login form, roles, protected sections, the IsGranted attribute and password hashing.
- Services and dependency injectionServices in Symfony: autowiring, your own service, parameters and environment variables, interfaces and configuration.
- Rights to a particular recordVoters in Symfony: the rule "an author may edit their own post", checking in a controller, an attribute and a template.
- EventsEvents in Symfony: listeners and subscribers, kernel events, your own events and Doctrine lifecycle callbacks.
- File uploadsUploading files in Symfony: the FileType field, checking size and type, saving under a safe name and displaying the image.
- Remember me, password reset, email verificationAdditions to login in Symfony: the remember-me feature, login throttling, email verification, password reset and impersonating a user.
- API tokensProtecting an API in Symfony: a separate stateless firewall, checking a token with access_token, issuing and storing tokens, the CurrentUser attribute.
4.Growing the project
- Console commandsYour own bin/console commands in Symfony: the AsCommand attribute, arguments and options, styled output and using services.
- APIs and JSONAn API in Symfony: JSON responses, serialization groups, receiving data with MapRequestPayload, status codes and API Platform.
- TestingTests in Symfony: PHPUnit, unit tests for services, WebTestCase for pages, submitting forms and logging a user in within a test.
- DeploymentPublishing a Symfony project: prod mode, installing dependencies, migrations, clearing the cache, secrets and web server setup.
- Environments, parameters and secretsConfiguring Symfony: the dev, test and prod environments, the order of .env files, application parameters, env var processors and the secrets vault.
- The EasyAdmin dashboardAn admin panel for Symfony in an hour: the EasyAdmin package, CRUD controllers, configuring fields, the menu, filters and access protection.
- API PlatformA ready-made API on Symfony: the ApiResource attribute, the set of operations, serialization groups, filters, pagination and access rules.
5.Components
- Sending emailSymfony Mailer: configuring MAILER_DSN, a simple email, emails from Twig templates, attachments and checking mail during development.
- Message queuesSymfony Messenger: a message and its handler, an asynchronous transport, running a worker, retries and failed messages.
- CachingThe cache in Symfony: CacheInterface, item lifetime, deleting, tags, storing in Redis and caching an HTTP response.
- Calling other servicesSymfony HttpClient: GET and POST requests, parsing JSON, headers and authorization, error handling and scoped clients.
- Translating the interfaceA multilingual Symfony site: translation files, the trans filter, placeholders, plural forms and the language in the address.
- Styles and scriptsThe front end in Symfony: AssetMapper and importmap, adding CSS and JavaScript, third-party packages, Stimulus and preparing for deployment.
- Logging and error pagesLogging and errors in Symfony: LoggerInterface, levels and Monolog configuration, custom 404 and 500 pages, error responses for an API.
- Scheduled tasksSymfony Scheduler: tasks with the AsCronTask and AsPeriodicTask attributes, a custom schedule, running the worker and guarding against double runs.
- Rate limitingSymfony RateLimiter: configuring a limiter, the fixed_window, sliding_window and token_bucket policies, the 429 response and storing counters.
- Turbo and live componentsSymfony UX: Turbo for navigation without reloads, Turbo Frames, Twig components and Live Components with interactivity in PHP.