Download the PHP package chustilla/cakephp-model-factory without Composer

On this page you can find all versions of the php package chustilla/cakephp-model-factory. 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 cakephp-model-factory

cakephp-model-factory

An easy for rapid creation of models for the purpose of testing, inspired by Laravel Model Factory.

Requirements

Installation

Via Composer

Usage

Define factories

Through model definition you will tell to the factory how to populate the entity with data.

An example of model definition would be...

That is an unusual model definition because it would create all entity instances with the same data. Usually you need compute data or use Faker library for fake data, in that case you can use a Closure for defining model attributes

Load model definitions

For creating models from its definitions you need to load those definitions. A good place for loading the models definitions could be the tests bootstrap file, by specifying the models definitions directory path.

Creating models

For an easy model creation the library provides the factory() helper

That will create a full populate entity and save it in the datasource defined for testing. If you don't need to persist the data you can use the make() method

You may also create an array of may models by passing the number of models to the helper

Override model definition data

By passing an array of attributes to create() or make() functions you can override the data filled by the model definition

States

By states, you can define discrete modifications to the model attributes.

As for definitions you can define state attributes by a Closure or a simple array

Apply states during the model building in the bellow way. States combination is allowed.

Deleting models

For ensuring tests isolation is very important to remove the models stored by each test. The library provides a trait which will do it for you.

License

The MIT License (MIT). Please see License File for more information.


All versions of cakephp-model-factory with dependencies

PHP Build Version
Package Version
Requires league/factory-muffin Version ~2.0
symfony/finder Version >=4.0
cakephp/cakephp Version ~3.7
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 chustilla/cakephp-model-factory contains the following files

Loading the files please wait ....