Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Export Laravel Package

smorken/export

Smorken Export is a Laravel package for turning Eloquent models and query results into CSV downloads. Define which columns to include, then generate export files through a simple, configurable API suitable for admin reports and data backups.

View on GitHub
Deep Wiki
Context7

Getting Started

Because smorken/export is a low-profile package (0 stars, 0 dependents, hosted on Bitbucket rather than GitHub/Packagist-first discovery), the fastest way to get productive is to treat the source as documentation before you commit to it.

  1. Install and inspect immediately.

    composer require smorken/export
    

    If Composer can't resolve it, add the VCS repo explicitly:

    composer config repositories.smorken-export vcs https://bitbucket.org/scott_morken/laravel-export.git
    
  2. Look here first, in this order:

    • README.md in the repo root (if present) — installation config and usage examples.
    • src/ directory — the service provider class will tell you what is registered (facades, bindings, commands, config publishing).
    • config/ — the published config file reveals supported formats, column definitions, and defaults.
    • composer.json — check require constraints. A package this obscure may not officially support your Laravel version, which is your first real risk.
  3. Publish config and check registration.

    php artisan vendor:publish --provider="Smorken\Export\ExportServiceProvider"
    

    The provider name may differ — grep src/ for extends ServiceProvider to confirm.

  4. First use case — export a model to CSV. The typical flow for a package like this is a trait or attribute-based export on an Eloquent model, exposed via a facade or command. Start by exporting a small, well-understood model (e.g. User limited to 10 records) to prove the plumbing works before scaling up.

If the README is missing or the API is opaque, spend 10 minutes reading src/ before writing integration code. For an undocumented package, the source is the spec.

Implementation Patterns

Model-level export definition. Most export extensions let you declare exportable columns on the model itself. Centralise the column mapping in one place per model (a trait method or attribute) so the HTTP download, the Artisan command, and any queued job all produce identical output:

// Example shape — verify against actual package API
class User extends Model
{
    use Exportable;

    public function exportColumns(): array
    {
        return ['id', 'name', 'email', 'created_at'];
    }
}

Controller download pattern. Wire exports to a streamed response rather than building the file in memory. The day-to-day pattern is a controller action that returns a download, with the export class (or trait method) doing the generation:

Route::get('/reports/users.csv', function () {
    return (new UsersExport)->download('users.csv');
})->middleware('can:export-users');

Always gate exports with authorization — they frequently leak more data than the corresponding index view.

Queue large exports. Anything over a few thousand rows should not run inside the HTTP request. If the package exposes an Export class (à la Laravel Excel), dispatch it to a queue with ->queue(), or wrap the export call in a job and notify the user with a signed URL to the generated file when complete.

Scheduled reports. The natural extension of queuing is a scheduled Artisan command that exports nightly and drops the file into a storage disk. If the package ships its own command, wrap it in a scheduler entry; if not, call the export facade directly from a custom command.

Custom query scope. Let the caller pass a pre-filtered query rather than filtering inside the export config, so the export doesn't bake business rules into itself:

$query = User::where('active', true)->where('created_at', '>=', $since);
return (new UsersExport($query))->download('active-users.csv');

Gotchas and Tips

Verify maintenance before adopting. With zero dependents and no star history, confirm two things: (1) the composer.json supports your Laravel version, and (2) the last commit is recent enough to trust. If it targets Laravel 8/9 only, expect to fork and patch the service provider or the export driver.

Config caching. If you publish a config file, remember php artisan config:cache will snapshot it. Custom format settings changed in .env after caching won't take effect until you re-run config:clear — a classic "why is my export still CSV?" debugging trap.

Memory and timeouts. If the package builds the full result set in memory, large tables will fatal before you notice. Debug this by exporting a fixed limit(5000) first. If memory is the bottleneck, either chunk with ->chunk() / cursor internally or fall back to a streamed response — check src/ for a StreamedExport or similar to confirm it exists.

Encoding for Excel. A CSV that opens fine in a text editor often mangles accented characters in Excel unless it includes a UTF-8 BOM. If the package doesn't add one, prepend "\xEF\xBB\xBF" to the stream. This bites almost every "our exports look wrong in Excel" ticket.

Date and numeric formatting. Confirm how the package serialises Carbon instances and floats. Locale-dependent decimal separators (comma vs. dot) will silently break downstream imports. Prefer explicit ->format('Y-m-d H:i:s') and number_format() in your column definitions rather than trusting defaults.

Service provider naming. Because this package is obscure, don't assume Smorken\Export\ExportServiceProvider is the class name. Grep for extends ServiceProvider in src/ before running vendor:publish, or discover providers via php artisan about / bootstrap/providers.php.

Extension points are your friend. If the package is thin, the maintainable approach is to wrap it in your own application-level ExportService class rather than calling it directly from controllers and commands. That gives you a single seam to swap in Laravel Excel or a custom CSV writer if the package stalls — which, given its adoption profile, is a realistic outcome.

Test the round-trip. Add a feature test that hits the export endpoint, asserts the Content-Type/Content-Disposition headers, and parses the output back (e.g. array_map('str_getcsv', explode("\n", $csv))) to confirm column order and row counts. For an unmaintained package, this test is your future upgrade safety net.

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
diephp/sequences
users-au/socialite-provider
twidpay/twid-logger
mrnewport/laravel-plaid
mrnewport/laravel-repo
mrnewport/laravel-docsign
mrnewport/laravel-stow
mrnewport/laravel-flow
mrnewport/laravel-priceable
mrnewport/laravel-nestedterms
fredmeng/laravel-apidoc-generator
itstructure/laravel-multilingual-tools
pdustdar/elasticsearch
markupai/php-sdk
rlacerda83/lumem-microservice-shipment
uni-method/symfony-lib
tacticmedia/scim-server-bundle
neika-ai/symfony-bundle
mattleads/agent-publishing-bundle
glavweb/framework-bundle