PHPackages                             moataz27/schema-object-manager - 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. moataz27/schema-object-manager

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

moataz27/schema-object-manager
==============================

Manage database views, procedures, functions and triggers without migrations

v1.0.3(1mo ago)018MITPHPPHP ^8.3

Since Dec 23Pushed 1mo agoCompare

[ Source](https://github.com/Moataz27/schema-object-manager)[ Packagist](https://packagist.org/packages/moataz27/schema-object-manager)[ RSS](/packages/moataz27-schema-object-manager/feed)WikiDiscussions main Synced today

READMEChangelogDependencies (6)Versions (5)Used By (0)

Schema Object Manager
=====================

[](#schema-object-manager)

A Laravel package to manage database schema objects (Views, Procedures, Functions, Triggers) as code. This package allows you to version control your database logic and sync it easily across different environments using Artisan commands, similar to how Laravel Migrations manage your tables.

Features
--------

[](#features)

- **Manage Database Objects**: First-class support for Views, Stored Procedures, Functions, and Triggers.
- **Version Control**: Keep your database logic in your codebase, not hidden in the database.
- **Auto-Discovery**: Automatically finds and registers your schema object classes.
- **Safe Syncing**: Prevents accidental overwrites in production environments (requires `--force`).
- **Artisan Integration**: Simple commands to create and sync your objects.

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

[](#installation)

You can install the package via composer:

```
composer require moataz/schema-object-manager
```

### Publish Configuration (Optional)

[](#publish-configuration-optional)

You can publish the configuration file to customize the namespace and other settings:

```
php artisan vendor:publish --tag="schema-objects"
```

This will create a `config/schema-objects.php` file where you can configure the namespace for your schema objects and toggle auto-discovery.

Usage
-----

[](#usage)

### Creating Schema Objects

[](#creating-schema-objects)

The package provides Artisan commands to generate boilerplate classes for your schema objects. By default, these are created in `App\SchemaObjects`.

**Create a View:**

```
php artisan schema:view UserStatsView
```

**Create a Stored Procedure:**

```
php artisan schema:procedure CalculatMonthlyRevenue
```

**Create a Function:**

```
php artisan schema:function GetUserAge
```

**Create a Trigger:**

```
php artisan schema:trigger BeforeUserUpdate
```

### Defining Your Object

[](#defining-your-object)

Once created, you can define the logic in the generated class. Here is an example of a View:

```
