1. Go to this page and download the library: Download royalcms/data-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/ */
royalcms / data-export example snippets
// somewhere in your app
use Royalcms\Component\DataExport\Jobs\CreateCustomizeDataExportJob;
// ...
dispatch(new CreateCustomizeDataExportJob(userModel());
// in your User model
public function selectCustomizeData(CustomizeDataSelection $customizeDataSelection) {
$customizeDataSelection
->add('user.json', ['name' => $this->name, 'email' => $this->email])
->addFile(storage_path("avatars/{$this->id}.jpg");
->addFile('other-user-data.xml', 's3');
}
namespace Royalcms\Component\DataExport\Contracts;
interface ExportsCustomizeData
{
public function selectCustomizeData(CustomizeDataSelection $customizeDataSelection);
public function customizeDataExportName();
public function getKey();
}
// in your user model
public function selectCustomizeData(CustomizeDataSelection $customizeDataSelection) {
$customizeDataSelection
->add('user.json', ['name' => $this->name, 'email' => $this->email])
->addFile(storage_path("avatars/{$this->id}.jpg");
->addFile('other-user-data.xml', 's3');
}
// on your user
public function customizeDataExportName(string $realFilename) {
$userName = Str::slug($this->name);
return "export-data-{$userName}.zip";
}
// somewhere in your app
use Royalcms\Component\DataExport\Jobs\CreateCustomizeDataExportJob;
// ...
dispatch(new CreateCustomizeDataExportJob(userModel());
use Royalcms\Component\DataExport\Jobs\CreateCustomizeDataExportJob;
class MyCustomJobClass extends CreateCustomizeDataExportJob
{
public $queue = 'my-custom-queue`
}
dispatch(new MyCustomJobClass(userModel()));
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.