Get started with Symfony 6 for beginners — Part 3.1| Database, Doctrine, Entity.

Azay Karimli
2 min readSep 11, 2022

This article will demonstrate how to populate a database with fake data (fake blog information). For this Open up a terminal window and run the following command:

$ composer require --dev orm-fixtures

This command will install the extra library and will create a file App\DataFixtures\AppFixtures

Open that file — src/DataFixtures/AppFixtures.php and let's create a few blog posts.

<?phpnamespace App\DataFixtures;use Doctrine\Bundle\FixturesBundle\Fixture;use Doctrine\Persistence\ObjectManager;use App\Entity\Blog;class AppFixtures extends Fixture{public function load(ObjectManager $manager): void{for ($i = 1; $i < 6; $i++) {$blog = new Blog;$blog->setTitle('Post ' . $i);$blog->setShortDescription('Short descr for post number ' . $i);$blog->setBody("Lorem Ipsum is simply dummy text of theprinting and typesetting industry. Lorem Ipsum has beenthe industry's standard dummy text ever since the 1500s,when an unknown printer took a galley of type and scrambled

--

--