Download the PHP package directorytree/dummy without Composer

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

Generate PHP class instances populated with dummy data using Faker


Index

Requirements

Installation

You can install the package via composer:

Introduction

Consider you have a class representing a restaurant reservation:

To make dummy instances of this class during testing, you have to manually populate it with dummy data.

This can quickly get out of hand as your class grows, and you may find yourself writing the same dummy data generation code over and over again.

Dummy provides you with a simple way to generate dummy instances of your classes using a simple API:

Setup

Dummy provides you two different ways to generate classes with dummy data.

HasFactory Trait

The HasFactory trait is applied directly to the class you would like to generate dummy instances of.

To use the HasFactory trait, you must implement the toFactoryInstance and getFactoryDefinition methods:

[!note] The HasFactory trait does not provide you the capability of defining state methods or callbacks. If you need this functionality, you should define a separate Factory class instead.

Once implemented, you may call the Reservation::factory() method to create a new dummy factory:

Class Factory

If you need more control over the dummy data generation process, you may use the Factory class.

The Factory class is used to generate dummy instances of a class using a separate factory class definition.

To use the Factory class, you must extend it with your own and override the definition and generate methods:

Usage

Once you've defined a factory, you can generate dummy instances of your class using the make method:

To add or override attributes in your definition, you may pass an array of attributes to the make method:

To generate multiple instances of the class, you may use the count method:

This will return a Illuminate\SupportCollection instance containing the generated classes.

Factory States

State manipulation methods allow you to define discrete modifications that can be applied to your dummy factories in any combination.

For example, your App\Factories\Reservation factory might contain a tomorrow state method that modifies one of its default attribute values:

Factory Callbacks

Factory callbacks are registered using the afterMaking method and allow you to perform additional tasks after making or creating a class. You should register these callbacks by defining a configure method on your factory class. This method will be automatically called when the factory is instantiated:

Factory Sequences

Sometimes you may wish to alternate the value of a given attribute for each generated class.

You may accomplish this by defining a state transformation as a sequence:

Factory Collections

By default, when making more than one dummy class, an instance of Illuminate\Support\Collection will be returned.

If you need to customize the collection of classes generated by a factory, you may override the collect method:


All versions of dummy with dependencies

PHP Build Version
Package Version
No informations.
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 directorytree/dummy contains the following files

Loading the files please wait ....