### Old Configuration File Example Source: https://github.com/enflow/laravel-excel-exporter/blob/main/UPGRADE.md This is an example of the configuration structure for the previous package. ```php // config/laravel-excel-to-google-sheet.php return [ 'exports' => [ 'teams' => \App\Exports\TeamsExport::class, ], 'google_sheets' => [ 'service_account_credentials_json' => storage_path('secrets/google-service-account.json'), ], ]; ``` -------------------------------- ### Install Old Package Source: https://github.com/enflow/laravel-excel-exporter/blob/main/UPGRADE.md Use this command to install the previous version of the package. ```bash composer require enflow/laravel-excel-to-google-sheet ``` -------------------------------- ### Old Scheduling Example Source: https://github.com/enflow/laravel-excel-exporter/blob/main/UPGRADE.md Example of scheduling exports using the old package's command. ```php use Enflow\LaravelExcelToGoogleSheet\PushExportsToGoogleSheets; $schedule->command(PushExportsToGoogleSheets::class)->dailyAt(3)->environments('production'); ``` -------------------------------- ### New Configuration File Example Source: https://github.com/enflow/laravel-excel-exporter/blob/main/UPGRADE.md This is an example of the new configuration structure for laravel-excel-exporter, supporting both Google Sheets and BigQuery. ```php // config/excel-exporter.php return [ 'exports' => [ 'teams' => \App\Exports\TeamsExport::class, ], 'exporters' => [ 'google-sheet' => [ 'service_account_credentials_json' => storage_path('secrets/google-service-account.json'), 'interface' => \Enflow\LaravelExcelExporter\Exporters\GoogleSheet\ExportableToGoogleSheet::class, 'factory' => \Enflow\LaravelExcelExporter\Exporters\GoogleSheet\GoogleSheetServiceFactory::class, ], 'google-bigquery' => [ 'service_account_credentials_json' => storage_path('secrets/google-service-account.json'), 'project_id' => 'your-project-id', 'dataset_id' => 'your-dataset-id', 'interface' => \Enflow\LaravelExcelExporter\Exporters\GoogleBigQuery\ExportableToGoogleBigQuery::class, 'factory' => \Enflow\LaravelExcelExporter\Exporters\GoogleBigQuery\GoogleBigQueryServiceFactory::class, ], ], 'memory_limit' => null, ]; ``` -------------------------------- ### Configuration File Example Source: https://context7.com/enflow/laravel-excel-exporter/llms.txt Central configuration file for registering export classes and setting up Google Service Account credentials, project identifiers, and memory limits. ```php // config/excel-exporter.php use Enflow\LaravelExcelExporter\Exporters\GoogleBigQuery\ExportableToGoogleBigQuery; use Enflow\LaravelExcelExporter\Exporters\GoogleBigQuery\GoogleBigQueryServiceFactory; use Enflow\LaravelExcelExporter\Exporters\GoogleSheet\ExportableToGoogleSheet; use Enflow\LaravelExcelExporter\Exporters\GoogleSheet\GoogleSheetServiceFactory; return [ // Register named export classes resolvable from the Laravel container 'exports' => [ 'teams' => \App\Exports\TeamsExport::class, 'orders' => \App\Exports\OrdersExport::class, ], 'exporters' => [ 'google-sheet' => [ // Path to Service Account JSON, or a PHP array of the credentials 'service_account_credentials_json' => storage_path('secrets/google-service-account.json'), 'interface' => ExportableToGoogleSheet::class, 'factory' => GoogleSheetServiceFactory::class, ], 'google-bigquery' => [ 'service_account_credentials_json' => storage_path('secrets/google-service-account.json'), 'project_id' => env('BIGQUERY_PROJECT_ID', 'my-gcp-project'), 'dataset_id' => env('BIGQUERY_DATASET_ID', 'analytics'), 'interface' => ExportableToGoogleBigQuery::class, 'factory' => GoogleBigQueryServiceFactory::class, ], ], // Optional: raise PHP memory limit only during export (e.g. '512M', '1G') 'memory_limit' => env('EXCEL_EXPORTER_MEMORY_LIMIT', null), ]; ``` -------------------------------- ### Install Laravel Excel Exporter Source: https://context7.com/enflow/laravel-excel-exporter/llms.txt Install the package using Composer and publish its configuration file. ```bash composer require enflow/laravel-excel-exporter php artisan vendor:publish --tag="laravel-excel-exporter-config" ``` -------------------------------- ### Old Export Class Interface Source: https://github.com/enflow/laravel-excel-exporter/blob/main/UPGRADE.md Example of implementing the export interface for the previous package. ```php use Enflow\LaravelExcelToGoogleSheet\ExportableToGoogleSheet; class TeamsExport implements ExportableToGoogleSheet { public function googleSpreadsheetId(): string { return 'your-spreadsheet-id'; } // ... other export methods } ``` -------------------------------- ### Google Service Account Credentials Setup Source: https://context7.com/enflow/laravel-excel-exporter/llms.txt Configure Google Service Account credentials either by providing a file path or passing them as a PHP array. Ensure the necessary Google APIs are enabled and the service account has the correct permissions. ```php // Credentials can also be passed as a PHP array instead of a file path: 'service_account_credentials_json' => [ 'type' => 'service_account', 'project_id' => env('GCP_PROJECT_ID'), 'private_key_id' => env('GCP_PRIVATE_KEY_ID'), 'private_key' => env('GCP_PRIVATE_KEY'), 'client_email' => env('GCP_CLIENT_EMAIL'), 'client_id' => env('GCP_CLIENT_ID'), 'auth_uri' => 'https://accounts.google.com/o/oauth2/auth', 'token_uri' => 'https://oauth2.googleapis.com/token', ], ``` -------------------------------- ### Install Laravel Excel Exporter Source: https://github.com/enflow/laravel-excel-exporter/blob/main/README.md Install the package using Composer. This command adds the package to your project's dependencies. ```bash composer require enflow/laravel-excel-exporter ``` -------------------------------- ### Run Push All Command Source: https://github.com/enflow/laravel-excel-exporter/blob/main/README.md Execute the `excel-exporter:push-all` Artisan command to push all configured exports to their respective destinations. ```bash php artisan excel-exporter:push-all ``` -------------------------------- ### Publish Configuration File Source: https://github.com/enflow/laravel-excel-exporter/blob/main/README.md Publish the package's configuration file to your application's config directory. This allows for customization of settings. ```bash php artisan vendor:publish --tag="laravel-excel-exporter-config" ``` -------------------------------- ### Schedule Daily Export Push Source: https://github.com/enflow/laravel-excel-exporter/blob/main/README.md Schedule the `PushAll` command to run daily at a specific time in production environments. This automates the export process. ```php use Enflow\LaravelExcelExporter\Commands\PushAll; $schedule->command(PushAll::class)->dailyAt('03:00')->environments('production'); ``` -------------------------------- ### Run Tests Source: https://github.com/enflow/laravel-excel-exporter/blob/main/README.md Execute the project's test suite using Composer. This command runs all defined tests to ensure code quality. ```bash $ composer test ``` -------------------------------- ### Publish New Configuration Source: https://github.com/enflow/laravel-excel-exporter/blob/main/UPGRADE.md Command to publish the new configuration file for laravel-excel-exporter. ```bash php artisan vendor:publish --tag="laravel-excel-exporter-config" --force ``` -------------------------------- ### Run Interactive Push Command Source: https://github.com/enflow/laravel-excel-exporter/blob/main/README.md Execute the `excel-exporter:push` Artisan command to interactively push a single configured export. You can specify the export key using the `--export` option. ```bash php artisan excel-exporter:push ``` -------------------------------- ### Old Push All Exports Command Source: https://github.com/enflow/laravel-excel-exporter/blob/main/UPGRADE.md This is the console command for pushing all exports in the old package. ```bash php artisan push-all-exports-to-google-sheets ``` -------------------------------- ### Old Console Command Source: https://github.com/enflow/laravel-excel-exporter/blob/main/UPGRADE.md This is the console command for pushing exports to Google Sheets in the old package. ```bash php artisan push-export-to-google-sheets ``` -------------------------------- ### Remove Old Package Source: https://github.com/enflow/laravel-excel-exporter/blob/main/UPGRADE.md Command to remove the old laravel-excel-to-google-sheet package. ```bash composer remove enflow/laravel-excel-to-google-sheet ``` -------------------------------- ### Implement Google BigQuery Export Source: https://github.com/enflow/laravel-excel-exporter/blob/main/README.md Implement the `ExportableToGoogleBigQuery` interface on your export class. Define `googleBigQueryTableId` for the table name and `googleBigQuerySchema` for the table schema. ```php use Enflow\LaravelExcelExporter\Exporters\GoogleBigQuery\ExportableToGoogleBigQuery; class TeamsExport implements ExportableToGoogleBigQuery { public function googleBigQueryTableId(): string { return 'teams'; } public function googleBigQuerySchema(): array { // column => BigQuery type (e.g. STRING, INT64, FLOAT64, BOOL, TIMESTAMP, DATE) return [ 'id' => 'INT64', 'name' => 'STRING', 'created_at' => 'TIMESTAMP', ]; } } ``` -------------------------------- ### Export to Google BigQuery Source: https://context7.com/enflow/laravel-excel-exporter/llms.txt Implement the `ExportableToGoogleBigQuery` interface to push exports to a Google BigQuery table. The table is replaced on each push using a `CREATE OR REPLACE TABLE` DDL statement based on the defined schema. ```php get(); } public function headings(): array { return ['id', 'total', 'status', 'placed_at']; } public function title(): string { return 'Orders'; } // Target table name within the configured dataset public function googleBigQueryTableId(): string { return 'orders'; } // Column name => BigQuery type mapping // Supported types: STRING, INT64, FLOAT64, BOOL, TIMESTAMP, DATE, NUMERIC, BYTES public function googleBigQuerySchema(): array { return [ 'id' => 'INT64', 'total' => 'FLOAT64', 'status' => 'STRING', 'placed_at' => 'TIMESTAMP', ]; } } ``` -------------------------------- ### Artisan Command: Push Single Export Source: https://context7.com/enflow/laravel-excel-exporter/llms.txt Use the `excel-exporter:push` command to interactively select and push a registered export. Use the `--export=` option to specify an export key for non-interactive use in scripts or CI pipelines. ```bash # Interactive — presents a choice menu of registered exports php artisan excel-exporter:push # Non-interactive — push the export registered under the key "teams" php artisan excel-exporter:push --export=teams # Expected console output: # Pushing via Enflow\LaravelExcelExporter\Exporters\GoogleSheet\GoogleSheetPusher # - Clearing destination... # - Pushing data... # - Inserting chunk #0 (1,200 rows)... # - Finished pushing data. ``` -------------------------------- ### Scheduling Exports with `PushAll` Source: https://context7.com/enflow/laravel-excel-exporter/llms.txt Register the `PushAll` command in your Laravel scheduler to automate periodic data synchronization. You can also schedule individual exports using their specific Artisan command. ```php // app/Console/Kernel.php (Laravel 10 and below) // routes/console.php (Laravel 11+) use Enflow\LaravelExcelExporter\Commands\PushAll; // Run every day at 03:00, only in production $schedule->command(PushAll::class)->dailyAt('03:00')->environments('production'); // Or push a single specific export on a different cadence $schedule->command('excel-exporter:push --export=orders')->hourly()->environments('production'); ``` -------------------------------- ### Dual-Destination Export (Google Sheets + BigQuery) Source: https://context7.com/enflow/laravel-excel-exporter/llms.txt A single export class can implement both `ExportableToGoogleSheet` and `ExportableToGoogleBigQuery` interfaces. The `PusherFactory` automatically handles pushing to both destinations. ```php 'INT64', 'name' => 'STRING', 'created_at' => 'TIMESTAMP', ]; } } ``` -------------------------------- ### Register Exports in Config Source: https://github.com/enflow/laravel-excel-exporter/blob/main/README.md Register your custom export classes within the 'exports' array in the configuration file. Ensure the export class is resolvable from the container. ```php 'exports' => [ // key => Export class (must be resolvable from the container) 'teams' => \App\Exports\TeamsExport::class, ] ``` -------------------------------- ### Implement Google Sheets Export Source: https://github.com/enflow/laravel-excel-exporter/blob/main/README.md Implement the `ExportableToGoogleSheet` interface on your export class and define the `googleSpreadsheetId` method to specify the target spreadsheet. ```php use Enflow\LaravelExcelExporter\Exporters\GoogleSheet\ExportableToGoogleSheet; class TeamsExport implements ExportableToGoogleSheet { public function googleSpreadsheetId(): string { return 'your-spreadsheet-id'; } // ... other export methods } ``` -------------------------------- ### Programmatic Push with `PushHandler` Source: https://context7.com/enflow/laravel-excel-exporter/llms.txt Invoke an export push directly from PHP code, such as within a queued job or controller action. The `PushHandler` automatically resolves and applies all applicable pushers for the given export class. ```php [ 'large_report' => \App\Exports\LargeReportExport::class, ], // ... 'memory_limit' => env('EXCEL_EXPORTER_MEMORY_LIMIT', '512M'), ]; ``` ```dotenv # .env EXCEL_EXPORTER_MEMORY_LIMIT=1G ``` -------------------------------- ### ExportableToGoogleSheet Interface Implementation Source: https://context7.com/enflow/laravel-excel-exporter/llms.txt Implement this interface in your Laravel Excel export class to enable pushing data to a Google Sheets spreadsheet. The `title()` method defines the sheet tab name. ```php get(); } public function headings(): array { return ['ID', 'Name', 'Created At']; } // The sheet tab name within the target spreadsheet public function title(): string { return 'Teams'; } // The Google Sheets spreadsheet ID (from the URL) // e.g. https://docs.google.com/spreadsheets/d/{SPREADSHEET_ID}/edit public function googleSpreadsheetId(): string { return '1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgVE2upms'; } } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.