PHPackages                             stats4sd/laravel-sql-views - 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. stats4sd/laravel-sql-views

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

stats4sd/laravel-sql-views
==========================

A small package to help automate the creation and updating of MySQL views within a Laravel project.

v1.2.0(2y ago)88.6k—0%1[3 issues](https://github.com/stats4sd/laravel-sql-views/issues)[2 PRs](https://github.com/stats4sd/laravel-sql-views/pulls)MITPHPCI passing

Since Mar 21Pushed 5mo ago2 watchersCompare

[ Source](https://github.com/stats4sd/laravel-sql-views)[ Packagist](https://packagist.org/packages/stats4sd/laravel-sql-views)[ Docs](https://github.com/stats4sd/laravel-sql-views)[ RSS](/packages/stats4sd-laravel-sql-views/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (7)Dependencies (4)Versions (11)Used By (0)

SqlViews
========

[](#sqlviews)

[![Latest Version on Packagist](https://camo.githubusercontent.com/bde3d62adeaa31aef49e8571baead4e920bf37c90b41e4919a28c1dcdab7f2ed/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f73746174733473642f6c61726176656c2d73716c2d76696577733f7374796c653d666c61742d737175617265)](https://packagist.org/packages/stats4sd/laravel-sql-views)[![Total Downloads](https://camo.githubusercontent.com/504e04e3bad7c89d72897f2efceadd2dfeadbce4eea72120a621c361221e81fe/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f73746174733473642f6c61726176656c2d73716c2d76696577733f7374796c653d666c61742d737175617265)](https://packagist.org/packages/stats4sd/laravel-sql-views)[![StyleCI](https://camo.githubusercontent.com/b5109005a8c13053f0b0976633d3957dd7ea917c15c60af4e61741039108313b/68747470733a2f2f6769746875622e7374796c6563692e696f2f7265706f732f3234383937383432312f736869656c64)](https://github.styleci.io/repos/248978421)

A small package to help automate the creation and updating of MySQL views and procedures.

This package lets you store the query definition for every MySQL view and stored procedure you need within your Laravel codebase, and lets you edit the SQL query strings directly instead of using migration files. This is useful when:

- You regularly create or update SQL views with real data, e.g. as part of a data analysis workflow.
- You have a set of complex queries that would involve you basically writing out the raw query within a migration file anyway.

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

[](#installation)

Via Composer

```
$ composer require stats4sd/laravel-sql-views
```

Usage
-----

[](#usage)

The package includes a single console command `php artisan updatesql`. This command does 2 things:

1. It will create or update the SQL views in your database based on the files within your `database/views` directory. It will create a view for every `.sql` file it finds, using the filename as the view name and the contents as the query definition.
2. It will create or update SQL procedures in your database based on the files within your `database/procedures` directory. It will run all `.sql` files in that directly verbatim. The intention is that you would include scripts to create the required procedures, but in theory you could include any SQL code that you want to run on a regular basis.

To use:

1. Place your query definitions within .sql files inside your `database/views` directory. You need 1 file per view. Do not include the "CREATE OR REPLACE VIEW" segment, just include the query definition itself.
2. Place any additional SQL scripts you want to run, e.g. to create stored procedures, into the `database/procedures` folder.
3. Run the command with `php artisan updatesql`.

It will search the folders recursively, so you can organise your views into subfolders if you wish.

The packge comes with a tiny config file.

```
php artisan vendor:publish --tag=sqlviews.config

```

To disable the automatic creation of either the `database/views` and/or `database/procedures` folder(s) you can add the following `.env` variables :-

```
SQL_VIEWS_REGISTER_VIEWS_FOLDER=false
SQL_VIEWS_REGISTER_PROCEDURES_FOLDER=false

```

Please note that disabling folder creation without a good understanding of this package will cause you issues.

Change log
----------

[](#change-log)

Please see the [changelog](changelog.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [contributing.md](contributing.md) for details and a todolist.

Security
--------

[](#security)

If you discover any security related issues, please email author email instead of using the issue tracker.

Credits
-------

[](#credits)

- \[Dave Mills\]\[\]
- [Stats4SD](https://github.com/stats4sd)

License
-------

[](#license)

MIT license. Please see the [license file](license.md) for more information.

###  Health Score

40

—

FairBetter than 88% of packages

Maintenance42

Moderate activity, may be stable

Popularity30

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 95.8% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~216 days

Recently: every ~266 days

Total

7

Last Release

942d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/2a7ba5ca40fde83339632231db5f6a95522c1de137f0029a338a5d90fa449a46?d=identicon)[dave-mills](/maintainers/dave-mills)

![](https://www.gravatar.com/avatar/e794ce6c1705bd8592bc7eb32dece5eb2dfa9773d695bc418ca0c16e263a132d?d=identicon)[Dan Tang](/maintainers/Dan%20Tang)

---

Top Contributors

[![dave-mills](https://avatars.githubusercontent.com/u/5711101?v=4)](https://github.com/dave-mills "dave-mills (23 commits)")[![vwmoose](https://avatars.githubusercontent.com/u/13658473?v=4)](https://github.com/vwmoose "vwmoose (1 commits)")

---

Tags

laravellaravel-packagephpsqllaravelsql

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/stats4sd-laravel-sql-views/health.svg)

```
[![Health](https://phpackages.com/badges/stats4sd-laravel-sql-views/health.svg)](https://phpackages.com/packages/stats4sd-laravel-sql-views)
```

###  Alternatives

[illuminate/database

The Illuminate Database package.

2.8k52.4M9.3k](/packages/illuminate-database)[rennokki/laravel-eloquent-query-cache

Adding cache on your Laravel Eloquent queries' results is now a breeze.

1.1k4.0M14](/packages/rennokki-laravel-eloquent-query-cache)[mnabialek/laravel-sql-logger

Log SQL queries in Laravel/Lumen framework

158796.3k2](/packages/mnabialek-laravel-sql-logger)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
