Download the PHP package askdkc/livewire-csv without Composer

On this page you can find all versions of the php package askdkc/livewire-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 livewire-csv

Latest Version on Packagist GitHub Tests Action Status Total Downloads

日本語ReadMeはこちら

About This Package

Introduction

Livewire CSV Package is a package created on top of Laravel livewire for easily handling imports with a simple API. And added some bug fixes to original Codecourse code and package.

csvimport

Note:

This package uses database UPSERT command behind to update (or create) your data.
Please refere to CSV Importer Component for detailed description 🫡

Installation

You can install the package via composer:

Setup Command

You can run livecsv-setup command to publish nessesary migration files and config file for this package.

This command, after publishes files, ask you to run the migration for you. If you want to run the migration by youself then just answer no. Otherwise, type "yes" to run the migration.

This command also ask you to star this repo. If you don't mind helping me, please star the repo. (Thanks in advance)

Add use HasCsvImports to your User Model

You need to implement HasCsvImports to your User model.

Open app/Models/User.php and edit like below:

Usage

CSV Importer Component

Using this package is easy. To implmenent the importer in your project, simply include the following component inside a Blade view.

Props Type Description
:model string Fully qualified name of the model you wish to import to
:columns-to-map array Column names in the target database table
:required-columns array Columns that are required by validation for import
:columns-label array Display labels for the required columns
:upsert-columns
(Optional)
array Columns to use for upsert, without this ['id'] will be used

Note: In order to use :upsert-columns, you need to have a "primary" or "unique" index. Without specifying :upsert-columns, the importer will default to using the id column for upserting.

If you want to user other columns for upsert, like example above, add following index to your model's migration:

If you want to use an other primary key rather than id, let's say email, you need to remove default id and add following index to your model's migration:

Button Component

The Component uses alpinejs under the hood. To display an import button, include the x-csv-button component.

To style the button, use the class attribute with Tailwind utility classes.

Manual Configuration

If you are not using livecsv-setup command, follow these steps to manually configure package setup process.

Publish and run the migrations with:

Csv Import uses Queue Worker so you need to create these tables:

Publish the config file with:

The following is the contents of the published config file:

The layout option is for choosing which CSS framework you are using and currently supports only tailwindcss. We are working on other CSS frameworks to implement in the future.

The file_type option is for choosing either CSV or TSV file. If your file is TSV type, change this to tsv.

The set_delimiter option is for choosing a delimiter of your CSV file. If your file is using, for example ; rather than ,, then change this to ';'.

The file_upload_size is for validation rules, and it defines the maximum file size of uploaded files. You may also define this value from the livewire config file.

Optionally, you can publish the views using

Before Using this command, please take a look at this section below.

In TALL stack project

If you are using this package in a TALL Stack project, (Tailwindcss, Alpinejs, Laravel, Livewire) publish the vendor views to include livewire-csv in your project.

Then compile your assets.

In none TALL Stack project

If you are not using the TALL Stack, use the csv directives to add the necessary styles/scripts.

Using Queues

This package uses queues under the hood with PHP Generators to make it fast and efficient.

Create the batches table by running

Then, run the migration.

After that, set up the queues' configuration. Head to Laravel Queues Documentation to learn more.

Testing

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Inspiration

This Package Was Inspired by codecourse video series. If you want to learn how this package was created, make sure to take a look at this video series

Credits

License

The MIT License (MIT). Please see License File for more information.


All versions of livewire-csv with dependencies

PHP Build Version
Package Version
Requires php Version ^8.0
illuminate/contracts Version ^9.0|^10.0
league/csv Version ^9.15.0
livewire/livewire Version ^2.10
spatie/laravel-package-tools Version ^1.9.2
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 askdkc/livewire-csv contains the following files

Loading the files please wait ....