Download the PHP package guidocella/eloquent-populator without Composer

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

Eloquent Populator

This package provides default attributes for Laravel model factories by guessing the best Faker formatters from columns' names and types. For example, if a column is called first_name, it will use $faker->firstName(). If unable to guess by the column's name, it will guess the formatter by the column's type; for example, it will use $faker->text() for a VARCHAR column, or a Carbon instance for a TIMESTAMP. Models of BelongsTo relationships that have been defined are created as well. Furthermore, if you use the Multilingual package, for translatable attributes Populator will generate arrays with a different value for each configured locale.

Compared to packages that generate factories once, you generally don't have to update your factories as you change their table definitions and they will be very small.

Installation

Install the package with Composer:

Model factory integration

Call Populator::guessFormatters($this->modelName()) in your factories' definition methods to get an array with the guessed formatters. You may merge these with custom attributes whose guessed formatter isn't accurate.

If you execute php artisan stub:publish, you can include the call to Populator in factory.stub so that php artisan make:factory will add it.

After guessing a model's formatters once, they are cached in a static property even across different tests.

Seeding

Before seeding your database you'll want to call setSeeding().

Its effect is that nullable columns will have a 50% chance of being set to null or to the guessed formatter.

Testing

If setSeeding() wasn't called nullable columns will always be set to their guessed formatter. The idea is to simplify tests such as this:

On the other hand, seeding the database with null attributes lets you notice Trying to get property of non-object errors.


All versions of eloquent-populator with dependencies

PHP Build Version
Package Version
Requires illuminate/database Version ^11
fakerphp/faker Version ^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 guidocella/eloquent-populator contains the following files

Loading the files please wait ....