Download the PHP package corp-soft/laravel-fixtures without Composer

On this page you can find all versions of the php package corp-soft/laravel-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 laravel-fixtures

Laravel Fixtures Package


Fixtures are used to load a "fake" set of data into a database that can then be used for testing or to help give you some interesting data while you're developing your application.

A fixture may depend on other fixtures, specified via its CorpSoft\Fixture\Fixture::$depends property. When a fixture is being loaded, the fixtures it depends on will be automatically loaded BEFORE the fixture; and when the fixture is being unloaded, the dependent fixtures will be unloaded AFTER the fixture.

Latest Stable Version Total Downloads License Build Status Scrutinizer Code Quality

Installation

The preferred way to install this extension is through composer.

Either run

or add

to the require section of your composer.json file.

Defining a Fixture

To define a fixture, create a new class by extending CorpSoft\Fixture\ActiveFixture.

The following code defines a fixture about the User Illuminate\Database\Eloquent\Model and the corresponding users table.

Tip: Each ActiveFixture is about preparing a DB table for testing purpose. You may specify the table by setting either the CorpSoft\Fixture\ActiveFixture::$table property or the CorpSoft\Fixture\ActiveFixture::$modelClass property. If the latter, the table name will be taken from the Illuminate\Database\Eloquent\Model class specified by modelClass.

The fixture data for an ActiveFixture fixture is usually provided in a file located at public/storage/fixtures/table_name.php. The data file should return an array of data rows to be inserted into the user table. For example:

As we described earlier, a fixture may depend on other fixtures. For example, a UserProfileFixture may need to depends on UserFixture because the user profile table contains a foreign key pointing to the user table. The dependency is specified via the CorpSoft\Fixture\Fixture::$depends property, like the following:

The dependency also ensures, that the fixtures are loaded and unloaded in a well defined order. In the above example UserFixture will always be loaded before UserProfileFixture to ensure all foreign key references exist and will be unloaded after UserProfileFixture has been unloaded for the same reason.

Using Fixtures

1) If you are using phpunit to test your code, then you need to add CorpSoft\Fixture\Traits\FixtureTrait to abstract class TestCase in the tests folder as follows:

2) If you are using Laravel Dusk to test your code, then you need to add CorpSoft\Fixture\Traits\FixtureTrait to abstract class DuskTestCase in the tests folder as follows:

After this steps you can define fixtures in your test classes as follows:

The fixtures listed in the fixtures() method will be automatically loaded before a test is executed. And as we described before, when a fixture is being loaded, all its dependent fixtures will be automatically loaded first. In the above example, because UserProfileFixture depends on UserFixture, when running any test method in the test class, two fixtures will be loaded sequentially: UserFixture and UserProfileFixture.


All versions of laravel-fixtures with dependencies

PHP Build Version
Package Version
Requires php Version >=7.1
illuminate/database Version ~5.5
illuminate/support Version ~5.5
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 corp-soft/laravel-fixtures contains the following files

Loading the files please wait ....