PHPackages                             beneaththesurfacelabs/universal-factory - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. beneaththesurfacelabs/universal-factory

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

beneaththesurfacelabs/universal-factory
=======================================

Laravel-style Factories for non-Eloquent classes

v1.2.3-beta(10mo ago)059[4 PRs](https://github.com/BeneathTheSurfaceLabs/universal-factory/pulls)MITPHPPHP ^8.2CI passing

Since Sep 23Pushed 1mo agoCompare

[ Source](https://github.com/BeneathTheSurfaceLabs/universal-factory)[ Packagist](https://packagist.org/packages/beneaththesurfacelabs/universal-factory)[ Docs](https://github.com/beneaththesurfacelabs/universal-factory)[ GitHub Sponsors](https://github.com/BeneathTheSurfaceLabs)[ RSS](/packages/beneaththesurfacelabs-universal-factory/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (6)Dependencies (12)Versions (14)Used By (0)

Universal Factories
===================

[](#universal-factories)

[![Latest Version on Packagist](https://camo.githubusercontent.com/b0aaad768d300af5be138dd3025937c47f17882ef66e73ae4c4f657f507d0565/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f62656e65617468746865737572666163656c6162732f756e6976657273616c2d666163746f72792e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/beneaththesurfacelabs/universal-factory)[![GitHub Tests Action Status](https://camo.githubusercontent.com/bdbed7ffd3ae562ce93353df331dd7c099fd2b903d37a3f7e3c2aa1d8eb0738d/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f62656e65617468746865737572666163656c6162732f756e6976657273616c2d666163746f72792f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/beneaththesurfacelabs/universal-factory/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/4cc458d3d8070a2a3f60e74405a3babb8f2ea00d04b1a1534c3c0ffb30a12c2e/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f62656e65617468746865737572666163656c6162732f756e6976657273616c2d666163746f72792f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/beneaththesurfacelabs/universal-factory/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/76f657f167a5a274c17d9ea1aea21510903adbe20ec54cfb001ff4feb3b273f4/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f62656e65617468746865737572666163656c6162732f756e6976657273616c2d666163746f72792e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/beneaththesurfacelabs/universal-factory)

[![](https://private-user-images.githubusercontent.com/3959529/369756388-171406c4-db0a-473c-850b-05538d92474a.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NzU2NzA0NzQsIm5iZiI6MTc3NTY3MDE3NCwicGF0aCI6Ii8zOTU5NTI5LzM2OTc1NjM4OC0xNzE0MDZjNC1kYjBhLTQ3M2MtODUwYi0wNTUzOGQ5MjQ3NGEucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI2MDQwOCUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNjA0MDhUMTc0MjU0WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9ODVkZmI5MjI3MDlkNzgyNGQ1MzlkNzI4NTg3ZjAwZjQwMjM4OGI4MGUxNmFlOWFhMDA3MmJlNjNiNzYxYzFhMyZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.ymC9TxbEyjCwANYyX5OpOP9ewVvYD2hhLKgsyGzkYQ8)](https://private-user-images.githubusercontent.com/3959529/369756388-171406c4-db0a-473c-850b-05538d92474a.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NzU2NzA0NzQsIm5iZiI6MTc3NTY3MDE3NCwicGF0aCI6Ii8zOTU5NTI5LzM2OTc1NjM4OC0xNzE0MDZjNC1kYjBhLTQ3M2MtODUwYi0wNTUzOGQ5MjQ3NGEucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI2MDQwOCUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNjA0MDhUMTc0MjU0WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9ODVkZmI5MjI3MDlkNzgyNGQ1MzlkNzI4NTg3ZjAwZjQwMjM4OGI4MGUxNmFlOWFhMDA3MmJlNjNiNzYxYzFhMyZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.ymC9TxbEyjCwANYyX5OpOP9ewVvYD2hhLKgsyGzkYQ8)

Create Laravel-style Factory classes to quickly generate test data within your applications

Why?
----

[](#why)

Laravel's existing factory implementation is truly amazing, but has become increasingly coupled to Eloquent models over the years.

Prior to these changes, it was possible to use Laravel Factories for many different kinds of data, including things like DTOs, FormRequests, etc.

In order to restore this ability, we can use this package to complement Laravel's existing Eloquent Factories.

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require beneaththesurfacelabs/universal-factory
```

You can publish the config file with:

```
php artisan vendor:publish --tag="universal-factory-config"
```

This is the contents of the published config file:

```
