PHPackages                             nickwelsh/eloquent-zero - 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. [Database &amp; ORM](/categories/database)
4. /
5. nickwelsh/eloquent-zero

ActiveLibrary[Database &amp; ORM](/categories/database)

nickwelsh/eloquent-zero
=======================

Generate Zero schemas from Eloquent Models

07

Since Jun 22Compare

[ Source](https://github.com/nickwelsh/eloquent-zero)[ Packagist](https://packagist.org/packages/nickwelsh/eloquent-zero)[ RSS](/packages/nickwelsh-eloquent-zero/feed)WikiDiscussions Synced 3w ago

READMEChangelogDependenciesVersions (1)Used By (0)

Generate Zero schemas from Eloquent Models
==========================================

[](#generate-zero-schemas-from-eloquent-models)

[![Latest Version on Packagist](https://camo.githubusercontent.com/0d7d5e7681be782d25372f3357b67f1fd8054414b1bcb5dc92b0a007d52db695/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6e69636b77656c73682f656c6f7175656e742d7a65726f2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/nickwelsh/eloquent-zero)[![GitHub Tests Action Status](https://camo.githubusercontent.com/894548b2e6a3f566d06dd06b25de87a9a75831f3668e58248d7f75761dfcc80f/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6e69636b77656c73682f656c6f7175656e742d7a65726f2f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/nickwelsh/eloquent-zero/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/15f682290e329e8340c408783f30cb785a558d4d0bd33f3b24a6d7801f4f2d0e/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6e69636b77656c73682f656c6f7175656e742d7a65726f2f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/nickwelsh/eloquent-zero/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/7d19872be715908379a2676c7343e808742aadca3d5ffb544fea93e226838d94/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6e69636b77656c73682f656c6f7175656e742d7a65726f2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/nickwelsh/eloquent-zero)

`eloquent-zero` generates a typed [Zero](https://zero.rocicorp.dev/) schema from your Laravel Eloquent models and Postgres database.

It reads your models, database columns, primary keys, enum types, and Eloquent relationships, then writes a `schema.ts` file ready for Zero. It can also sync a Postgres publication for those models.

> Warning This package is very early. Expect rough edges, missing features, and breaking changes.

What it does
------------

[](#what-it-does)

- generates Zero tables from Eloquent models
- maps `belongsTo`, `hasOne`, `hasMany`, and `belongsToMany` relationships
- respects model hidden fields and column allowlists
- syncs Postgres publication column lists from model metadata
- supports renaming the emitted Zero schema with a PHP attribute
- validates that migrations are current before generating

Requirements
------------

[](#requirements)

- PHP 8.4+
- Laravel 11+
- PostgreSQL

`eloquent-zero` currently only supports Postgres connections.

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

[](#installation)

You can install the package via composer:

```
composer require nickwelsh/eloquent-zero:dev-main
```

You can publish and run the migrations with:

```
php artisan vendor:publish --tag="eloquent-zero-migrations"
php artisan migrate
```

You can publish the config file with:

```
php artisan vendor:publish --tag="eloquent-zero-config"
```

Published config:

```
