Development

ref/DirFixtures

You must first sign up to be able to contribute.

fixtures

Fixtures are data that's loaded into the model (and ultimately the database) to initialize the state of the project. Some fixtures are to initialize the project itself. Others are used to set up test cases.

Locations

/<projname>/data/fixtures
/<projname>/test/fixtures

Contents

Depending on whether you are using Propel or Doctrine, you may need to organize your fixtures differently. They are Yaml versions of data. They need to contain data appropriate for their model definitions. The top level is the entity name, each level below that is a named instance. Named instances can be references elsewhere via their name. A subset of php can be used to pre-process these files, allowing you to populate large data sets.

Propel (currently) requires the reference data to be defined before it's referenced. So, file names beginning numerically is commonly seen.

Examples

data from a fixture file from from Jobeet(Doctrine):

JobeetJob:
  job_sensio_labs:
    JobeetCategory: programming
    type:         full-time
    company:      Sensio Labs
    logo:         /uploads/jobs/sensio_labs.png
    url:          http://www.sensiolabs.com/
    position:     Web Developer
    location:     Paris, France
    description:  |
      You've already developed websites with symfony and you want to work
      with Open-Source technologies. You have a minimum of 3 years
      experience in web development with PHP or Java and you wish to
      participate to development of Web 2.0 sites using the best
      frameworks available.
    how_to_apply: |
      Send your resume to fabien.potencier [at] sensio.com
    is_public:    true
    is_activated: true
    token:        job_sensio_labs
    email:        job@example.com
    expires_at:   '2008-12-25'

References