Download the PHP package noj/fabrica without Composer

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

Fabrica

Travis (.com) Latest Stable Version PHP Version Support GitHub Total Downloads

Fabrica handles the definition and creation of objects for use in testing.

Coupled with its Doctrine integration, Fabrica allows you to fully test CRUD logic without mocking. See the What Problem Does it Solve? page for a full explanation.


Installing

Usage

Setup

First initialise Fabrica somewhere within your test suite. For PHPUnit, this can be done using the bootstrap option:

Basic Usage

Assuming that you have a User entity, create a new factory factories/UserFactory.php:

Now within your test, you can create a new User instance:

Setters

If your entity's properties are only accessible through setters then you can use the @ syntax to call methods instead:

Given that a value is an array, you can indicate that you wish the method to be called for each item using the multiple times suffix (*):

Overrides

You can override any default values when creating your entity:

Create Multiple

You can create multiple entities like so:

Relations

You can automatically create related entities. For example, if you have Comment entity that belongs to a User then you can define a factory:

Whenever a Comment is created it will have an associated User:

You can also define the inverse side of the relation. For example, you can define that each created User should have an associated Comment:

You can create multiple child relations:

Will create a User with 3 Comments.

If the entity has a property that depends on the relation then you can define this like so:

Overriding Relation Properties

You can also override properties of nested relations when creating an entity:

For a single entity of a one-to-many relation:

Or even every entity:

Entity Types

Rather than always having to pass overrides when creating entities, you can define different types of entities:

Extending

If a sub-type shares attributes with the parent-type then you can specify that the factory extends from it:

You can also extend from a sub-type:

Doctrine Integration

Fabrica ships with a Doctrine adapter that will automatically persist your entities on creation. Simply configure the store in your bootstrap file:

Where the EntityManager comes from and how it is configured may depend on your application.

Fabrica provides a simple way of creating an annotation backed EntityManager using in-memory SQLite if that meets your requirements:

Refreshing the Database Between Tests

Most likely you will want to reset the state of your database before each test runs. There are 2 ways of doing this:

PHPUnit Assertions

Fabrica ships with a set of PHPUnit assertions for validating the state of the database during a test.

This provides the following assertions:

Note: If you are using NeedsDatabase described above then the assertions are already included.

Example usage:

Faker Integration

Fabrica can be configured with a faker instance to help generate fake data in your entity definitions.

You will then receive the faker instance in the define callback:

Inspirations


All versions of fabrica with dependencies

PHP Build Version
Package Version
Requires php Version ^7.0|^8.0
noj/dot Version ^1.0.1
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 noj/fabrica contains the following files

Loading the files please wait ....