Download the PHP package husail/cnab-sdk without Composer

On this page you can find all versions of the php package husail/cnab-sdk. 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 cnab-sdk

husail/cnab-sdk

PHP SDK for reading and writing CNAB 240 files, built on top of husail/edi-sdk.

Provides tools to generate, parse and validate CNAB 240 files with support for payment grouping, automatic record sequencing, and bank-specific layouts.

PHP License Status


πŸ“‹ Requirements


πŸ“¦ Installation


🏦 Supported banks and formats

Bank CNAB 240 CNAB 150 CNAB 400
ItaΓΊ (341) βœ… Pagamentos β€” β€”
Bradesco (237) πŸ”œ β€” β€”

πŸ“ Writing a payment file β€” ItaΓΊ CNAB 240

High-level API

batch_code, record_sequence, record_count (batch trailer) and batch_count, record_count (file trailer) are all filled automatically.

PIX by key β€” Segment A + Segment B PIX

PIX by key requires a segment_b_pix after each segment_a. The segment_b_pix is distinguished from the standard segment_b by the pix_key_type field at positions 15-16.

PIX key types (pix_key_type):

Code Type
01 Phone
02 E-mail
03 CPF / CNPJ
04 Random key (EVP)

PIX by bank account β€” Segment A + Segment B

PIX by bank account data uses the standard segment_b (address/email complement). The parser distinguishes them automatically: positions 15-16 are spaces for standard segment_b and a key type code for segment_b_pix.

Multiple batches

Each ->batch() call creates a new batch with an incremented batch code:

According to SISPAG rules, PIX payments must be in a separate file from other payment types.

Overriding auto-calculated fields

All automatically calculated fields can be overridden:


πŸ“‚ Reading a return file

The same layout covers both remessa (outgoing) and retorno (return). The file_header.file_code field distinguishes them: 1 = remessa, 2 = retorno.

Return occurrence codes (occurrence_code at positions 231-240):

Code Meaning
00 Paid / Processed
BD Invalid bank
AB Scheduling error
Others See ItaΓΊ SISPAG manual (v086) for the full list

πŸ—‚οΈ Grouped payments

groupPayments() reconstructs each payment with all its segments together, grouped by batch_code + record_sequence.

Generic access

Typed PIX payments

Typed boleto payments

Filter grouped payments


βœ… Validating a file


πŸ› οΈ Generic API β€” bring your own layout

Use Cnab::write() when you have a custom YAML or JSON layout:


πŸ—“οΈ CNAB helpers


πŸ—οΈ Adding a new bank

Implement BankLayoutInterface and provide a YAML layout file:

The layout YAML follows the same structure as the ItaΓΊ layout. See src/Layouts/Itau/cnab240/pagamentos/layout.yaml as reference. A single layout file covers both remessa and retorno.


πŸ”— How it relates to edi-sdk

Cnab::parse() and Cnab::validate() are thin wrappers over Edi::parse() and Edi::validate(). For full control, use the edi-sdk directly with Cnab240Itau::layout().


πŸ§ͺ Testing


🀝 Contributing

Contributions, issues and pull requests are welcome. \ If you find a bug or have a suggestion, feel free to open an issue.


πŸ“œ License

Licensed under the MIT License.


All versions of cnab-sdk with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
husail/edi-sdk Version ^1.0
symfony/yaml Version ^6.0|^7.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 husail/cnab-sdk contains the following files

Loading the files please wait ...