1000 search results

Exceptions Part 2: Adding Fence Security

…Actually, I don't need to refactor, but now is a great time to add the missing Doctrine annotations. Above the $securities property, add @ORM\OneToMany() with targetEntity="Security" and mappedBy="enclosure". enclosure is the name of the property on the other side of the…

7:11
Rock some FOSUserBundle!

…php bin/console It's alive! Now, we can generate the migration for our User class: php bin/console doctrine:migrations:diff Yep, that looks about right. Run it: php bin/console doctrine:migrations:migrate Perfect! At this point, the only thing this bundle has…

12:02
The POST Create API

…just simpler if you can update the state immediately. And that is why UUID's can be awesome. If you configure your Doctrine entities to use UUID's instead of auto-increment ids, you can generate valid UUID's in JavaScript, update the state immediately…

9:04
Give the User a Subscription (in our Database)

…and $stripeSubscription->id: Booya! And, time to save this to the database! Since we're using Doctrine in Symfony, we need the EntityManager object to do this. I'll use dependency injection: add an EntityManager argument to the __construct() method, and set it on a…

8:41
Finishing with kernel.response and kernel.exception

…After that, the controller is called and the stuff under that is our work. We can see some Doctrine calls we’re making and the time it takes to render the template. After the controller, the kernel.response event is dispatched, it has a few…

5:34
API Pagination Done Easily

…m just trying to keep things simple. If I were doing this in a real project, I'd probably use a library called Pagerfanta. It helps you paginate and has built-in adapters already for Doctrine, and Elastic Search. You can give it things like…

8:48
Twig Extensions and Dependency Injection Tags

…to unlocking really powerful features. A very important tag is kernel.event_listener, which allows you to register “hooks” inside Symfony at various stages of the request lifecycle. That topic is for another screencast, but we’ll cover a very similar subject next: Doctrine events.

4:33
Customizing the Contentful Slugger

…can run: symfony console doctrine:migrations:migrate current-1 That will reverse the most recent migration, causing the contentful and route tables to be dropped. Put them back with: symfony console doctrine:migrations:migrate Re-sync the content again: And now check the routes: Yes…

5:36
Content Browser: Returning the Items

…web debug toolbar, we have a 400 error. Dang. When we open that up, we see: Value loader for doctrine_recipe value type does not exist. There's just one final piece we need: A very simple class called the "value loader". That's next.

5:33
Hello Layouts+ Setup!

…putting into them. We'll see all of that in the Layouts admin section in a minute. To add the needed tables, scroll up and copy this nifty doctrine:migrations:migrate line. This is kind of cool. The layouts packages comes with migrations... and this…

7:30
Upgrading to Symfony 6.0

…? We get Attempted the load class QueryAdapter from namespace "Pagerfanta\Doctrine\ORM. This shouldn't be a surprise... since we did upgrade pagerfanta-bundle from 2.8 to 3.6. This is a situation where you need to find the GitHub page for the library…

7:07
Annotations to Attributes

…re back! With just a few commands we've converted our entire site from annotations to attributes. Woo! Next, let's add property types to our entities. That's going to allow us to have less entity config thanks to a new feature in Doctrine.

5:14
Always Remember Me & "signature_properties"

…s password in the database. We can cheat and do this on the command line: symfony console doctrine:query:sql 'UPDATE user SET password="foo" WHERE email = "abraca_admin@example.com"' Setting the password to foo is utter nonsense... since this column needs to…

6:28
Prod Vault Optimization & Vault for Tests

…Next, let's talk about a really cool new feature called "validation auto mapping". It's a wicked-smart feature that automatically adds validation constraints based on your Doctrine metadata and also based on the way that your PHP code is written in your class.

4:53
Database Tricks on SymfonyCloud

…main php bin/console doctrine:fixtures:load Ok, let's break this down. First, there is actually a much easier way to do all of this... but I'll save that for some future SymfonyCloud tutorial. Basically, we're running the doctrine:fixtures:load command…

8:00
Timeline: Go Behind-the-Scenes with your Code

…not that there are only 3 objects being hydrated during this request, but that our code asks Doctrine to hydrate one or more objects on three occasions. So where are the 3 times that we're hydrating objects? One of the cool things is that…

7:15
Flysystem & S3

…it should... just kinda work! The easiest way to find out is to reload the fixtures: php bin/console doctrine:fixtures:load And yes, I do recommend using S3 when developing locally if that's what you're using on production. You could change the…

7:44
Unique (but not Insane) Filenames

…But if you want to guarantee cleaner filenames, there's an easy way to do that. I'll use a class called Urlizer: this comes from the gedmo/doctrine-extensions library. It has a nice method called urlize() and we can wrap our $originalFilename in…

6:30
ManyToMany with Extra Fields

…is still there, just the way it always was. If you try to run this migration...it will blow up, with this rude error: Incorrect table definition; there can be only one auto column... It turns out, Doctrine has a bug! Gasp! The horror! Yep…

8:20
Blog
Doctrine's HIDDEN Gem

We had a great question from a user recently where the answer involved a little-known Doctrine feature called HIDDEN. You won't need it often, but it deserves its 5 in the spotlight! HIDDEN allows you to select a field so that you can…

By Leannapelham

Read Full Post