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.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package cpf-utils

cpf-utils for PHP

Packagist Version Packagist Downloads PHP Version Test Status Last Update Date Project License

Toolkit to deal with CPF data (Brazilian personal ID): validation, formatting and generation of valid IDs.

PHP Support

PHP 8.1 PHP 8.2 PHP 8.3 PHP 8.4
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:

Contribution & Support

We welcome contributions! Please see our Contributing Guidelines for details. But if you find this project helpful, please consider:

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

PHP Build Version
Package Version
Requires php Version >=8.1
lacus/cpf-fmt Version ^1.0
lacus/cpf-gen Version ^1.0
lacus/cpf-val Version ^1.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package lacus/cpf-utils contains the following files

Loading the files please wait ...