Download the PHP package vitorccs/laravel-csv without Composer

On this page you can find all versions of the php package vitorccs/laravel-csv. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-csv

Laravel CSV

PHP Laravel package to export and import CSV files in a memory-optimized way.

Description

Export CSV files from PHP arrays, Laravel Collections or Laravel Queries and choose to prompt the user to download the file, store it in a Laravel disk or create the file in background as a Laravel Job.

Import CSV files from Laravel Disks, local files, strings or resources and choose to retrieve the full content or in small chunks.

The memory usage is optimized in this project by using PHP streams, which places the content in a temporary file (rather than PHP thread memory) and reads/writes content one line at a time.

NOTE: This project was inspired on https://github.com/maatwebsite/Laravel-Excel which is a great project and can handle many formats (Excel, PDF, OpenOffice and CSV). But since it uses PhpSpreadsheet, it is not optimized for handling large CSV files (thousands of records) causing the PHP memory exhaustion.

Upgrading from v1.0 to v2.0

Version 2.0 adds the importing feature so the only required action is to change the importing namespace:

Requirements

Installation

Step 1) Add composer dependency

Step 2) Publish the config file

Step 3) Edit your local config\csv.php file per your project preferences

How to Export

Step 1) Create an Export class file as shown below

Note: you may implement FromArray, FromCollection or FromQuery

Step 2) The file can now be generated by using a single line:

In case you want the file to be stored in the disk:

You may also get the content as stream for better control over the output:

For larger files, you may want to generate the file in background as a Laravel Job

Export - Data sources

Note: Only FromQuery can chunk results per chunk_size parameter from config file.

Laravel Eloquent Query Builder

Laravel Database Query Builder

Laravel Collection

Laravel LazyCollection

PHP Arrays

How to Import

Step 1) Create an Import class file as shown below

Note: you may implement FromDisk, FromFile, FromResource or FromContents

Step 2) The content can now be retrieved by using a single line:

Import - Data sources

From string

From local File

From resource

From Laravel Disk

Implementations

The implementations below work with both Export and Import mode.

Headings

Implement WithHeadings for setting a heading to the CSV file.

Mapping rows

Implement WithMapping if you either need to set the value of each column or apply some custom formatting.

Formatting columns

Implement WithColumnFormatting to format date and numeric fields.

In export mode, the Date must be either a Carbon or a Datetime object, and the number must be any kind of numeric data (numeric string, integer or float).

In import mode, the string content must match with the formatting set (e.g: yyyy-mm-dd for dates).

The formatting preferences are set in the config file csv.php.

Limiting the results

Implement the method below if you need to limit the quantity of results to be exported/imported.

License

Released under the MIT License.


All versions of laravel-csv with dependencies

PHP Build Version
Package Version
Requires php Version >=8.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package vitorccs/laravel-csv contains the following files

Loading the files please wait ....