Chapters
28 Chapters
|
2:24:59
|
Login to bookmark this video
-
Course Code
Subscribe to download the code!Compatible PHP versions: ^7.1.3
Subscribe to download the code!Compatible PHP versions: ^7.1.3
-
This Video
Subscribe to download the video!
Subscribe to download the video!
-
Subtitles
Subscribe to download the subtitles!
Subscribe to download the subtitles!
-
Course Script
Subscribe to download the script!
Subscribe to download the script!
08.
Removing a ManyToMany Item
Scroll down to the script below, click on any sentence (including terminal blocks) to jump to that spot in the video!
Subscribe to jump to this part in the video!
Keep on Learning!
If you liked what you've learned so far, dive in! Subscribe to get access to this tutorial plus video, code and script downloads.
This course is built on Symfony 3, but most of the concepts apply just fine to newer versions of Symfony.
What PHP libraries does this tutorial use?
// composer.json
{
"require": {
"php": "^7.1.3",
"symfony/symfony": "3.4.*", // v3.4.49
"doctrine/orm": "^2.5", // 2.7.5
"doctrine/doctrine-bundle": "^1.6", // 1.12.13
"doctrine/doctrine-cache-bundle": "^1.2", // 1.4.0
"symfony/swiftmailer-bundle": "^2.3", // v2.6.7
"symfony/monolog-bundle": "^2.8", // v2.12.1
"symfony/polyfill-apcu": "^1.0", // v1.23.0
"sensio/distribution-bundle": "^5.0", // v5.0.25
"sensio/framework-extra-bundle": "^3.0.2", // v3.0.29
"incenteev/composer-parameter-handler": "^2.0", // v2.1.4
"composer/package-versions-deprecated": "^1.11", // 1.11.99.4
"knplabs/knp-markdown-bundle": "^1.4", // 1.9.0
"doctrine/doctrine-migrations-bundle": "^1.1", // v1.3.2
"stof/doctrine-extensions-bundle": "^1.2" // v1.3.0
},
"require-dev": {
"sensio/generator-bundle": "^3.0", // v3.1.7
"symfony/phpunit-bridge": "^3.0", // v3.4.47
"nelmio/alice": "^2.1", // v2.3.6
"doctrine/doctrine-fixtures-bundle": "^2.3" // v2.4.1
}
}
16 Comments
If you're fetching User and Genus, why not to make use of param converter, that will handle NotFoundException and fetching from DB ?
Hey kubaf
You are totally right, we can be lazier and let the ParamConverter to do the job for us, but from a teaching perspective, it is more complicated to explain what's going on behind the scenes
Have a nice day!
How could we use route=>model binding to get Doctrine Entity versions and not just ids?
Yo adrianbadarau!
I'm not sure what you mean - can you give an example of your setup and what you'd like to accomplish?
Cheers!
I wanted to do something like public ' function removeScientistAction(Genus $genus, User $user) '
But it's ok, I managed to do it with @ParamConverter
You did it exactly right then :). Cheers!
Persist is not necessary to remove an existing element from the collection.
Following the docs.
* NOTE: The persist operation always considers entities that are not yet known to
* this EntityManager as NEW. Do not pass detached entities to the persist operation.
Hey Jose,
Yes, you're right, it's unnecessary to call persist() if entity is already in the DB. Thank for this tip!
Cheers!
You're welcome :)
Hi, how to you get code completion and color syntaxing on javascript in your twig template ? Thanks
By the way this lesson about doctrine relationship is amazing
Ah, thanks eCosinus! I'm using PhpStorm, and I believe it naturally gives you highlighting and code completion on your JavaScript inside Twig. Do you see something different in PhpStorm for you? It should see the
<script>tag, and know that there is JavaScript inside.Cheers!
Hi, I m using phpstorm too with the symfony plugin, completion works well in twig template and php files except for javascript tags <script> in template files. I have no completion netiher color highlighting
Hey eCosinus ,
Do you use the latest PhpStorm version? It'w weird, if it works well for templates, it should work inside javascript tags too. I'm wondering, what is name of your template where you don't have autocompletion? Is it something like "my-script.js.twig"? Have you wrapped your code with the "<script></script>" tag *inside* this template?
Cheers!
Hi, I m using
phpStorm 2016.1.2
Build #PS-145.1616, built on May 24, 2016
JRE: 1.8.0_76-release-b198 amd64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
I' ve tried to unisntall and reinstall it from stratch It's still not working.
Hm, I'd recommend you to update your PhpStorm to the latest version - as I understand your version isn't the latest one. Probably it helps. If not - try to reset your PhpStorm settings. Actually, they migrate from version to version, so even upgraded PhpStorm will still use your previous settings. So I suppose you need to delete your "Project Settings" and "IDE Settings" - see the https://www.jetbrains.com/h... . Make its backup if you need it.
Btw, could you take a screenshot of opened file in PhpStorm where you doesn't have autocompletion? It helps to understand your case better.
Cheers!
"Houston: no signs of life"
Start the conversation!