定制 laravel-toolkit/laravel-db-seeder-export 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

laravel-toolkit/laravel-db-seeder-export

最新稳定版本:v1.0.0

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:

  1. Create a Telegram bot using BotFather
  2. Get your chat ID (you can use the userinfobot)
  3. Set the environment variables:
    • DB_SEEDER_TELEGRAM_ENABLED=true
    • DB_SEEDER_TELEGRAM_BOT_TOKEN=your_token
    • DB_SEEDER_TELEGRAM_CHAT_ID=your_chat_id

Email Notifications

To send email notifications after backup completion:

  1. Ensure your Laravel mail configuration is set up correctly
  2. Set the recipient email addresses in the config file or using the --notify-email option

License

The MIT License (MIT). Please see License File for more information.

统计信息

  • 总下载量: 343
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-04-26

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固