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

  Переглядів 17,692

Code With Dary

Code With Dary

День тому

This video will show you how you could easily create and run entities and migrations in Symfony 6 - Want to learn an incredible open-source PHP framework? Symfony is one of the most popular frameworks when you need to build high-performance & complex web applications.
📚 New Udemy Course
If you're looking to level up your Laravel skills, my new course "Udemy Migirations, Seeders, Factories, Query Builder, Eloquent & Relationships" is the perfect opportunity. Learn the essential tools and techniques for building robust and scalable web applications with Laravel: www.udemy.com/course/masterin...
📲 Let’s plan a meeting
Plan a (paid) 1-hour meeting on Calendly to do portfolio reviews, code reviews resume reviews or a coaching session for Laravel. Please read the description before booking: calendly.com/codewithdary
💌 Newsletter
Sign up for my free weekly email newsletter: www.newsletter.codewithdary.com
🔥 Resources
- PHP Hosting (10% DISCOUNT): www.hostinger.com/codewithdary
- TikTok: / codewithdary
- Instagram: / codewithdary
- Twitter: / codewithdary
- Blog: blog.codewithdary.com/
- Newsletter: newsletter.codewithdary.com/
- Patreon: www.patreon.com/user?u=30307830
- GitHub: github.com/codewithdary/symfo...
Want to learn more?
- Courses: / @codewithdary
📋 Table of Content
00:00 - Introduction
00:59 - What are Entities?
02:14 - Creating our first Entity
05:40 - Diving into our First Entity
07:41 - Creating a new Entity & Linking them
12:02 - Diving into our Migration
16:08 - Running our migrations & Checking the DB
#symfony #framework #symfony6 #php

КОМЕНТАРІ: 45
@codewithdary
@codewithdary 2 роки тому
Want to learn more about me? Let’s connect through Instagram. www.Instagram.com/codewithdary
@faizan101010
@faizan101010 9 місяців тому
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 9 місяців тому
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 11 місяців тому
@codewithdary why don't you reply this i have facing same issue give it solution
@acetwebsite7197
@acetwebsite7197 11 місяців тому
@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/
@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 10 місяців тому
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 10 місяців тому
Solution is in read more
@codewithdary
@codewithdary 9 місяців тому
Thank you!
@najimelguennouni873
@najimelguennouni873 2 роки тому
good job bro
@codewithdary
@codewithdary 2 роки тому
Big up Najim!!
@Rubenhood97
@Rubenhood97 Рік тому
Great tuto
@codewithdary
@codewithdary Рік тому
Thank you Zakaria!
@icebej3947
@icebej3947 2 роки тому
Thanks
@codewithdary
@codewithdary 2 роки тому
Welcome!
@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
@lasithadulshan7357
@lasithadulshan7357 Рік тому
Thank Yoou
@codewithdary
@codewithdary Рік тому
Thank you for watching Lasitha!!
@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
@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.
@m_m_m_m_m_m_m_m_m_m_m
@m_m_m_m_m_m_m_m_m_m_m Рік тому
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 Рік тому
Both should work fine, right?
@ummehanyarozshandaanny2846
@ummehanyarozshandaanny2846 Рік тому
it's just because of php version
@ionutcornea5469
@ionutcornea5469 9 місяців тому
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 8 місяців тому
i have the same issue? How to solve it?
@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?
Spotlight: SDE 3 Backend Engineering in Kashmir, India !!🚀🚀
17:17
КИРПИЧ ОБ ГОЛОВУ #shorts
00:24
Паша Осадчий
Переглядів 5 млн
ФОКУС С ЧИПСАМИ (секрет)
00:44
Masomka
Переглядів 4 млн
Build ENTIRE Frontends With ONE Prompt - OpenUI Tutorial
8:59
Matthew Berman
Переглядів 34 тис.
Certificates from Scratch - X.509 Certificates explained
21:50
OneMarcFifty
Переглядів 82 тис.
КИРПИЧ ОБ ГОЛОВУ #shorts
00:24
Паша Осадчий
Переглядів 5 млн