doctrine/doctrine-fixtures-bundle
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|---|---|---|---|---|
doctrine/data-fixtures | 1.7.0 | 27.11 kB | MIT | prod dev | |
doctrine/doctrine-bundle | 2.12.0 | - | MIT | prod | |
doctrine/orm | 3.1.3 | - | MIT | prod dev | |
doctrine/persistence | 3.3.2 | - | MIT | prod dev | |
symfony/config | v7.0.7 | - | MIT | prod dev | |
symfony/console | v7.0.7 | - | MIT | prod dev | |
symfony/dependency-injection | v7.0.7 | - | MIT | prod dev | |
symfony/deprecation-contracts | v3.5.0 | - | MIT | prod dev | |
symfony/doctrine-bridge | v7.0.7 | - | MIT | prod | |
symfony/http-kernel | v7.0.7 | - | MIT | prod dev |
The doctrine/doctrine-fixtures-bundle is a Symfony bundle that facilitates the integration of the Doctrine2 Data Fixtures library into your Symfony applications. It serves as an efficient tool to load data fixtures programmatically into the Doctrine ORM (Object-Relational Mapping) or ODM (Object Document Mapping), making it easier to manage and play around with your application's data for testing or other purposes.
To use the doctrine/doctrine-fixtures-bundle, you need to install the package first via Composer, given that you already have Composer installed and updated. You can do this by running the command below in your terminal:
composer require --dev doctrine/doctrine-fixtures-bundle
Once the bundle is installed, you may need to manually enable it in your kernel, especially if you're using a Symfony version before 3.4. Afterward, you can create fixture classes wherein you define what sort of data you want to generate. Here is an example of what a fixture class might look like:
namespace AppBundle\DataFixtures\ORM;
use Doctrine\Common\DataFixtures\FixtureInterface;
use Doctrine\Persistence\ObjectManager;
use AppBundle\Entity\Product;
class LoadProductData implements FixtureInterface
{
public function load(ObjectManager $manager)
{
$product = new Product();
$product->setName('A new product');
$product->setPrice('19.99');
$product->setDescription('Lorem ipsum dolor sit amet');
$manager->persist($product);
$manager->flush();
}
}
And here is how you'd use the console command to load your fixtures:
php bin/console doctrine:fixtures:load
The complete documentation for the doctrine/doctrine-fixtures-bundle is made available online. You can find it on the Symfony website at this address: http://symfony.com/doc/current/bundles/DoctrineFixturesBundle/index.html. This documentation provides a comprehensive guide on how you can make the most of this bundle, including detailed instructions and usage examples.