Download the PHP package lacus/cpf-utils without Composer
On this page you can find all versions of the php package lacus/cpf-utils. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package cpf-utils

Toolkit to deal with CPF data (Brazilian personal ID): validation, formatting and generation of valid IDs.
PHP Support
| Passing ✔ | Passing ✔ | Passing ✔ | Passing ✔ |
Installation
Import
Usage
Object-Oriented Usage
The CpfUtils class provides a unified interface for all CPF operations:
With Configuration Options
You can configure the formatter and generator options in the constructor:
Functional Programming
The package also provides standalone functions for each operation:
API Reference
Formatting (cpf_fmt / CpfUtils::format)
Formats a CPF string with customizable delimiters and masking options.
Parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
escape |
?bool |
false |
Whether to HTML escape the result |
hidden |
?bool |
false |
Whether to hide digits with a mask |
hiddenKey |
?string |
'*' |
Character to replace hidden digits |
hiddenStart |
?int |
3 |
Starting index for hidden range (0-10) |
hiddenEnd |
?int |
9 |
Ending index for hidden range (0-10) |
dotKey |
?string |
'.' |
String to replace dot characters |
dashKey |
?string |
'-' |
String to replace dash character |
onFail |
?callable |
fn($v) => $v |
Fallback function for invalid input |
Examples:
Generation (cpf_gen / CpfUtils::generate)
Generates valid CPF numbers with optional formatting and prefix completion.
Parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
format |
?bool |
false |
Whether to format the output |
prefix |
?string |
'' |
Prefix to complete with valid digits (1-9 digits) |
Examples:
Validation (cpf_val / CpfUtils::isValid)
Validates CPF numbers using the official algorithm.
Examples:
Advanced Usage
Accessing Individual Components
You can access the individual formatter, generator, and validator instances:
Custom Error Handling
Dependencies
This package is built on top of the following specialized packages:
lacus/cpf-fmt- CPF formattinglacus/cpf-gen- CPF generationlacus/cpf-val- CPF validation
Contribution & Support
We welcome contributions! Please see our Contributing Guidelines for details. But if you find this project helpful, please consider:
- ⭐ Starring the repository
- 🤝 Contributing to the codebase
- 💡 Suggesting new features
- 🐛 Reporting bugs
License
This project is licensed under the MIT License - see the LICENSE file for details.
Changelog
See CHANGELOG for a list of changes and version history.
Made with ❤️ by Lacus Solutions
All versions of cpf-utils with dependencies
lacus/cpf-fmt Version ^1.0
lacus/cpf-gen Version ^1.0
lacus/cpf-val Version ^1.0