laravel-toolkit/laravel-db-seeder-export
Composer 安装命令:
composer require laravel-toolkit/laravel-db-seeder-export
包简介
Export Laravel database tables to seeders with Telegram and email backup functionality
README 文档
README
A Laravel package to export database tables into Laravel Seeder classes with support for Telegram notifications and email alerts.
Features
- Export database tables to Laravel Seeder classes
- Automatic dependency detection between tables
- Support for multiple database types (MySQL, PostgreSQL, SQLite, SQL Server)
- Schema-aware seeders that can adapt to column changes
- Telegram notifications with file attachments
- Email notifications with detailed statistics
- Advanced filtering options to include/exclude tables
- JSON output for API integrations
- Comprehensive stats and reporting
Installation
You can install the package via composer:
composer require laravel-toolkit/laravel-db-seeder-export
Publishing Configuration
php artisan vendor:publish --tag=db-seeder-export-config
This will publish the configuration file to config/db-seeder-export.php.
To publish the email templates:
php artisan vendor:publish --tag=db-seeder-export-views
Usage
Basic Usage
Export all tables:
php artisan db:export-seeder --all
Export specific tables:
php artisan db:export-seeder users posts comments
Options
| Option | Description |
|---|---|
--all |
Export all tables in the database |
--disable-foreign-keys |
Temporarily disable foreign key constraints during seeding |
--exclude=table1,table2 |
Tables to exclude from export |
--exclude-pattern=pattern1,pattern2 |
Exclude tables matching these patterns (e.g., "telescope_,log_") |
--include-migrations |
Include the migrations table which is excluded by default |
--schema-aware |
Create schema-aware seeders that can adapt to column changes |
--telegram |
Send the backup to Telegram |
--delete-after-send |
Delete the backup files after sending to Telegram |
--output-json |
Format output as JSON (useful for API calls) |
--notify-email=email1,email2 |
Send email notification to these addresses |
--skip-empty-tables |
Skip tables that have no data |
--storage-disk=diskname |
Specify storage disk to save backup (default: local) |
--max-execution-time=seconds |
Set maximum execution time in seconds |
Configuration
You can configure the package by editing the config/db-seeder-export.php file or by setting environment variables in your .env file:
# General Settings DB_SEEDER_SCHEMA_AWARE=true DB_SEEDER_DISABLE_FK=true DB_SEEDER_SKIP_EMPTY=false DB_SEEDER_MAX_EXECUTION_TIME=300 DB_SEEDER_STORAGE_DISK=local # Telegram Configuration DB_SEEDER_TELEGRAM_ENABLED=true DB_SEEDER_TELEGRAM_BOT_TOKEN=your_telegram_bot_token DB_SEEDER_TELEGRAM_CHAT_ID=your_telegram_chat_id # Email Configuration DB_SEEDER_MAIL_ENABLED=true DB_SEEDER_MAIL_TO=admin@example.com,alerts@example.com
Using Created Seeders
After running the export command, the seeders will be created in a timestamped directory inside the database/seeders folder. The command will output instructions for using the seeders.
To run the master seeder (which will run all individual seeders in the correct order):
php artisan db:seed --class="Database\Seeders\BackupXXXXXXXXXXXXX\DatabaseBackupSeeder"
Telegram Integration
To use the Telegram integration, you need to:
- Create a Telegram bot using BotFather
- Get your chat ID (you can use the userinfobot)
- Set the environment variables:
DB_SEEDER_TELEGRAM_ENABLED=trueDB_SEEDER_TELEGRAM_BOT_TOKEN=your_tokenDB_SEEDER_TELEGRAM_CHAT_ID=your_chat_id
Email Notifications
To send email notifications after backup completion:
- Ensure your Laravel mail configuration is set up correctly
- Set the recipient email addresses in the config file or using the
--notify-emailoption
License
The MIT License (MIT). Please see License File for more information.
laravel-toolkit/laravel-db-seeder-export 适用场景与选型建议
laravel-toolkit/laravel-db-seeder-export 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 419 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 04 月 26 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「database」 「export」 「backup」 「laravel」 「seeder」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 laravel-toolkit/laravel-db-seeder-export 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 laravel-toolkit/laravel-db-seeder-export 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 laravel-toolkit/laravel-db-seeder-export 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Dibi is Database Abstraction Library for PHP
A SDK for working with B2 cloud storage.
Bulk export of sylius resources
Store your language lines in the database, yaml or other sources
A package for automatically encrypting and decrypting Eloquent attributes in Laravel 5.5+, based on configuration settings.
A sleek PHP wrapper around rclone with Laravel-style fluent API syntax
统计信息
- 总下载量: 419
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 9
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-04-26