Download the PHP package api-skeletons/laravel-doctrine-data-fixtures without Composer
On this page you can find all versions of the php package api-skeletons/laravel-doctrine-data-fixtures. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download api-skeletons/laravel-doctrine-data-fixtures
More information about api-skeletons/laravel-doctrine-data-fixtures
Files in api-skeletons/laravel-doctrine-data-fixtures
Package laravel-doctrine-data-fixtures
Short Description Doctrine Data Fixtures for Laravel
License MIT
Informations about the package laravel-doctrine-data-fixtures
Laravel Doctrine Data Fixtures
Laravel has built-in support for 'seed' data. In seed data, the classes are not namespaced and many developers treat seed data as a one-time import. Seed data often uses auto-increment primary keys. Perhaps these notes are what differentiates seed data from Fixtures.
In my fixtures I want static primary keys and I want to be able to re-run my fixtures at any time. I want the data my fixtures populate to be stored with my fixtures and I want to reference fixture values though class constants within my code.
For instance, to validate a user has an ACL role the code may read:
but this use of strings in the code does not read well and may be error-prone. Instead of the above, I want my code to read
This pattern is not possible with seed data because seed data does not have namespaces. So, this repository exists not only as an alternative to Laravel seed data, but as a namespaced-integrated tool for static database data.
Installation
Run the following to install this library using Composer:
A doctrine-data-fixtures.php
configuration file is required. Publish the included config to your project:
Configuration
Doctrine MongoDB, ORM and PHPCR are supported. See the configuration file for details.
This example assumes laravel-doctrine/orm
is installed and you'll be using fixtures
for ORM data:
Fixture Groups
Modeled from api-skeletons/doctrine-data-fixture for Laminas, fixtures are organized into groups. This organization allows fixtures for specific modules, development faker data, different entity managers, and so on.
Use
List Fixtures
List all groups or list all fixtures for a group.
The <group>
is optional.
Executing a Fixture Group through Artisan command
The <group>
is required.
Append is the default option. This is inversed with --do-not-append
Options:
--purge-with-truncate
if specified will purge the object manager's tables before
running fixtures for the ORMPurger only.
--do-not-append
will delete all data in the database before running fixtures.
Executing a Fixture Group from code
For unit testing or other times you must run your fixtures from within code, follow this example:
Doctrine data-fixtures
Be sure to read the documentation on the parent library doctrine/data-fixtures
All versions of laravel-doctrine-data-fixtures with dependencies
doctrine/data-fixtures Version ^1.5
laravel/framework Version ^8.82 || ^9.0 || ^10.0 || ^11.0