Download the PHP package anahkiasen/fakable without Composer

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

DEPRECATED

This package is deprecated and will no longer be maintained, I recommend using Factory Muffin instead

Fakable

Allows the creation and seeding of fake Eloquent models. This is a PHP 5.4+ package.

Can be used in tests or to generate batch of fake entries in the seeds.

Installation

Usage

Basic usage

Simply add the trait to a model like this :

A lot of defaults are built-in to configure what gets assigned to what attribute, but you can override or add to this by modifing the $fakable property on your model :

Fakable uses Faker underneath so you can call any of Faker's methods by either simply passing a method name, or an array of ['method', [argument, argument]] as seen above.

From then on you can call multiple methods on the model to generate fake instances :

You can also generate multiple models by calling fakeMultiple(attributes, min, max) :

Advanced usage

To get more control over the flow of your generated fake models you can do this :

This will return a Fakable instance from which you can set various options :

Setting attributes on fake models

You can also set attributes on generated fake models that may not be random :

Attributes fixtures

Instead of setting all your attributes on your models you can also create an attributes fixture to hold them all. This file can be anywhere and can be either a PHP, YAML or JSON file. You tell Fakable where to find it by setting the Fakable\Fakable::$baseFixture variable to its path, in the setup of your seeding per example, or the start of your application.

You can also set a different file for a specific Fakable instance, like this per example:

The file is a simple array [class => attributes] like this:

Relationships

Fakable will also seed relationships when possible. Most of the time this is a completely automatic process, you simply add the name of the relationship to the fakable attributes and pass it an empty signature :

Optionally you can pass a number of generated relations to generate by passing a min and/or max :

Do note, this currently doesn't work for Has-type relations : Fakable can only seed from the point of the receiver (ie Belongs-type relations).

The only relation you really need to configure are morphTo relations because, well, it's a pain to guess their behavior :

Here, relationType will tell Fakable this is a MorphTo relationship, and forModels will indicate it what kind of models Image may be a polymorphic relation of.

By default Fakable will use the attribute name as the foreign key (so illustrable would look for illustrable_type and illustrable_id) but you can also pass a foreignKey to the signature to specify that :


All versions of fakable with dependencies

PHP Build Version
Package Version
Requires php Version >=5.4.0
illuminate/support Version ~4
fzaninotto/faker Version ~1.4
symfony/yaml Version ~2.6
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 anahkiasen/fakable contains the following files

Loading the files please wait ....