Download the PHP package ellgreen/laravel-loadfile without Composer
On this page you can find all versions of the php package ellgreen/laravel-loadfile. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download ellgreen/laravel-loadfile
More information about ellgreen/laravel-loadfile
Files in ellgreen/laravel-loadfile
Package laravel-loadfile
Short Description A package to help with loading files into MySQL tables
License MIT
Informations about the package laravel-loadfile
Laravel Load File 💽
A package to help with loading files into MySQL tables.
This uses MySQL's LOAD DATA statement to load text files quickly into your database.
This is usually 20 times faster than using INSERT statements according to: https://dev.mysql.com/doc/refman/8.0/en/insert-optimization.html
Options
This library currently can handle any of the options in a normal LOAD DATA statement except for the partitioned table support. This will be included in a future release of laravel-loadfile.
Further information on the following options that can be passed to the load file builder can be found here:
https://dev.mysql.com/doc/refman/8.0/en/load-data.html
Installation
Requires >= PHP 8.2 and >= Laravel 12
Older versions of Laravel and PHP are supported through previous major versions of this library
Loading files
To use local files you will need to have local_infile
enabled for
the client and server. To do this on the Laravel side you will need
to add the following to the options
part of your database config:
Simple file import
Ignoring header row
Specifying field options
Specifying line options
Input preprocessing (set)
Using a different connection
Duplicate-key and error handling
Loading data into Eloquent Models
Simply add the LoadsFiles
trait to your model like so:
Then you can use the following method to load a file into that table:
Need to specify options to load the file with?
Add the following method to your Model
Or you can get an instance of the query builder on the fly
Development
Check
Runs linting, static analysis, and unit tests.
All tests
Runs unit and feature tests against all support Laravel versions.
You will need to have docker installed for these.