1000 search results

Fun with Commands

…if you needed your SlackClient service, you would just add a __construct() method and autowire it! With our new knowledge, let's keep going and start mastering features, like the Doctrine ORM, form system, API stuff and a lot more. Alright guys, seeya next time…

5:44
Services

…you learn to master services, you can do anything from anywhere in Symfony. There's a lot more to say about the topic of services, and so many other parts of Symfony: configuration, Doctrine & the database, forms, Security and APIs, to just name a few…

7:24
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
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
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
Idempotency, changed_when & Facts

…and paste that below: So what language happens when there are no migrations to execute? Go to your virtual machine and run the migrations to find out: ./bin/console doctrine:migrations:migrate --no-interaction Yes! It says: No migrations to execute That's the key…

6:48
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
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
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…

47 lines | config/packages/doctrine.yaml
doctrine:
// ... lines 2 - 7
orm:
// ... lines 9 - 18
filters:
fortuneCookie_discontinued: App\Doctrine\DiscontinuedFilter
// ... lines 21 - 47
See Code Block in Script
51 lines | config/packages/doctrine.yaml
doctrine:
// ... lines 2 - 7
orm:
// ... lines 9 - 18
filters:
fortuneCookie_discontinued:
class: App\Doctrine\DiscontinuedFilter
enabled: true
parameters:
discontinued: false
// ... lines 25 - 51
See Code Block in Script
43 lines | config/packages/doctrine.yaml
doctrine:
dbal:
url: '%env(resolve:DATABASE_URL)%'
// ... lines 4 - 43
See Code Block in Script
44 lines | config/packages/doctrine.yaml
doctrine:
dbal:
// ... lines 3 - 7
schema_filter: ~^(?!nglayouts_)~
// ... lines 9 - 44
See Code Block in Script
5 lines | config/packages/test/doctrine.yaml
// ... line 1
doctrine:
dbal:
url: '%env(resolve:DATABASE_TEST_URL)%'
See Code Block in Script
19 lines | config/packages/doctrine.yaml
doctrine:
dbal:
url: '%env(resolve:DATABASE_URL)%'
// ... lines 4 - 19
See Code Block in Script
19 lines | config/packages/doctrine.yaml
doctrine:
dbal:
// ... lines 3 - 4
# IMPORTANT: You MUST configure your server version,
# either here or in the DATABASE_URL env var (see .env file)
#server_version: '5.7'
// ... lines 8 - 19
See Code Block in Script
19 lines | config/packages/doctrine.yaml
doctrine:
dbal:
// ... lines 3 - 6
server_version: '8.0'
// ... lines 8 - 19
See Code Block in Script
doctrine:
dbal:
url: '%env(resolve:DATABASE_URL)%'
# IMPORTANT: You MUST configure your server version,
# either here or in the DATABASE_URL env var (see .env file)
#server_version: '5.7'
orm:
auto_generate_proxy_classes: true
naming_strategy: doctrine.orm.naming_strategy.underscore_number_aware
auto_mapping: true
mappings:
App:
is_bundle: false
type: annotation
dir: '%kernel.project_dir%/src/Entity'
prefix: 'App\Entity'
alias: App
See Code Block in Script
19 lines | config/packages/doctrine.yaml
doctrine:
dbal:
// ... lines 3 - 6
server_version: '5.7'
// ... lines 8 - 19
See Code Block in Script