Download the PHP package sizuhiko/fabricate without Composer

On this page you can find all versions of the php package sizuhiko/fabricate. 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 fabricate

Build Status Coverage Status Total Downloads Latest Stable Version

Fabricate

PHP data generator for Testing

It's inspired on Fabrication and factory-girl from the Ruby world.

Fabricate is a simple fake object generation core library for PHP. Quickly Fabricate objects as needed anywhere in your app or test case.

If you use CakePHP2, please see cakephp2 branch.

Install

Add require-dev in your composer.json

composer require --dev sizuhiko/fabricate

Usage

Adaptor

At first, Fabricate require to config for using. For example, to override these settings, put a bootstrap.php in your app folder and append the path to phpunit.xml

Fabricate doesn't provide adaptors. If you will make adaptor of any frameworks, send us your pull request. The pull request will include suggestion into composer.json and link of repository on README(Comunity Adaptors).

Comunity Adaptors

The Basics

The simplest way to generate objects

That will generate and save to database an instance of Post using the schema information.

To set additional attributes or override what is in the Fabricator, you can pass a array to Fabricate with the fields you want to set.

Fabricating With Blocks

In addition to the array, you can pass a callback function to Fabricate and all the features of a Fabricator definition are available to you at object generation time.

The hash will overwrite any fields defined in the callback function.

APIs

Configuration

To override these settings, put a bootstrap.php in your app folder and append the path to phpunit.xml

Supported Options

sequence_start

Allows you to specify the default starting number for all sequences. This can still be overridden for specific sequences.

Default: 1

adaptor

Adapters ease the population of databases through the Database accessor provided by an ORM library(or framework).

Default: null

faker

Allow you to specify the default Faker instance to return localized data.

Default: default locale(en_EN) instance

text_size_limit

Allow you to specify the limit size for generation of text field.

Default: 200

from v1.2.3

Generate model attributes as array (not saved)

Fabricate::attributes_for(:model_name, :number_of_generation, :array_or_callback) generate only attributes.

Example

Generate a model instance (not saved)

Fabricate::build(:model_name, :array_or_callback) generate a model instance (using ClassRegistry::init).

Example

Generate records to database

Fabricate::create(:model_name, :number_of_generation, :array_or_callback) generate and save records to database.

Example

Defining

Fabricate has a name and a set of attributes when fabricating objects. The name is used to guess the class of the object by default,

To use a different name from the class, you must specify 'class'=>:class_name into first argument as array.

You can inherit attributes from other defined set of attributes by using the 'parent' key.

Associations

It's possible to set up associations(hasOne/hasMany/belongsTo) within Fabricate::create(). You can also specify a FabricateContext::association(). It will generate the attributes, and set(merge) it in the current array.

Usage

Sequences

A sequence allows you to get a series of numbers unique within the each generation function. Fabrication provides you with an easy and flexible means for keeping track of sequences.

Config

Allows you to specify the default starting number for all sequences. This can still be overridden for specific sequences.

Usage

If you want use sequence within generation function, callback has second attribute. $world is FabricateContext instance. It have sequence method.

FabricateContext#sequence API

You should set name argument to sequence.

If you want to specify the starting number, you can do it with a second parameter. It will always return the seed number on the first call and it will be ignored with subsequent calls.

If you are generating something like an unique string, you can pass it a callback function and the callback function response will be returned.

Traits

Traits allow you to group attributes together and then apply them to any fabricating objects.

traits can specify defined names as array

Faker

Faker is a PHP library that generates fake data for you. Fabrication provides you with generation custom value for own rule.

Config

Faker supports a localization. The default locale is en_EN. Allows you to specify the locale. This can still be overridden for specific Faker Factory.

Usage

Reloading

If you need to reset fabricate back to its original state after it has been loaded.

Contributing to this Library

Please feel free to contribute to the library with new issues, requests, unit tests and code fixes or new features. If you want to contribute some code, create a feature branch from develop, and send us your pull request.


All versions of fabricate with dependencies

PHP Build Version
Package Version
Requires fzaninotto/faker Version ~1.4
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 sizuhiko/fabricate contains the following files

Loading the files please wait ....