1000 search results

Starting in Symfony2: Course 3 (2.4+)

…Plus a ton more! Highlights: Doctrine relations, metadata, and the JoinColumn ManyToMany relationship that's bidirectional, owning versus inverse side and why that matters Loading fixtures with shared data Creating shortcuts with your very own base controller! Doctrine extensions: timestampable, sluggable Ajax: returning Json from…

29 videos
|
1:34:37
Maker Bundle: Let's Generate Some Code!

…same thing. Thanks to the new bundle, we have a ton of commands that start with make! Commands for generating a security system, making a controller, generating doctrine entities to talk to the database, forms, listeners, a registration form.... lots and lots of stuff! Let…

5:13
High-Tech Controllers: Auto-inject Entities

…SEO-friendly! Flying through space is dangerous business. Sometimes starships experience "rapid unscheduled disassemblies"... or in other words, they explode. We need a way to remove ships from our database that no longer... err... exist. Next, we'll see how to delete entities with Doctrine.

4:23
Processing the Submitted Form

…that no ID is set because Doctrine hasn't saved it in the database yet. I'll quickly add a PHPDoc above the variable to make PhpStorm's autocomplete happier, and delete the dd() statement: To save the new part, we need Doctrine's EntityManager…

4:59
Black Hole: Deleting Entities

…search on and the value is the value to search for: ['slug' => $slug]: When using these out-of-the-box find methods, Doctrine automatically escapes the values, so you don't need to worry about SQL injection attacks. Adjust this if statement to if (…

3:25
Starship Upgrade: Adding Slug and Timestamp Fields

…Open up the new migration file. I love this. Remember that migrations are generated by comparing the database to the entity class. Doctrine sees the new fields in the class, does not see the corresponding columns in the table, generates the SQL to fix that…

5:06
Alien Tech for Fixtures: Foundry & Faker

…other two... and remove the old code: Bonus! Remove the persist() and flush() calls: Foundry handles that for us! Let's see what this does! Reload the fixtures: symfony console doctrine:fixtures:load Choose yes and... success! Back over, refresh and... it looks the same…

4:29
Quantum Refactor: Rich Entities

…maintainability. Ok crew, that's it for this Doctrine Fundamentals course! If you're looking to upgrade your Doctrine skills, search for "Doctrine" on SymfonyCasts to find more advanced courses. The Doctrine documentation is a great resource too. And as always, if you have any…

2:42
Part Entity

…cleaned up the old migrations from the last course. So this one is all about StarshipPart. Run it with: symfony console doctrine:migrations:migrate The table is in the database! But there are two fields that I like to add to all my entities: createdAt…

3:12
Built-in Symfony Form Themes

…fancy and use an Order enum for the second argument. So instead of ASC, write Order, importing the enum from Doctrine\Common\Collections, then ::Ascending->value: Super nerdy... But at least we know we didn't make a typo in those, ummm... 3 letters... Since…

5:49
Joining to Avoid the N+1 Trap

…in the template looping over the parts, when we reference part.starship, Doctrine has a light bulb moment. It realizes it has the part data, but not the Starship data for this part. So it queries for it. We end up with one query for…

3:35
Setting the Relation

…not related yet. Pff, try to load the fixtures anyway. Head over to your terminal and run: symfony console doctrine:fixtures:load Rutro: starship_id cannot be null on the starship_part table. Why is that column required? In StarshipPart, the starship property has a…

2:51
Swagger UI: Interactive Docs

…of all of the DragonTreasures we currently have, which is just this one. So in just a few minutes of work, we have a fully featured API for our Doctrine entity. That is cool. Copy the URL to the API endpoint, open a new tab…

6:41
Droid Entity for the ManyToMany Relationship

…to generate the migration and run it: Go take a peek. No surprises here. So... run it: symfony console doctrine:migrations:migrate And... we've got a shiny new droid table in the database. It's not yet in a relationship with ship, but hey…

2:41
Creating your First ApiResource

…file... just to make sure it doesn't contain any weird surprises. Looks good! So spin back over and run this with: symfony console doctrine:migrations:migrate Done! We now have an entity and a database table. But if you go and refresh the documentation..…

5:44
The Clever Criteria System

…10 of them cost more than 50,000. What a waste! Could we ask Doctrine to change the query so it only grabs the parts related to the starship where the price is greater than 50,000? Enter the Criteria object. This thing is mighty…

4:03
Ordering a Relation and "fetch" type

…what's happening: we grab the starships, then as soon as we count ship.parts, Doctrine realizes it doesn't have that data yet. So it fetches all the parts for each ship one by one and counts them. This is a common situation: we…

3:30
Fetching a Relation's Data

… Instead, pass the Starship object itself. You could pass the id if you're feeling lazy, but in the spirit of Doctrine, relationships, and thinking about objects, passing the entire Starship object is the way to go. Let's debug and see what we've…

4:16
Setting Many To Many Relations

…the flush, remove an assignment: $starship->removeDroid($droid1): Reload the fixtures and check out the join table. Only two rows remain! Doctrine removed the row for our removed droid. One final touch on ManyToMany — remember when we discussed owning versus inverse sides of a relationship?…

3:12
Many-To-Many Relationship

…database: with a join table. The real magic of Doctrine is that we only need to think about objects. A Starship object has many Droid objects, and a Droid object has many Starship objects. Doctrine handles the tedious details of saving that relationship to the…

2:45