Download the PHP package h4cc/alice-fixtures-bundle without Composer

On this page you can find all versions of the php package h4cc/alice-fixtures-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package alice-fixtures-bundle

AliceFixturesBundle

A Symfony2 bundle for flexible usage of nelmio/alice and fzaninotto/Faker in Symfony2.

Build Status Scrutinizer Quality Score Code Coverage SensioLabsInsight

Status

This Bundle should be considered "Work-In-Progress". Every version < 1.0 can and will change. This also means, if you have a fundamental idea for a change, feel free to contribute. Contributions in any form are always welcome!

Introduction

The aim of this bundle is to provide a new way of working with data fixtures detached from the common Doctrine DataFixtures. Loading of fixtures should be decoupled and easy to integrate where needed. This bundle offers loading Fixtures from yaml and php files, also dropping and recreating the ORM Schema. Next to Doctrine/ORM, also Doctrine/MongoDB-ODM is supported for recreating schema and persisting fixtures.

If you are searching for a Bundle that provides a way to integrate Alice with Doctrine DataFixtures, have a look at hautelook/AliceBundle.

This bundle is also capable of recreating the ORM schema. This means all tables managed by Doctrine will be dropped and recreated. A data loss will appear, you have been warned.

Installation

Simply require the bundle by its name with composer:

Follow the 'dev-master' branch for latest dev version. But i recommend to use more stable version tags if available.

After that, add the Bundle to your Kernel, most likely in the "dev" or "test" environment.

Keep in mind, that this bundle is capable of removing whole databases, so be careful when using in production!

Configuration

You can globally configure the Seed for random values, the Locale for Faker and a global flag do_flush, if ORM flushes of entities should be omitted or not.

A custom 'schema_manager' service id can be defined, the Entity or ObjectManagers from Doctrine will be determined by current objects class and mapping.

In case you want to use the default services for either doctrine/orm or doctrine/mongodb-odm, set the "doctrine" value accordingly, which can be either "orm" or "mongodb-odm". This setting will just adjust the service-ids for ManagerRegistry and 'schema_manager' accordingly, if you have not set them on your own.

A simple configuration using a single default manager:

Or you can use many managers:

Check out this command for a always up-to-date configuration reference:

Usage

Fixtures

Fixtures are defined in YAML or PHP Files like nelmio/alice describes it. The two alice default loaders 'Yaml' and 'Base' are already available. If you want to integrate own loaders, patch the Loader Factory service for your needs ('h4cc_alice_fixtures.loader.factory').

Loading the entities from single fixture files can be done with the FixtureManagerInterface::loadFiles(array $files, $type='yaml');. Persisting them can be done with FixtureManagerInterface::persist(array $entities, $drop=false);.

Example:

Fixture Sets

A more advanced way of loading fixtures is using "FixtureSets". Look at it like a fixture configuration object for multiple fixture files and options.

Example:

Commands

There are some commands for loading fixtures included in this bundle. They are also divided in loading plain files or FixtureSets.

By default, all fixture files or sets will share their references. This way a Bundle can reference the fixtures from another bundles.

Example for loading single files using all available options:

Example command for loading the given FixtureSet:

When your FixtureSets are stored at the default path 'DataFixtures/Alice/' and are named ending in ...'Set.php', they can be found automaticaly. Like the fixtures in Doctrine Datafixtures do. To load the default fixture sets, simply execute this command:

The order in which the bundles are loaded is defined by the order in which they are defined in AppKernel. A customization to that can be done using the "order" value in your fixture sets. Default is '1' and lower order values will be taken first.

Example for a Preconfigured FixtureSet:

Such a file has to return a Object with the FixtureSetInterface Interface.

FixtureSets from different Bundles

When using multiple bundles like MyCommonBundle and MyUserBundle, there are a few things to do and know:

Demo Application

There is a Demo Application showing some ways to use this bundle: https://github.com/h4cc/AliceDemo

Feel free to add some more demos if you like.

PHPUnit

If needed, the fixtures can also be loaded in a PHPUnit test. Accessing the needed container in a Symfony2 environment is described here: http://symfony.com/doc/current/book/testing.html#accessing-the-container

Example:

Selenium

This flexible way of handling data fixtures offers a easy way to work with selenium/behat/mink. For example could you create a controller behind a development route, that is called by selenium to ensure a specific dataset.

Adding own Providers for Faker

A provider for Faker can be any class, that has public methods. These methods can be used in the fixture files for own testdata or even calculations. To register a provider, create a service and tag it.

Example:

Adding own Processors for Alice

A alice processor can be used to manipulate a object before and after persisting. To register a own processor, create a service and tag it.

Example:

License

This bundle is licensed under MIT.


All versions of alice-fixtures-bundle with dependencies

PHP Build Version
Package Version
Requires php Version >=5.3.0
nelmio/alice Version ~1.6
doctrine/common Version ~2.1
psr/log Version ~1.0
symfony/finder Version ~2.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package h4cc/alice-fixtures-bundle contains the following files

Loading the files please wait ....