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

Поділитися
Вставка
  • Опубліковано 1 гру 2024

КОМЕНТАРІ • 47

  • @codewithdary
    @codewithdary  2 роки тому +1

    Want to learn more about me? Let’s connect through Instagram.
    instagram.com/codewithdary

  • @SiphoMkhwanazi
    @SiphoMkhwanazi 3 місяці тому

    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 Рік тому +7

    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

  • @scottwoodcock2779
    @scottwoodcock2779 2 роки тому +10

    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 роки тому +1

      Ah yeah, that works too!

    • @codewithdary
      @codewithdary  2 роки тому

      Anyways, thanks for sharing!

    • @DjVorcera
      @DjVorcera 2 роки тому +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 Рік тому +1

    Great video, easy to understand thank you so much

  • @dannysdianr.
    @dannysdianr. 2 роки тому +5

    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/

  • @Rubenhood97
    @Rubenhood97 Рік тому +1

    Great tuto

  • @nbro5529
    @nbro5529 6 місяців тому

    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".

  • @YassineNDv
    @YassineNDv Рік тому +3

    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

  • @kingtyphoon
    @kingtyphoon Рік тому +1

    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!

  • @mariozerrini1408
    @mariozerrini1408 2 роки тому +1

    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 2 роки тому +1

      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 Рік тому +1

      @@alionides Thank you, I was searching for this

    • @alionides
      @alionides Рік тому

      @@jeanrakotoarison1976 Welcome

  • @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  Рік тому +1

      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.

  • @najimelguennouni873
    @najimelguennouni873 2 роки тому +1

    good job bro

  • @lasithadulshan7357
    @lasithadulshan7357 Рік тому +1

    Thank Yoou

  • @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

  • @icebej3947
    @icebej3947 2 роки тому +1

    Thanks

  • @m_m_m_m_m_m_m_m_m_m_m
    @m_m_m_m_m_m_m_m_m_m_m 2 роки тому +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.

  • @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..

  • @stormybear4986
    @stormybear4986 Рік тому +1

    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?