Download the PHP package dknx01/data-fixtures without Composer

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

DKNX01/Data-fixtures

A PHP package for data fixtures with plain PDO connection.

Requirements

Install

  1. run composer require --dev dknx01/data-fixtures-phpunit

Usage

If you want to use data fixtures in you tests you can do it in multiple ways. You can write a method to fill data in the database. or you can use a fixture and reuse it in multiple tests.

With an existing PDO connection

If you already have a PDO connection you can use it directly.

Create a new PDO connection

Configuration:

The Configuration object has the following parameters:

Parameter Description
pdo An existing PDO connection that will be used
dsn The dsn of the PDO connection
user Databases user, if needed
password Databases users password, if needed
options PDO options that will be used for the connection

Load and execute fixtures

Your class should use the DataFixtureTrait.

If you do not want to use the trait, you can load and execute the fixtures this way:

loadFixtures(int $stackPosition = 1)

This option should be used to define at which stack position the fixtures should be loaded from. Mostly it will be "1" which means directly from the method/class the "loadFixtures" method is called from. If you have more inherited classes, you can change the number.

Writing a fixture

Each fixture must implement the Dknx01\DataFixtures\Contract\FixtureInterface. Example:

As you can see the fixture can have constructor arguments for individual data in different tests.

Data Fixture on method level

Data fixtures can be used on class level (see above) and on method level.

Dependent Fixtures

Fixtures can depend on other fixtures.

Ordered Fixtures

Fixtures can have an order at which position they should load in the fixture loading process.

If a position is added multiple times, the early will move one step ahead of the latest ones.

Example:

This attribute will overwrite the DependFixture attribute!

In this example the FooFixture is loaded at position 0 which means at the beginning of all fixtures.

Faker

As you can see it is possible to use PHPFaker inside a fixture class.

If you implement the FakerAware interface a Faker instance is automatically injected into the data fixture.

Examples

You can see some examples in the directory examples or you can run the script


All versions of data-fixtures with dependencies

PHP Build Version
Package Version
Requires php Version >=8.5
ext-pdo Version *
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 dknx01/data-fixtures contains the following files

Loading the files please wait ...