SymfonyCasts

SymfonyCasts

@symfonycasts.com

Injecting Unicorns and Rainbows back into learning PHP // The official way to learn Symfony: http://SymfonyCasts.com

739 followers5 following337 posts

Rewind ⏪ Cosmic Coding with Symfony #19 I want our Symfony app to be *incredible*. And so, we're going to use Turbo and instantly transform it into a single page app (SPA) experience. This is one of our most impactful 5 minute videos! symfonycasts.com/screencast/s...

symfonycasts.comTurbo: Your Single Page AppTurbo, installed through Symfony UX, turns a Twig-rendered Symfony app into a single-page-app-like experience by intercepting link clicks and replacing full-page reloads with AJAX-driven page swaps.

Rewind ⏪ Cosmic Coding with Symfony #18 We're going to make our new Symfony app much more awesome by introducing my absolute favorite JavaScript tool: Stimulus. With about 10 lines of code, we'll have an animated, closeable sidebar that *always* works. symfonycasts.com/screencast/s...

symfonycasts.comStimulus: Writing Pro JavaScriptStimulus is introduced as the Symfony-friendly way to add reliable, behavior-driven JavaScript to existing HTML by connecting data-controller elements to small controller files, then using it to…

Rewind ⏪ Cosmic Coding with Symfony #17 We're well on our way to building a beautiful Symfony app and today, we finish making the design dynamic! But we're also writing code that's clean & understandable. And we'll add "smart model methods" towards this goal. symfonycasts.com/screencast/s...

symfonycasts.comSmart Model Methods & Making the Design DynamicTurns the starship pages into a fully dynamic Twig-driven design by moving repeated display logic into Starship model methods, fixing asset paths, and wiring named routes for homepage/show links.

🔐 Symfony Security: Going Further #9 Let's swap the built-in switch_user role for a custom attribute, let a voter make the call, & see how to check the permissions of any user - not just the one logged in. And, now our admins can't impersonate each other! symfonycasts.com/screencast/s...

Rewind ⏪ Cosmic Coding with Symfony #14 Our new Symfony site deserves to look *great*. Let's hook that up with Tailwind CSS courtesy of the excellent bundle from those nice folks over at Symfonycasts 😊. I *love* how much fun this is! symfonycasts.com/screencast/s...

symfonycasts.comTailwind CSSSets up Tailwind CSS in a Symfony 7 app, explains how Tailwind is built and kept up to date during development, and then replaces the starter templates with predesigned Tailwind markup that still…

Rewind ⏪ Cosmic Coding with Symfony #13 We get to try out one of my *favorite* parts! Asset Mapper is *the* tool for building a modern CSS & JS frontend without the fuss of a build system. It's time to make our site shine! symfonycasts.com/screencast/s...

symfonycasts.comCSS & JavaScript with Asset MapperHow Symfony 7 serves frontend assets with Asset Mapper, so CSS/JavaScript/images in assets/ can be referenced publicly with automatic cache-busting versioned URLs instead of being manually copied…

Rewind ⏪ Cosmic Coding with Symfony #12 We're making all sorts of pages in our new Symfony app. So for part 12, let's start linking them together! The secret is that every route already has an internal name and we can use it to generate URLs. symfonycasts.com/screencast/s...

symfonycasts.comGenerating URLsBuilds a dedicated StarshipController::show() page for displaying one ship, fetches the ship by route {id} via StarshipRepository, handles missing ships with a 404, and links to the page using…

Rewind ⏪ Cosmic Coding with Symfony #11 We can fine-tune the routes in our Symfony app in tons of cool ways: route {wildcards}, requirements, HTTP methods, etc! We'll use this to create another API endpoint and continue building our app with clean architecture. symfonycasts.com/screencast/s...

symfonycasts.comFancier Routes: Requirements, Wildcards, and MoreBuilds a more realistic API endpoint for fetching a single starship by ID using route wildcards, route requirements, HTTP method restrictions, route prefixes, repository lookup, and a 404 when the…

Symfony Cache Contracts have a sneaky little trick 👀 Use `beta: INF` to force-refresh a cached value without deleting the old one first - so other requests can keep using it while the fresh value is computed. See how it works 👇 symfonycasts.com/blog/symfony...

symfonycasts.comForce Refresh a Symfony Cache Item with beta: INFSymfony's Cache Contracts have a mysterious third argument: "$beta". Here's where its name comes from, how it prevents cache stampedes, and how "beta: INF" lets you force a cache item to refresh…

Rewind ⏪ Cosmic Coding with Symfony #10 Symfony lives & dies by service - which are tools! It's packed full of them. But we can - & will - constantly create our *own* services! Let's do that to centralize our code & learn more about how autowiring *really* works. symfonycasts.com/screencast/s...

