Download the PHP package osama-98/laravel-exports without Composer

On this page you can find all versions of the php package osama-98/laravel-exports. 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-exports

Laravel Exports

Latest Version on Packagist Total Downloads License

A powerful Laravel package for exporting large datasets in batches and chunks with support for CSV and XLSX formats. This package provides a clean, fluent API for handling exports efficiently.

Features

Requirements

Installation

Install the package via Composer:

Publish and run the migrations:

Note: The job_batches table is required for queue batching functionality. If you're using the database queue driver, you'll also need the jobs and failed_jobs tables:

The package will automatically register its service provider.

Quick Start

1. Create an Exporter

Create an exporter class that extends Osama\LaravelExports\Exports\Exporter:

2. Start an Export

Using the Facade

Using Dependency Injection

3. Check Export Status

4. Download Export File

Usage Examples

Export with Custom Column Mapping

Export with Query Modification

Export Specific Records by IDs

Export with Max Rows Limit

Export with Custom Options

Export Using Query Builder

Export to S3

Advanced Features

Custom Column State

Customize how column values are extracted:

Column Formatting

Format dates, numbers, and add prefixes/suffixes:

Relationship Aggregations

Export aggregated data from relationships:

Query Modification in Exporter

Modify queries directly in your exporter class:

XLSX Styling

Customize XLSX cell styles:

Events

ExportCompleted Event

The ExportCompleted event is dispatched when an export finishes processing. Listen to this event to send notifications or perform post-export actions.

Example Listener:

Example Listener Class:

Register it in EventServiceProvider:

Queue Configuration

The package uses Laravel's queue batching system for processing exports. Make sure your queue is properly configured.

Required Database Tables

If you're using the database queue driver, you need the following tables:

  1. job_batches - Required for batch processing (used by this package)
  2. jobs - Required for queue jobs
  3. failed_jobs - Required for failed job tracking

Create these tables:

Configure Queue Driver

Configure queue in .env:

Run queue worker:

For production, use a process manager like Supervisor to keep the queue worker running.

API Reference

ExportManager Methods

Method Description Example
exporter(string $exporter) Set the exporter class ->exporter(UserExporter::class)
start(Builder\|QueryBuilder\|null $query, ?array $records, ?array $columnMap, $creator) Start the export ->start(User::query(), creator: auth()->user())
chunkSize(int $size) Set chunk size (default: 100) ->chunkSize(500)
maxRows(?int $rows) Set maximum rows limit ->maxRows(10000)
formats(array $formats) Set export formats ->formats([ExportFormat::Csv, ExportFormat::Xlsx])
fileDisk(?string $disk) Set storage disk ->fileDisk('s3')
fileName(?string $name) Set custom file name ->fileName('my-export')
modifyQueryUsing(?Closure $callback) Modify query before export ->modifyQueryUsing(fn($q) => $q->where('active', true))
options(array $options) Set export options ->options(['date_format' => 'Y-m-d'])

ExportColumn Methods

Method Description Example
make(string $name) Create a new column ExportColumn::make('name')
label(string $label) Set column label ->label('Full Name')
getStateUsing(Closure\|string $callback) Custom state extraction ->getStateUsing(fn($r) => $r->name)
formatStateUsing(Closure $callback) Format the state value ->formatStateUsing(fn($s) => ucfirst($s))
enabled(bool $enabled) Enable/disable by default ->enabled(false)
default($value) Set default value ->default('N/A')
prefix(string $prefix) Add prefix to value ->prefix('$')
suffix(string $suffix) Add suffix to value ->suffix(' USD')
limit(int $limit) Limit text length ->limit(100)
counts(string $relationship) Count relationship records ->counts('orders')
sum(string $relationship, string $column) Sum relationship column ->sum('orders', 'amount')
avg(string $relationship, string $column) Average relationship column ->avg('orders', 'amount')

Export Model Properties

Property Type Description
id int Export ID
exporter string Exporter class name
status ExportStatus Export status (Pending, Processing, Completed, Failed)
total_rows int Total number of rows to export
processed_rows int Number of rows processed
successful_rows int Number of rows successfully exported
file_name string Export file name
file_disk string Storage disk name
completed_at Carbon|null Completion timestamp
creator Model|null User who created the export (morphTo)

Export Model Methods

Method Description Example
download(string $format) Download export file $export->download('xlsx')
getFileDirectory() Get file directory path $export->getFileDirectory()
getFileDisk() Get Filesystem instance $export->getFileDisk()
getFailedRowsCount() Get count of failed rows $export->getFailedRowsCount()
progressPercentage() Get progress percentage (0-100) $export->progressPercentage()

Testing

Run the test suite:

Run tests with coverage:

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

License

This package is open-sourced software licensed under the MIT license.

Support

For issues, questions, or contributions, please visit the GitHub repository.

Credits

Developed with ❤️ for the Laravel community.


All versions of laravel-exports with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
anourvalar/eloquent-serialize Version ^1.2
illuminate/contracts Version ^10.0||^11.0||^12.0
league/csv Version ^9.27
openspout/openspout Version ^5.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 osama-98/laravel-exports contains the following files

Loading the files please wait ...