PHP code example of ekoukltd / s3-import-export

1. Go to this page and download the library: Download ekoukltd/s3-import-export library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

ekoukltd / s3-import-export example snippets


php artisan vendor:publish --provider="Ekoukltd\S3ImportExport\S3IOServiceProvider" --tag="config"

    //Data will be exported to this disk -> choose from config.filesystems.disks options
	//Note that if using s3 a local copy will also be created in storage when importing
	//When running tests local storage copy will be used.
	'disk'           => 's3',
	
	//Where to stick em.  Note trailing slash
	'export_dir' => 'content-export/',
	
	//Add your models to import and export here
	'content_models' => [
		//Json object exports are ideal for copying content type data like pages, posts and templates 
		//without affecting the reset of the database
		'App\\Models\\Pages',
		'App\\Models\\Posts',
		'App\\Models\\EmailTemplates',
	],
	 
	 /** IMPORTANT **/
	//Carbon dates export with a timezone by default, which throws an error when importing to sql
	//If your using timestamps either set any other date fields here 
	'date_columns' => ['created_at', 'updated_at', 'deleted_at']
    
    //or set the format in the model
    protected $casts = [
        'email_verified_at' => 'datetime:Y-m-d H:i:s'
        'my_date_field'     => 'datetime:Y-m-d H:i:s',
    ];

#Export from the CLI
php artisan data:export

#Import
php artisan data:import

#Or in a scheduled task:
Artisan::call('data:export');