Giter Site home page Giter Site logo

laravel-lazy-import's Introduction

Laravel Lazy Import

Introduction

This project gives you the ability to import data into database from a massive file such as JSON, XML, CSV, etc. Regard to taking the stream reading file strategy, and queuing the input, there is no limit how big the file could be. And If the process stopped, it will continue the process again if queue system were working. Currently, the project only supports JSON but the other drivers will be provided soon!

Requirements

The best environment to run this project is docker. So the only things that you need to run the project is docker and docker-compose. But if you don't want to run this project on docker, you will need PHP 8.0+ or newer, Composer, and MySQL.

Installation

Docker

I developed this project using Laravel Sail. So at the first place you need to install the dependencies. But if you don't want to deal with installing composer locally, you can install them with an ephemeral container from composer official image. Just follow the following steps:

  • cd into project's directory.
  • Copy the .env.example to .env.
  • run docker run --rm -v $(pwd):/app composer install
  • run ./vendor/bin/sail up and wait until all containers been created and stared.
  • run php artisan key:generate
  • run php artisan migrate

Local Machine

As it was mentioned before, you can run this project on your local machine. For that, you can go through following steps:

  • cd into project's directory.
  • Copy the .env.example to .env.
  • run composer update
  • Create the database on MySQL and fill the database configurations on .env file.
  • run php artisan key:generate
  • run php artisan migrate

Configuration

All configurations could be set within environment variables. The following list are these configurations which the names of these variables, represent their use-case:

  • DATA_SOURCE_CHARACTER_LENGTH
  • DATA_IMPORT_STRICT_VALIDATION
  • MIN_CLIENT_AGE
  • MAX_CLIENT_AGE
  • CLIENT_AGE_ALLOW_UNKNOWN
  • CLIENT_CARD_NUMBER_PATTERN

Import Data

There is an example file customers.json in storage directory. The use-case of this file is to run unit tests and also run the actual import as an instance. To start importing this file you can run the following command:

php artisan data-import:define "customers.json" "\App\Services\DataImport\Drivers\Client"

The first argument is the Relative path of the file inside the storage folder. And the second argument is for defining the Driver which imports data into database.

The import process is based on Laravel Queues. So the queue worker should be running to import data. But in production environment, consider using a service monitor to be sure that always the queue worker is running. To see how queues are working, logs, etc. you can check them from Laravel Telescope that is provided in project.

laravel-lazy-import's People

Contributors

rustinm avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.