Entities & Migrations | What are Entities in Symfony? | Symfony 6 for Beginners

  Рет қаралды 20,526

Code With Dary

Code With Dary

Күн бұрын

Пікірлер: 47
@codewithdary
@codewithdary 2 жыл бұрын
Want to learn more about me? Let’s connect through Instagram. www.Instagram.com/codewithdary
@SiphoMkhwanazi
@SiphoMkhwanazi 2 ай бұрын
The explanations here are very clear. Thank you so much from this, you're easing my transition. I'm jumping straight from Django ORM. 🙌
@faizan101010
@faizan101010 Жыл бұрын
You dont need to hit control+c. You can just hit enter as stated in the message while creating entity. If you haven't typed anything then it will just exit the entity creation flow
@codewithdary
@codewithdary Жыл бұрын
Thank you
@scottwoodcock2779
@scottwoodcock2779 2 жыл бұрын
10:11 Could be my setup, however, I had to press enter on "New field name inside Actor [movies]:" rather than immediately using, [control + C]
@codewithdary
@codewithdary 2 жыл бұрын
Ah yeah, that works too!
@codewithdary
@codewithdary 2 жыл бұрын
Anyways, thanks for sharing!
@DjVorcera
@DjVorcera 2 жыл бұрын
Well to be fair, when I watched that moment I was like "wait this isn't right". And your terminal shows that as well ;) The final question is how to call the field in the actor entity but you first canceled it and a few seconds later the the terminal shows you did it again. But i'm not trying to be a smart ass, just wanted to let others be aware of the final enter there. Also, really great stuff mate. Love that I finally found a tutorial about symfony with doctrine that works. Almost lost hope finding one ^_^
@codewithdary
@codewithdary 2 жыл бұрын
@@DjVorcera thank you buddy. I’m here to improve too, maybe not in the actual coding part but definitely screen casting etc, so thanks for the feedback! :)
@DjVorcera
@DjVorcera 2 жыл бұрын
​@@codewithdary nobodies perfect :) But the explanations are great. It is seriously helping me a lot. Looking forward to maybe seeing more symfony related videos in the future (if any haha )
@baderelhayah7961
@baderelhayah7961 Жыл бұрын
Great video, easy to understand thank you so much
@codewithdary
@codewithdary Жыл бұрын
You are welcome Bader!
@dannysdianr.
@dannysdianr. 2 жыл бұрын
10:49 When i follow your instruction, i check my Actor.php, i cannot find private $movies. Why ???. Oh don't mind, just press enter on cmd. Thank you
@acetwebsite7197
@acetwebsite7197 Жыл бұрын
@codewithdary why don't you reply this i have facing same issue give it solution
@acetwebsite7197
@acetwebsite7197 Жыл бұрын
@dannysdianr don't abort while mapping fields exactely in the while adding new property to relational entity after your set yes and hit enter along way to the end of the mapping process mapping automatically close you just hitting enter. PS E:\dev\localhost\htdocs\movies> symfony console make:entity classes created: src/Entity/Classes.php created: src/Repository/ClassesRepository.php Entity generated! Now let's add some fields! You can always add more fields later manually or by re-running this command. New property name (press to stop adding fields): > class Field type (enter ? to see all types) [string]: > string Field length [255]: > 255 Can this field be null in the database (nullable) (yes/no) [no]: > yes updated: src/Entity/Classes.php > Success! PS E:\dev\localhost\htdocs\movies> symfony console make:entity classes Your entity already exists! So let's add some new fields! New property name (press to stop adding fields): > [critical] Error thrown while running command "make:entity classes". Message: "Aborted." error sending signal interrupt not supported by windows PS E:\dev\localhost\htdocs\movies> symfony console make:entity students created: src/Entity/Students.php created: src/Repository/StudentsRepository.php Entity generated! Now let's add some fields! You can always add more fields later manually or by re-running this command. New property name (press to stop adding fields): > student Field type (enter ? to see all types) [string]: > string Field length [255]: > 255 Can this field be null in the database (nullable) (yes/no) [no]: > no updated: src/Entity/Students.php Add another property? Enter the property name (or press to stop adding fields): > subject Field type (enter ? to see all types) [string]: > string Field length [255]: > 255 Can this field be null in the database (nullable) (yes/no) [no]: > no updated: src/Entity/Students.php > Success! Next: When you're ready, create a migration with php bin/console make:migration PS E:\dev\localhost\htdocs\movies> symfony console make:entity classes Your entity already exists! So let's add some new fields! New property name (press to stop adding fields): > teachers Field type (enter ? to see all types) [string]: > relation What class should this entity be related to?: > Students What type of relationship is this? ------------ ------------------------------------------------------------------------ Type Description ------------ ------------------------------------------------------------------------ ManyToOne Each Classes relates to (has) one Students. Each Students can relate to (can have) many Classes objects. OneToMany Each Classes can relate to (can have) many Students objects. Each Students relates to (has) one Classes. ManyToMany Each Classes can relate to (can have) many Students objects. Each Students can also relate to (can also have) many Classes objects. OneToOne Each Classes relates to (has) exactly one Students. Each Students also relates to (has) exactly one Classes. ------------ ------------------------------------------------------------------------ Relation type? [ManyToOne, OneToMany, ManyToMany, OneToOne]: > ManyToMany Do you want to add a new property to Students so that you can access/update Classes objects from it - e.g. $students->getClasses()? (yes/no) [yes]: > yes A new property will also be added to the Students class so that you can access the related Classes objects from it. New field name inside Students [classes]: > updated: src/Entity/Classes.php updated: src/Entity/Students.php Add another property? Enter the property name (or press to stop adding fields): > Success! have you see the updated propmt for both entity if you see in your terminal you doing corect you will get what we see in this videos as a output. if have any more questions reach out to www.linkedin.com/in/vasudevan-n-r-481b70151/
@nbro5529
@nbro5529 5 ай бұрын
Which VS Code extension did you use exactly to visualize the tables? Is it specific to MySQL? I've searched for extensions and there are many, but I don't to install a bunch of them. I just want to install the "best".
@kingtyphoon
@kingtyphoon Жыл бұрын
Symfony, make me a new entity or php/bin console, make me a new entity is actually a very good nmemonic for learning how to create entities out of your head so thanks for sharing it with us Code With Dary!
@codewithdary
@codewithdary Жыл бұрын
Thank you so much for your kind words
@YassineNDv
@YassineNDv Жыл бұрын
this series of symfony is really good and following it with the doc . but i just wanna know if anyone found a solution for anotation ? somehow on my controller th anototation works fine but inside the modal , these anotation is returned as error by intelephense #[ORM\Id] #[ORM\GeneratedValue] #[ORM\Column] Solution : in your console do => composer require doctrine/annotations go to your extensions in vscode => PHP intelephense and disable it , (reload the vscode) AND THEN enable it. Leave a like here or a comment so that everyone fix the issue quickly
@YassineNDv
@YassineNDv Жыл бұрын
Solution is in read more
@codewithdary
@codewithdary Жыл бұрын
Thank you!
@Rubenhood97
@Rubenhood97 Жыл бұрын
Great tuto
@codewithdary
@codewithdary Жыл бұрын
Thank you Zakaria!
@mariozerrini1408
@mariozerrini1408 Жыл бұрын
the relation doesnt work for me when i do it from the cli even though everything is green but it just doesnt generate the methods and the tables, foreign key..
@alionides
@alionides Жыл бұрын
in symfony 6.2 you should pass relation to field type then follow instructure $ php bin/console make:entity Class name of the entity to create or update (e.g. BraveChef): > Product New property name (press to stop adding fields): > category Field type (enter ? to see all types) [string]: > relation What class should this entity be related to?: > Category Relation type? [ManyToOne, OneToMany, ManyToMany, OneToOne]: > ManyToOne
@jeanrakotoarison1976
@jeanrakotoarison1976 Жыл бұрын
@@alionides Thank you, I was searching for this
@alionides
@alionides Жыл бұрын
@@jeanrakotoarison1976 Welcome
@najimelguennouni873
@najimelguennouni873 2 жыл бұрын
good job bro
@codewithdary
@codewithdary 2 жыл бұрын
Big up Najim!!
@lasithadulshan7357
@lasithadulshan7357 Жыл бұрын
Thank Yoou
@codewithdary
@codewithdary Жыл бұрын
Thank you for watching Lasitha!!
@ionutcornea5469
@ionutcornea5469 Жыл бұрын
My addActor and removeActor methods are undefined inside the Actor Entity and I do not understand why. I followed the exact same steps.. Hmm..
@md.nazmulhuda7605
@md.nazmulhuda7605 Жыл бұрын
i have the same issue? How to solve it?
@icebej3947
@icebej3947 2 жыл бұрын
Thanks
@codewithdary
@codewithdary 2 жыл бұрын
Welcome!
@suryakiranvishnumulkala3110
@suryakiranvishnumulkala3110 Жыл бұрын
I am getting this when i run " symfony console make:entity " and tells me create name of entity i enterted " Movie " as said in the video 2:45 " [critical] Error thrown while running command "make:entity". Message: "An exception occurred in the driver: could not find driver" please help me with this dary
@codewithdary
@codewithdary Жыл бұрын
You are missing a PHP extension for your database driver. Please install that, and restart your web server.
@suryakiranvishnumulkala3110
@suryakiranvishnumulkala3110 Жыл бұрын
@@codewithdary Please Can you elaborate it more. i didn't get i am on intial stage of learning. Please tell me with step by step.
@OpaGohan
@OpaGohan Жыл бұрын
2:24 If i try "symfony console make:entity" and then type in "Movie", i get the error message: Doctrine ORM Manager named "" does not exist. I also tried the same with "Movies", there i get the error message: Cannot find the entity manager for class "App\Entity\Movies"
@OpaGohan
@OpaGohan Жыл бұрын
I use Php 8.2.5 and Symfony 6
@m_m_m_m_m_m_m_m_m_m_m
@m_m_m_m_m_m_m_m_m_m_m 2 жыл бұрын
Instead of creating the entity like this: /** * @ORM\Entity(repositoryClass=MovieRepository::class) */ class Movie { /** * @ORM\Id * @ORM\GeneratedValue * @ORM\Column(type="integer") */ private $id; It created like: #[ORM\Entity(repositoryClass: MovieRepository::class)] class Movie { #[ORM\Id] #[ORM\GeneratedValue] #[ORM\Column(type: 'integer')] private $id; I'm not sure what did I do wrong and how to fix that.
@codewithdary
@codewithdary 2 жыл бұрын
Both should work fine, right?
@ummehanyarozshandaanny2846
@ummehanyarozshandaanny2846 2 жыл бұрын
it's just because of php version
@stormybear4986
@stormybear4986 Жыл бұрын
Dary, it's not "Doc-treen", it's "Doc-trinn".
@codewithdary
@codewithdary Жыл бұрын
Oops, thank you so much! Sometimes I struggle with pronouncing a couple words, also with 'Facade' in Laravel, hehe.
@stormybear4986
@stormybear4986 Жыл бұрын
@@codewithdary Believe me, I understand. I've been an English teacher for a long time, English is one of the most difficult languages on the planet, many Americans can't even speak it well. Then you add in loan words like the French façade "fa-SAHD" and it gets even crazier. I speak 12 languages and have lived all over the world and English is really hard for non native speakers. May I ask what your mother tongue is? I'm guessing something Slavic/Eastern European, perhaps Russian or Bulgarian?
I tricked MrBeast into giving me his channel
00:58
Jesser
Рет қаралды 27 МЛН
the balloon deflated while it was flying #tiktok
00:19
Анастасия Тарасова
Рет қаралды 35 МЛН
World’s strongest WOMAN vs regular GIRLS
00:56
A4
Рет қаралды 17 МЛН
Doctrine ORM - PHP Entities & Data Mapper Pattern - Full PHP 8 Tutorial
26:18
Databases & Migrations | Laravel For Beginners | Learn Laravel
15:09
Code With Dary
Рет қаралды 54 М.
Top 7 Ways to 10x Your API Performance
6:05
ByteByteGo
Рет қаралды 339 М.
When to use Traits, Interfaces, and Abstract Classes in PHP
15:08
Andrew Schmelyun
Рет қаралды 22 М.
I tricked MrBeast into giving me his channel
00:58
Jesser
Рет қаралды 27 МЛН