PHP code example of jerfeson / correios

1. Go to this page and download the library: Download jerfeson/correios library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

jerfeson / correios example snippets

 php
use Jerfeson\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',
]

**/
 php 
use Jerfeson\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' =>[],
        ],
]
*/