Download the PHP package joshbonnick/filament-faker without Composer

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

Filament Faker

Filament Testing Utility Library

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

Filament Faker is a utility library designed to streamline writing testing that use Filament resources, forms, blocks, and components content. This library assists in automatically generating mock data for your tests within the Filament ecosystem.

Features and Usage Highlights

Contents

Requirements

Installation

You can install the package via composer:

You can publish the config file with:

Usage

Call the fake method on a resource to retrieve an array of fields filled with fake data.

Generated Data Example

Usage In Tests

You can use the faked data in your tests.

Faking Custom & Plugin Components

If you have added a plugin such as Spatie Media Library, which adds the SpatieMediaLibraryFileUpload component you can register it in config/filament-faker.php like so:

If you do not register extra components, the default callback will be used which returns the result of fake()->sentence().

You may also override the default faker method attached to built in components by adding them to the config.

Mutating Generated Data

If you need to control a specific components value, you can chain mutateFake onto the fake builder. If this method returns null for a component then it will be ignored and filled by other methods.

Mutate Method As Method

Alternatively you can add a mutateFake method to your Form, Block or Resource.

The closure passed to mutateFake supports dependency injection, you just need to type hint \Filament\Forms\Components\Field or the specific component type (e.g. \Filament\Forms\Components\TextInput) to get an instance of the component.

Disabling Generations From Component Names

By default, component names are used to map to a Faker method for more accurate data. There are several ways to disable this behavior:

Set use_component_names_for_fake to false in config/filament-faker.php which will disable the behavior for the entire package as default.

You can chain shouldFakeUsingComponentName on the Faker API to disable the feature per test.

Generate Data Using Factory Definitions

If you need increased accuracy for a specific test then you can enable the usage of Factories. When the use of factories is enabled the generated data will be generated using definitions from the factory provided.

If no factory is provided the package will attempt to resolve one from the given resource, form, component or block.

As this feature executes Factory::makeOne under the hood, I recommend only using it in tests where the accuracy of the faked data is of significant importance.

If you need to specify a factory you can pass a class-string or instance of a Factory to the withFactory() method.

Only Resources can resolve a factory automatically, if you wish to use a factory with a Block or Component, you must provide either the factory to withFactory or provide the model to the Component, Form or Block.

Selecting Definitions

If you want to select only a specific set of definitions from your factory you can pass an array as to the withFactory() method which lists the definitions you want you use.

Generate Data for Specific Fields

If you only need a specific field or fields, you can specify them with the onlyFields method on Resource and Form fakers.

IDE Support

As this package adds methods using Laravel's Macroable trait, your IDE will not find the methods on its own. To fix this you will need to use the ide-helper package.

Changelog

Please see CHANGELOG for more information on what has changed recently.

Credits

License

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


All versions of filament-faker with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
filament/filament Version ^3.2
illuminate/contracts Version ^10.0|^11.0
illuminate/support Version ^10.0|^11.0
livewire/livewire Version ^3.0
spatie/laravel-package-tools Version ^1.14.0
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 joshbonnick/filament-faker contains the following files

Loading the files please wait ....