PHPackages                             izopi4a/econt-bundle - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Framework](/categories/framework)
4. /
5. izopi4a/econt-bundle

ActiveSymfony-bundle[Framework](/categories/framework)

izopi4a/econt-bundle
====================

econt curier bundle for symfony

v1.0.1(1y ago)024MITPHPPHP ^8.4

Since Jan 3Pushed 1y ago1 watchersCompare

[ Source](https://github.com/Izopi4a/EcontBundle)[ Packagist](https://packagist.org/packages/izopi4a/econt-bundle)[ RSS](/packages/izopi4a-econt-bundle/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (5)DependenciesVersions (6)Used By (0)

EcontBundle
===========

[](#econtbundle)

api docs by econt here: This doesn't cover all the Econt API. I developed what I needed, if you need help or more APIs just open an issue I will add them.

Install
=======

[](#install)

```
composer require izopi4a/econt-bundle
```

Post install
============

[](#post-install)

add this to your enviorment variables

```
IZOPI4A_ECONT_USER=
IZOPI4A_ECONT_PASS=
IZOPI4A_ECONT_LOCALE=BG
IZOPI4A_ECONT_DEV=true
```

Usage
=====

[](#usage)

#### It is a service, so you can autowire it. Example:

[](#it-is-a-service-so-you-can-autowire-it-example)

```
#[Route('/{_locale}', name: 'app_home')]
public function index(EcontService $econtService): Response
{

    $offices_in_sofia = $econtService->getOfficesInCity(41);

    dd($offices_in_sofia)
}
```

### Calculating delivery

[](#calculating-delivery)

```
$sender = new \Izopi4a\EcontBundle\Service\Http\Payload\Party();
$sender->setTypeSender();
$sender->setOffice(1000);

$receiver = new \Izopi4a\EcontBundle\Service\Http\Payload\Party();
$receiver->setTypeReciever();
// to specify office use
//$receiver->setOffice(1100);
//to specify home address use
$receiver->setAddress(41, "Незабравка", 31, "");

$package = new \Izopi4a\EcontBundle\Service\Http\Payload\Package();
$package->setWeight(1);
$package->setDescription("обувки");
$package->setCount(2);
//to add cash on delivery uncomment
//$package->addCashOnDelivery(200);

$sender_contact = new \Izopi4a\EcontBundle\Service\Http\Payload\Contact();
$sender_contact->setName("Иван Иванов");
$sender_contact->addPhone("0888888888");
$sender_contact->setTypeSender();

$receiver_contact = new \Izopi4a\EcontBundle\Service\Http\Payload\Contact();
$receiver_contact->setName("Иван Иванов");
$receiver_contact->addPhone("0888888888");
$receiver_contact->setTypeReciever();

$shipment = $econtService->calculateDelivery($sender, $receiver, $package, $sender_contact, $receiver_contact);

//you can check for errors with $shipment->getErrors() or $shipment->hasErrors()

dd($shipment->getTotalPrice(), $shipment);
```

### Getting all the cities

[](#getting-all-the-cities)

I didn't find an option to filter the cities, so Econt are returning ~6k cities, in my case I store them in my database so I can use them faster. Example entity / php bin/console make:entity City

```
