Installation:
composer require devwizardhq/laravel-filex
php artisan vendor:publish --provider="DevWizardHQ\Filex\FilexServiceProvider" --tag="filex-config"
php artisan migrate
config/filex.php) and migrations (creates filex_uploads and filex_quarantined_files tables).Basic Blade Usage:
<x-filex::upload
name="documents"
endpoint="{{ route('filex.upload') }}"
max-files="5"
max-file-size="10MB"
accepted-files="image/*,.pdf,.docx"
/>
Route::post('/filex/upload', [FilexController::class, 'upload'])->name('filex.upload');
First Use Case:
<x-filex::upload> and handle submissions via FilexController (auto-generated by the package). The package handles:
Drag-and-Drop Integration:
<x-filex::upload>) with customizable attributes:
<x-filex::upload
name="avatars"
endpoint="{{ route('filex.upload') }}"
max-files="1"
preview-template="filex::preview.image" <!-- Custom preview for images -->
chunk-size="5MB"
/>
resources/views/vendor/filex/preview/image.blade.php) for custom file types (PDFs, videos).Chunked Uploads:
config/filex.php:
'chunk' => [
'size' => '10MB', // Default chunk size
'enabled' => true,
],
FilexController:
public function upload(Request $request)
{
$upload = (new FilexUploadHandler())->handle($request);
return response()->json($upload);
}
Form Submission:
finalize() to move temporary files to permanent storage:
public function store(Request $request)
{
$request->validate(['documents' => 'required|array']);
$upload = Filex::finalize($request->documents);
// Save $upload->files() to your model
}
Quarantine System:
config/filex.scanner.enabled = true).$quarantined = Filex::quarantined()->latest()->get();
FilexField trait to integrate uploads into admin panels:
use DevWizardHQ\Filex\Nova\FilexField;
FilexField::make('Cover Image')->onlyOnDetail(),
use DevWizardHQ\Filex\Rules\Filex;
$request->validate([
'files' => ['required', new Filex(['max' => 5, 'types' => 'image/jpeg'])]
]);
config/filex.php:
'storage' => [
'disk' => 's3',
'path' => 'uploads/{year}/{month}',
],
Temporary Files:
storage/app/filex/temp/ until finalize() is called. Never rely on these files persisting beyond the request.Filex::finalize() in your form submission logic.Chunked Upload Failures:
filex_uploads table) and retry:
$incomplete = Filex::uploads()->where('status', 'incomplete')->get();
Filex::retryUpload($uploadId);
CSRF Token:
@csrf in Blade or passes the token via JavaScript:
Dropzone.options.myDropzone = {
headers: { 'X-CSRF-TOKEN': '{{ csrf_token() }}' }
};
Scanner Conflicts:
filex.scanner.command in config points to the correct binary. Test locally first:
php artisan filex:scan --path=/path/to/test/file
Log Upload Events:
Enable debug mode in config/filex.php:
'debug' => env('FILEX_DEBUG', false),
storage/logs/laravel.log.Check Database:
filex_uploads: Tracks all upload sessions.filex_quarantined_files: Lists flagged files.php artisan tinker
>>> \DevWizardHQ\Filex\Models\Upload::all();
Custom Events:
Filex\Events\UploadStarted):
Filex::listen(function ($event) {
Log::info('Upload started', $event->upload->toArray());
});
Override Blade Components:
php artisan vendor:publish --tag="filex-views"
resources/views/vendor/filex/upload.blade.php for custom UI.Add File Types:
Filex facade to support new file types (e.g., 3D models):
Filex::extend('3d-model', function ($file) {
return new \App\Services\ThreeDModel($file);
});
API Integration:
FilexUploadHandler directly in API routes:
public function apiUpload(Request $request)
{
$handler = new \DevWizardHQ\Filex\Handlers\FilexUploadHandler();
return response()->json($handler->handle($request));
}
storage/app/filex/ is writable:
chmod -R 775 storage/app/filex
memory_limit. Increase it in .env:
MEMORY_LIMIT=2G
php artisan queue:work
How can I help you explore Laravel packages today?