symfonycasts.comCreating your own ServiceMoves Starship data-fetching logic out of controllers into a reusable StarshipRepository service, then uses constructor autowiring, Twig object/property access, and |length to reuse that data on…

🚀 New on the blog: our ideal GitHub Actions setup for Symfony apps! Tests, linting, PHPStan, code style, database/schema checks, Symfony-aware diagnostics, asset compilation, plus a scheduled Composer security audit. A solid CI baseline you can actually build from: symfonycasts.com/blog/ideal-g...

symfonycasts.comIdeal GitHub Actions for Symfony AppsA practical, modern GitHub Actions setup for Symfony apps, covering tests, linting, static analysis, database checks, Symfony-aware diagnostics, and scheduled dependency security audits.

Rewind ⏪ Cosmic Coding with Symfony #8 How easy is it to create a JSON endpoint in Symfony? Let's find out! Then, we'll create a "model" class to organize our data and find out how Symfony's serializer system can even turn objects into JSON. symfonycasts.com/screencast/s...

symfonycasts.comCreating JSON API EndpointsBuilds a basic JSON API endpoint in Symfony 7, first by returning an array as JSON from a controller and then by switching to Starship objects so the chapter can introduce Symfony’s Serializer…

Rewind ⏪ Cosmic Coding with Symfony #5 I absolutely ❤️ Twig.We get to know the 3 Twig syntaxes, filters & more. Oh, and packs! Unrelated to Twig, packs are a way to install multiple packages at once to get everything you need for a robust setup. symfonycasts.com/screencast/s...

symfonycasts.comTwig & TemplatesUses Twig in Symfony 7 to move HTML out of controllers, render templates with data, and understand Twig’s core syntax so controllers still return Response objects.

Rewind ⏪ Cosmic Coding with Symfony #4 Fun fact: Symfony projects start as a *single* file: composer.json! So then where do the other files come from? Say hello to Symfony's unique recipes systems. We'll install PHP CS Fixer, skip configuration & use it immediately. symfonycasts.com/screencast/s...

symfonycasts.comMagical Flex RecipesSymfony Flex is a Composer plugin that makes symfony new start from a tiny skeleton and then expands the project by applying package recipes; this chapter shows how aliases and recipes automatically…

🔐 Symfony Security Basics #17 Let's protect our login form from brute-force attacks! We'll enable Symfony's login throttling, see what happens when we trip the limiter, then dig into its configuration and how it works. Delightful nerdery!

symfonycasts.comLimiting Login AttemptsEnables Symfony login throttling to limit failed login attempts, explains the required RateLimiter dependency and cache-backed storage, and shows how the default per-IP/per-username and global IP limits...

Rewind ⏪ Cosmic Coding with Symfony #2 A new Symfony project is... only about 15 files 🤯! Let's get to know our tiny new app, meet the only 2 directories we care about & get PhpStorm set up & ready for coding. symfonycasts.com/screencast/s...

symfonycasts.comGetting to Know our Tiny ProjectIntroduces the tiny Symfony 7 project structure, how dependencies are installed via Composer and vendor/, and how to prepare PhpStorm with the Symfony plugin before writing any code.

🔐 Symfony Security Basics #15 Need to debug a problem from a user's perspective? Let's enable Symfony's user impersonation feature so admins can temporarily switch to another user without ever knowing their password.

symfonycasts.comImpersonating Users with switch_userImpersonation with switch_user lets an admin temporarily log in as another user, and this chapter shows how to enable it in Symfony security, expose switch links in a user admin CRUD, and route the impersonated...

Rewind ⏪ Doctrine Queries #16 We're wrapping up the update to our Doctrine Queries tutorial with a more complex GROUP BY query. We select objects *and* extra data all at once... to reduce our page queries down to 1! symfonycasts.com/screencast/d...

symfonycasts.comUsing GROUP BY to Fetch & Count in 1 QueryUse a JOIN + GROUP BY + COUNT() query in Doctrine to fetch categories and each category’s fortune-cookie count in one database query instead of one query per category.

Rewind ⏪ Doctrine Queries #15 Ever run into an SQL function that Doctrine didn't support - like MySQL's RAND? Those may not work out-of-the-box (and b/c of a good reason), but they're easy to use thanks to the beberlei/DoctrineExtensions library! symfonycasts.com/screencast/d...

symfonycasts.comUsing RAND() or Other Non-Supported FunctionsAdds support for database-specific DQL functions like RAND() so Doctrine can randomize query order, then uses that custom function to return related FortuneCookie records in random order without…