minvws / laravel-sql-exporter
Laravel SQL Exporter
Requires
- php: >=8.1
- laravel/framework: ^10|^11
- nesbot/carbon: ^2.66|^3.0
Requires (Dev)
- orchestra/testbench: ^8.0
- phpstan/phpstan: ^1.10 || ^2.0
- phpunit/phpunit: ^9.5 || ^10.0
- slevomat/coding-standard: ^8.8
- squizlabs/php_codesniffer: ^3.7
- vimeo/psalm: ^5.8
This package is not auto-updated.
Last update: 2025-06-06 07:56:06 UTC
README
This package is a slim package that allows you to export your Laravel database migrations to an SQL file.
Requirements
Before using the package, make sure you have the following requirements:
- PHP 8.1 or higher
- Laravel 10 or higher
- Composer
Installation
Install the package via composer (as a dev dependency):
composer require --dev minvws/laravel-sql-exporter
Usage
After installing the package, you can run the following command to export your migrations to an SQL file:
vendor/bin/sail artisan sql-export migration_description
By default, the laravel migrations are read from the database/migrations
folder of the working directory.
By default, the SQL file will be saved in the database/sql
folder of the working directory.
You can specify the laravel migrations and the output location by adding
the laravelMigrationsPath
or the sqlMigrationsPath
arguments:
vendor/bin/sail artisan sql-export migration_description \ --laravelMigrationsPath=/path/to/laravel/migrations \ --sqlMigrationsPath=/path/to/sql/migrations
Development
To contribute to the development of this package, you can clone the repository and run the following command to install the dependencies:
composer install
A running PostgreSQL database is required to run the tests. To create the database run the following command:
docker run --name laravel-sql-export-test-postgres -v "$(pwd)/tests/fixtures/init.sql:/docker-entrypoint-initdb.d/10-create-testing-database.sql" -e POSTGRES_PASSWORD=password -p 55322:5432 -d postgres || docker start laravel-sql-export-test-postgres || echo "Unable to start Postgres container, it may already be running"
To run the tests, you can use the following command:
vendor/bin/phpunit
To stop and remove the PostgreSQL container after running the tests, you can use:
docker stop laravel-sql-export-test-postgres docker rm laravel-sql-export-test-postgres
Contributing
If you encounter any issues or have suggestions for improvements, please feel free to open an issue or submit a pull request on the GitHub repository of this package.
License
This package is open-source and released under the European Union Public License version 1.2. You are free to use, modify, and distribute the package in accordance with the terms of the license.
Part of iCore
This package is part of the iCore project.