staudenmeir/laravel-migration-views
Larablocks Analysis
Compatibility
Trusted maintainerstaudenmeir/laravel-migration-views works with Laravel 13 (latest release v1.12, Feb 28, 2026).
Laravel 5 to 12 in earlier releases.
- Trusted maintainer: staudenmeir publishes 15 packages on Larablocks, with 5,145,651 downloads a month between them.
Recommendation checks
RecommendedRecommended by Larablocks: meets all 4 checks.
- Works with Laravel 13, the current version
- Released in the last 12 months (Feb 28, 2026)
- 96,899 downloads a month (at least 10,000)
- 226 GitHub stars (at least 100)
State
Maintained- Last stable release: Feb 28, 2026.
- 1 release in the last 12 months.
- First released: Jun 15, 2019.
- Monthly downloads: 96,899, up 116% from six months ago.
- 0 open issues on GitHub.
Data from Packagist and GitHub, checked by Larablocks on Nov 30, 2026.
| Install | |
|---|---|
composer require staudenmeir/laravel-migration-views |
|
| Latest Version: | v1.12 |
| PHP: | ^8.2 |
| Laravel: | 13 |
| Older releases: | 5 – 12 |
| License: | MIT |
| Last Updated: | Mar 1, 2026 |
| Links: | GitHub · Packagist |
Laravel Migration Views
This Laravel extension adds support for SQL views in database migrations.
Supports Laravel 5.5+.
Installation
composer require staudenmeir/laravel-migration-views:"^1.0"
Use this command if you are in PowerShell on Windows (e.g. in VS Code):
composer require staudenmeir/laravel-migration-views:"^^^^1.0"
Versions
| Laravel | Package |
|---|---|
| 13.x | 1.12 |
| 12.x | 1.11 |
| 11.x | 1.9 |
| 10.x | 1.7 |
| 9.x | 1.6 |
| 8.x | 1.5 |
| 7.x | 1.4 |
| 6.x | 1.2 |
| 5.8 | 1.1 |
| 5.5–5.7 | 1.0 |
Usage
- Creating Views
- Renaming Views
- Dropping Views
- Checking For View Existence
- Listing View Columns
- Materialized Views
Creating Views
Use createView() to create a view and provide a query builder instance or an SQL string:
use Staudenmeir\LaravelMigrationViews\Facades\Schema;
$query = DB::table('users')->where('active', true);
Schema::createView('active_users', $query);
You can provide the view's columns as the third argument:
use Staudenmeir\LaravelMigrationViews\Facades\Schema;
$query = 'select id from users where active = 1';
Schema::createView('active_users', $query, ['key']);
Use createOrReplaceView() to create a view or replace the existing one:
use Staudenmeir\LaravelMigrationViews\Facades\Schema;
$query = DB::table('users')->where('active', true);
Schema::createOrReplaceView('active_users', $query);
View Processing Algorithm
On MySQL and MariaDB, you can specify the view processing algorithm:
use Staudenmeir\LaravelMigrationViews\Facades\Schema;
$query = DB::table('users')->where('active', true);
Schema::createView('active_users', $query, algorithm: 'TEMPTABLE');
Renaming Views
Use renameView() to rename a view:
use Staudenmeir\LaravelMigrationViews\Facades\Schema;
Schema::renameView('active_users', 'users_active');
Dropping Views
Use dropView() or dropViewIfExists() to drop a view:
use Staudenmeir\LaravelMigrationViews\Facades\Schema;
Schema::dropView('active_users');
Schema::dropViewIfExists('active_users');
If you are using php artisan migrate:fresh, you can drop all views with --drop-views (Laravel 5.6.26+).
Checking For View Existence
Use hasView() to check whether a view exists:
use Staudenmeir\LaravelMigrationViews\Facades\Schema;
if (Schema::hasView('active_users')) {
//
}
Listing View Columns
Use getViewColumnListing() to get the column listing for a view:
use Staudenmeir\LaravelMigrationViews\Facades\Schema;
$columns = Schema::getViewColumnListing('active_users');
Materialized Views
On PostgreSQL, you can create a materialized view with createMaterializedView():
use Staudenmeir\LaravelMigrationViews\Facades\Schema;
$query = DB::table('users')->where('active', true);
Schema::createMaterializedView('active_users', $query);
Use refreshMaterializedView() to refresh a materialized view:
Schema::refreshMaterializedView('active_users');
Use dropMaterializedView() or dropMaterializedViewIfExists() to drop a materialized view:
Schema::dropMaterializedView('active_users');
Schema::dropMaterializedViewIfExists('active_users');
Use hasMaterializedView() to check whether a materialized view exists:
if (Schema::hasMaterializedView('active_users')) {
//
}
Contributing
Please see CONTRIBUTING and CODE OF CONDUCT for details.
Related Packages
Powerful PHP database abstraction layer (DBAL) with many features for database s...
Laravel Serializable Closure provides an easy and secure way to serialize closur...
Cli error handling for console/command-line PHP applications.
Version History
| Version | Released | PHP | Laravel | License |
|---|---|---|---|---|
| v1.12 | ^8.2 | ^13.0 | MIT | |
| v1.11.1 | ^8.2 | ^12.0 | MIT | |
| v1.11 | ^8.2 | ^12.0 | MIT | |
| v1.10.1 | ^8.2 | ^11.0 | MIT | |
| v1.10 | ^8.2 | ^11.0 | MIT | |
| v1.9.1 | ^8.2 | ^11.0 | MIT | |
| v1.9 | ^8.2 | ^11.0 | MIT | |
| v1.8 | ^8.1 | ^10.0 | MIT | |
| v1.7 | ^8.1 | ^10.0 | MIT | |
| v1.6.3 | ^8.0.2 | ^9.0 | MIT | |
| v1.6.2 | ^8.0.2 | ^9.0 | MIT | |
| v1.6.1 | ^8.0.2 | ^9.0 | MIT | |
| v1.6 | ^8.0.2 | ^9.0 | MIT | |
| v1.5.1 | ^7.3| | ^8.0 | MIT | |
| v1.5 | ^7.3 | ^8.0 | MIT | |
| v1.4 | ^7.2.5 | ^7.0 | MIT | |
| v1.3.1 | ^7.2 | ^6.0 | MIT | |
| v1.3 | ^7.2 | ^6.0 | MIT | |
| v1.2 | ^7.2 | ^6.0 | MIT | |
| v1.1 | ^7.1.3 | ~5.8.1 | MIT | |
| v1.0 | >=7.0 | ~5.5.25| | MIT |