Download the PHP package dpc/importer without Composer
On this page you can find all versions of the php package dpc/importer. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Package importer
Short Description Laravel package for importing data from another database
License MIT
Informations about the package importer
Laravel Importer
Requirements:
- PHP 7
- Laravel 5.6
Why?
This package allows you to import data from another database locally.
The entire seeding process is run in a transaction by default
How?
Installation:
Use composer to install the package:
Install the service provider in your config file (config/app.php)
Publish the vendor files by running:
This will create an importer.php
config file in config directory
Initialization:
Make sure you have created a new database connection for your temporary database (from where you want to import the data) and it contains the required data.
You need to set up the connection name along with the array of the seeders in the config file. The array will determine the order in which the seeders run.
An example of the config file:
Creating The Seeders:
Create your own Seeder class that extends Dpc\Importer\AbstractSeed
.
The Seeder class should implement these 2 methods:
getData()
: This function is responsible for fetching the data from the database into the seeder. This function does not return the data but an instance of the seeder. The data is available in $this->data
seed()
: This function is called after data is loaded into the class property. Define your seeding process here.
prepareData()
: This is an optional function that is called before the data is seeded. Can be used to
The connection is injected into the seeds so you can use $this->manager->table(<tableName>)
to access the data in the temporary database.
The entire seeding operation is wrapped inside a transaction.
Running The Seeds:
To run the seeds:
Lastly....
Do star this repo. It means a lot to the author (oh wait.. that's me :P )
What's Next?
- Data Chunking
- Flexibility to queue the seeders
- Option to run using a cron job
Wanna Contribute?
Not fussy about standards so just drop in a PR.
If you find any issues or want to make future proposals, create an issue here.
Wanna contact me?
- Twitter: @DPC_22
- Email: [email protected]