1000 search results

All about the User class

…And actually, it's not that important. I'll tell you what it does later. But before we get there, forget about security and remember that our User class is a Doctrine entity. Let's add another field to it, generate a migration & add some…

3:18
Customizing the User Entity

…But! A word of warning. Check out the roles field on top: It's an array and its Doctrine type is json. This is really cool. Newer databases - like PostgreSQL and MySQL 5.7 - have a native "JSON" column type that allows you to store…

6:28
Impersonation (switch_user)

…is also used by a few other features to load the user, like remember_me and switch_user. If you're using the Doctrine user provider like we are, then this property key determines which field will be used for all of this: If you…

6:30
Fetching Relations

…s why we use 'article' => $article. Of course, behind the scenes, Doctrine will make a query where article_id = the id from this Article. But, in PHP, we think all about objects. As nice as this was... there is a much simpler way…

6:02
Final config/ Migration

…We can also delete config_prod.yml. Oh, by the way, if you have some doctrine caching config in config_prod.yml, I would recommend not migrating it. The DoctrineBundle recipe gives you prod configuration that is great for production out-of-the-box. Booya…

7:25
Bye Bye AppBundle

…But, the fix is easy: Find all AppBundle and replace with App. Done! There is one last thing we need to undo: in config/packages/doctrine.yaml. Remove the AppBundle mapping we added. So, what other AppBundle things haven't been updated yet? It's…

7:51
Flex Extras

…more going on. Find your composer.json file and make sure the version constraint is ^3.0. Then, run: composer update doctrine/doctrine-fixtures-bundle Version 3 of this bundle is all new... but not in a "broke everything" kind of way. Before, fixture classes…

6:31
Void Types & Refactoring an Entire Class

…return type to the class you know you're returning... or use the more flexible interface. But actually, for Doctrine collections, you must use Collection. Depending on the situation, this property might be an ArrayCollection or a PersistentCollection... both of which implement the Collection interface…

7:06
ManyToMany Relationship

…thing is that it will hold the array of User objects that are linked to this Genus: Above, add the annotation: @ORM\ManyToMany with targetEntity="User". Finally, whenever you have a Doctrine relationship where your property is an array of items, so, ManyToMany and OneToMany…

5:18
Stripe Customers + Our Users

…getters and setters for the new property: Now that our PHP code is updated, we need to actually add the new column to our table. Since this project uses Doctrine migrations, open a new tab and run: All that did was create a new file…

2:55
We <3 Creating Stripe Customers

…our user record, say $user->setStripeCustomerId($customer->id): Then, I'll use Doctrine to run the UPDATE query to the database: If you're not using Doctrine, just make sure to update the user record in the database however you want. Now, add the else…

4:37
Symfony Console Commands

…we only want to run if this is a development machine, because it resets the database. We'll talk about controlling that later. For this command, use hautelook_alice:doctrine:fixtures:load --no-interaction: Ok! The 3 commands are ready! Head back to the terminal…

5:38
Fixtures: Dummy Data Rocks

…not available in the prod environment. That's fine for us - this is a development tool - and it keeps the prod environment a little smaller. Anyways, this bundle gives us a new console command - doctrine:fixtures:load. When we run that, it'll look for …

3:45
Pagerfanta Pagination

… This is all we need to use Pagerfanta. In the controller, start with $adapter = new DoctrineORMAdapter() - since we're using Doctrine - and pass it the query builder. Next, create a $pagerfanta variable set to new Pagerfanta() and pass it the adapter. On the Pagerfanta…

6:29
Joins and addSelect Reduce Queries

…That's different from SQL, where selecting all the fields from a joined table will give you more fields in your result. Here, addSelect() just tells Doctrine to fetch the FortuneCookie data, but store it internally. Later, when we access the FortuneCookies for a Category…

6:03
Selecting Specific Fields

…s an awesome error: This is what it looks like when you mess up your DQL. Doctrine does a really good job of lexing and parsing the DQL you give it, so when you make a mistake, it'll give you a pretty detailed error…

5:04
HATEOAS Loves Routers

…and it doesn't! I messed up some syntax. Anytime you see the Doctrine\Common\Annotations T_CLOSE_PARENTHESIS type of thing, this is a syntax error in your annotation. I'm missing a comma between my arguments. Let's try that one more time…

3:12
Deployment

…Update your database schema. The easy, but maybe dangerous way is with the schema update console command: php app/console doctrine:schema:update --force Why dangerous? Let’s say you rename a property from name to firstName. Instead of renaming the column, this task may…

6:51
Content Browser

…when we try the page, we're greeted with an error! Netgen Content Browser backend for doctrine_recipe value type does not exist. Yep! We need to implement a class that helps Layouts browse our recipes. That's called a "content browser". Adding a content…

9:02
Adding Lists: Value Type

…The same is true if you're using Ibexa CMS. So here's our next big goal: to add our Recipe Doctrine entity as a "value type" in layouts so that we can create lists and grids containing recipes. Step one to adding a value…

9:58