$path = array('directory1', 'directory2', 'directory3'); // Array of directories which contain yml files. It will find all files with an extension of .yml
$path = array('directory1', 'directory2', 'directory3'); // Array of directories which contain yml files. It will find all files with an extension of .yml
// Specify the format of the data you are importing
// Specify the format of the data you are importing
$format = 'yml';
$format = 'yml'; // xml, yml, json
$format = 'xml';
$format = 'csv';
$models = array('User', 'Phonenumber'); // you can optionally specify an array of the models you wish to import the data for, by default it loads data for all the available loaded models and the data that exists
$models = array('User', 'Phonenumber'); // you can optionally specify an array of the models you wish to import the data for, by default it loads data for all the available loaded models and the data that exists
You can write your fixtures files manually and load them in to your applications. Below is a sample data.yml fixtures file. You can also split your data fixtures file up in to multiple files. Doctrine will read all fixtures files and parse them, then load all data.
You can write your fixtures files manually and load them in to your applications. Below is a sample data.yml fixtures file. You can also split your data fixtures file up in to multiple files. Doctrine will read all fixtures files and parse them, then load all data.
Please see the [doc schema-files :index :name] for the sample models/schema for these example fixtures.
Imagine a schema with the following relationships:
<code type="php">
Resource hasMany Tag as Tags
Resource hasOne ResourceType as Type
ResourceType hasMany Resource as Resources
Tag hasMany Resource as Resources
</code>
<code type="yml">
<code type="yml">
---
---
Adult:
Resource:
Adult_1:
Resource_1:
name: Parent 1
name: Doctrine Video Tutorial
Contact: Contact_1
Type: Video
Car:
Tags: [tutorial, doctrine, help]
Car_1:
Resource_2:
name: Chevorlet Trailblazer
name: Doctrine Cheat Sheet
Car_2:
Type: Image
name: Chevorlet Blazer
Tags: [tutorial, cheat, help]
Car_3:
name: Buick
ResourceType:
Child:
Video:
Child_1:
name: Video
name: Child 1
Image:
Adult: Adult_1
name: Image
Contact:
Contact_1:
Tag:
name: Jonathan H. Wage
tutorial:
Contact_3:
name: tutorial
name: Daniel Adams
doctrine:
Contact_4:
name: doctrine
name: Robert Adams
help:
Dog:
name: help
Dog_1:
cheat:
name: Sam
name: cheat
User: User_1
</code>
Dog_2:
name: Dixie
You could optionally specify the Resources each tag is related to instead of specifying the Tags a Resource has.
User: User_2
Dog_3:
<code type="yml">
name: Chief
Tag:
User: User_3
tutorial:
SelfReference:
name: tutorial
SelfReference_1:
Resources: [Resource_1, Resource_2]
User1: User_1
doctrine:
User2: User_2
name: doctrine
name: Self Reference 1
Resources: [Resource_1]
SelfReference1: SelfReference_2
help:
SelfReference2: SelfReference_3
name: help
SelfReference_2:
Resources: [Resource_1, Resource_2]
User1: User_2
cheat:
User2: User_1
name: cheat
name: Self Reference 2
Resources: [Resource_1]
SelfReference1: SelfReference_1
SelfReference2: SelfReference_1
SelfReference_3:
User1: User_2
User2: User_1
name: Self Reference 3
SelfReference1: SelfReference_3
SelfReference2: SelfReference_3
User:
User_1:
username: jwage
hair_color: light brown
Contact: Contact_1
User_2:
username: dadams
hair_color: dark brown
Contact: Contact_3
User_3:
username: radams
hair_color: light brown
Contact: Contact_4
UserCar:
UserCar_1:
User: User_1
Car: Car_1
UserCar_2:
User: User_2
Car: Car_2
UserCar_3:
User: User_3
Car: Car_3
</code>
</code>
Here is how you would write code to load the data from that data.yml file
Here is how you would write code to load the data from that data.yml file