https://github.com/jerfeson/correios
A library that facilitates integration with Brazilian postal services
https://github.com/jerfeson/correios
Last synced: about 1 year ago
JSON representation
A library that facilitates integration with Brazilian postal services
- Host: GitHub
- URL: https://github.com/jerfeson/correios
- Owner: jerfeson
- License: mit
- Created: 2021-09-15T22:50:15.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2021-09-20T16:11:48.000Z (over 4 years ago)
- Last Synced: 2025-02-01T20:26:31.666Z (over 1 year ago)
- Language: PHP
- Size: 30.3 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Correios for PHP
[](https://github.com/jerfeson/correios/actions/workflows/build.yml)
[](https://img.shields.io/github/v/release/jerfeson/correios)
[](LICENSE.md)
[](https://php.net/)

This library facilitates the integration with the Correios delivery services of Brazil on php
## Functionalities
- [Consult address by zip code](#find-address)
- [Calculate Prices and Deadlines](#calculate-prices-and-deadlines)
## Installation
- Using composer
```bash
$ composer require jerfeson/correios
```
## How to use
### Consult address by zip code
``` php
use Jerfeson\Correios;
require 'vendor/autoload.php';
$correios = new Correios();
$repsonse = $correios->address()->find("73100‑020");
/** result
[
'zipcode' => '01001-000',
'street' => 'Praça da Sé',
'complement' => [
'lado ímpar',
],
'district' => 'Sé',
'city' => 'São Paulo',
'uf' => 'SP',
]
**/
```
### Calculate Prices and Deadlines
Calculate prices and terms of delivery services (Sedex, PAC and etc), with `support for multiple objects` in the same query.
``` php
use Jerfeson\Correios;
require 'vendor/autoload.php';
$correios = new Correios();
$response = $correios->freight()
->origin('01001-000')
->destination('73100‑020')
->services(FreightType::SEDEX, FreightType::PAC)
->item(16, 16, 16, .3, 1)->calculate();
/** result
[
0 =>
[
'name' => 'Sedex',
'code' => '4014',
'price' => 35.1,
'deadline' => 4,
'error' => [],
],
1 =>
[
'name' => 'PAC',
'code' => '4510',
'price' => 24.8,
'deadline' => 8,
'error' =>[],
],
]
*/
```
## How to test
``` bash
$ composer test
```
## Roadmap
- [ ] CodeCoverage
## License
jerfeson/correios is release under the MIT license.
## Thanks
This project is based on the project in flyingluscas/correios-php feel free to contribute to this and the other project.