MNB PHPExcelDeveloper Guide

CSV · Security

CSV security examples.

Package-local, copy-ready examples organized like the classes and methods reference. Open one example at a time, search by method, and jump from the right-side index.

Packagemnb/mnb-phpexcel-csv:^2.0Reference1 examples · 2 methods
CSV individual library

Security examples with copy-ready, production-minded PHP.

Every snippet uses mnb/mnb-phpexcel-csv or its declared Core dependency. Each copied snippet includes strict typing, a concise summary, implementation guidance, readable limits, and a safe fixture check.

1
examples
2
documented methods
Example 01

Enforce CSV upload boundaries

Open related guide
Csv::read()rows()
enforce-csv-upload-boundaries.php
<?php

declare(strict_types=1);

/*
Summary:
    Reject oversized or structurally inconsistent delimited uploads before downstream work.

Implementation note:
    Application upload limits should be stricter than parser limits. Reject unexpected column counts
    when the integration contract is fixed.
*/

use Mnb\PHPExcel\Format\Csv;

$rows = Csv::read(__DIR__ . '/upload.csv', [
    'max_file_bytes' => 20 * 1_024 * 1_024,
    'max_source_rows' => 250_000,
    'max_columns' => 80,
    'strict_column_count' => true,
    'expected_columns' => 12,
])->rows();