Skip to content

Commit ddad143

Browse files
committed
docs: update README.md to include motivation section
1 parent 4f9c2af commit ddad143

File tree

1 file changed

+48
-4
lines changed

1 file changed

+48
-4
lines changed

README.md

Lines changed: 48 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,27 @@
1212
</p>
1313
</div>
1414

15+
## Motivation
16+
17+
Laravel's schema builder and migration system are great for managing tables and
18+
indexes---but offer no built-in support for other SQL entities, such as
19+
(materialized) views, procedures, functions, and triggers.
20+
These often get handled via raw SQL in migrations, making them hard to manage,
21+
prone to unknown conflicts, and difficult to track over time.
22+
23+
`laravel-sql-entities` solves this by offering:
24+
25+
- 📦 Class-based definitions for SQL entities: bringing views, functions, triggers, and more into your application code.
26+
- 🧠 First-class source control: definitions live in PHP files, so you can track changes, review diffs in PRs, and resolve conflicts easily.
27+
- 🧱 Decoupled grammars per database: letting you support multiple drivers (e.g., PostgreSQL) without cluttering your logic with dialect-specific SQL.
28+
- 🔁 Lifecycle hooks: run logic before/after an entity is created or dropped, enabling logging, auditing, or cleanup.
29+
- 🚀 Batch operations: easily create or drop all entities in a single command or lifecycle event.
30+
- 🧪 Testability: because definitions are just code, they’re easy to test, validate, and keep consistent with your schema.
31+
32+
Whether you're managing reporting views, business logic functions, or automation
33+
triggers, this package helps you treat SQL entities like real, versioned parts
34+
of your codebase---no more scattered SQL in migrations!
35+
1536
## Installation
1637

1738
First pull in the package using Composer:
@@ -20,13 +41,33 @@ First pull in the package using Composer:
2041
composer require calebdw/laravel-sql-entities
2142
```
2243

23-
And then publish the package's configuration file:
44+
<!-- And then publish the package's configuration file: -->
45+
<!---->
46+
<!-- ```bash -->
47+
<!-- php artisan vendor:publish --provider="CalebDW\SqlEntities\ServiceProvider" -->
48+
<!-- ``` -->
2449

25-
```bash
26-
php artisan vendor:publish --provider="CalebDW\SqlEntities\ServiceProvider"
50+
The package looks for Entities under `database/entities/` so you will need to add
51+
a namespace to your `composer.json` file, for example:
52+
53+
```diff
54+
{
55+
"autoload": {
56+
"psr-4": {
57+
"App\\": "app/",
58+
+ "Database\\Entities\\": "database/entities/",
59+
"Database\\Factories\\": "database/factories/",
60+
"Database\\Seeders\\": "database/seeders/"
61+
}
62+
}
63+
}
2764
```
2865

29-
## Configuration
66+
> [!NOTE]
67+
> This package looks for any files matching `database/entities` in the application's
68+
> base path. This means it should automatically work for a modular setup.
69+
70+
<!-- ## Configuration -->
3071

3172
## Usage
3273

@@ -39,3 +80,6 @@ Thank you for considering contributing! You can read the contribution guide [her
3980
This is open-sourced software licensed under the [MIT license](LICENSE).
4081

4182
## Alternatives
83+
84+
- [laravel-sql-views](https://github.com/stats4sd/laravel-sql-views)
85+
- [laravel-migration-views](https://github.com/staudenmeir/laravel-migration-views)

0 commit comments

Comments
 (0)