zendframework/zend-filter
Filtering and normalization utilities for PHP from Zend Framework. Provides a range of filters to sanitize, convert, and transform input (strings, numbers, arrays, etc.), with extensible interfaces for custom filters—useful for validation pipelines and data processing.
The zendframework/zend-filter package is a legacy component from the Zend Framework ecosystem, archived since 2019. While no longer actively maintained, it remains useful in older Laravel applications that depend on Zend Framework components. To begin:
composer require zendframework/zend-filter:^2.10StringTrim, ToInt, HtmlEntities, Alnum, and Digits.Illuminate\Support\Str falls short.rules() or withValidator() to sanitize inputs before validation. Example:
$validator->after(function ($validator) {
$input = $validator->getData();
$filter = new \Zend\Filter\FilterChain();
$filter->attach(new \Zend\Filter\StringTrim())
->attach(new \Zend\Filter\Alpha(['allowWhitespace' => true]));
$validator->setData(['name' => $filter->filter($input['name'])]);
});
Illuminate\Database\Eloquent\Casts\Attribute to apply filters on model attribute access.FilterChain on request input before controllers.FilterChain::filter() with nested arrays or RecursiveFilter.laminas/laminas-filter (Laminas Project). In new projects, migrate to laminas/laminas-filter or use Laravel-native alternatives.Zend\, Laminas\, and Symfony\Component\Validator. Use Composer’s replace or autoload exclusions if needed.append()/prepend() for reusable logic (e.g., trim → lower → alnum for usernames).Callback filters sparingly: For edge cases, \Zend\Filter\Callback lets you wrap custom logic but avoid overuse — prefer standard filters for maintainability.\Zend\Filter\FilterInterface for domain-specific filters (e.g., SanitizePostalCode), but document them thoroughly.Compress\Gz) throw silent failures on invalid input. Use var_dump() in custom filters or log filtered vs. raw values for regression checks.How can I help you explore Laravel packages today?