Installation:
composer require answear/meest-bundle
The bundle auto-registers in config/bundles.php via Symfony Flex.
First Use Case:
Fetch Nova Poshta pickup points (or any DivisionTypeEnum):
use Answear\MeestBundle\Service\MeestClient;
use Answear\MeestBundle\Request\SearchDivisions;
use Answear\MeestBundle\Enum\DivisionTypeEnum;
$client = app(MeestClient::class);
$response = $client->request(new SearchDivisions(DivisionTypeEnum::NovaPoshtaPoint));
foreach ($response->return as $division) {
if ($division->active) {
// Process active pickup points
}
}
Configuration:
MeestClient or override its dependencies.Request-Response Pattern:
MeestClient::request(RequestInterface).SearchDivisions (for pickup points, regions, etc.)GetDivision (fetch details for a specific division)CreateOrder (submit orders to Meest B2B).DTO Handling:
DTO objects (e.g., DivisionDTO, OrderDTO).@var hints or IDE autocompletion for properties like division->active, division->address.Dependency Injection:
MeestClient into services/controllers:
public function __construct(private MeestClient $meestClient) {}
Error Handling:
try {
$response = $this->meestClient->request($request);
} catch (\Answear\MeestBundle\Exception\MeestException $e) {
// Log or handle API errors (e.g., invalid credentials, rate limits)
}
Symfony Forms:
Bind pickup points to a ChoiceType field:
$form->add('pickup_point', ChoiceType::class, [
'choices' => $this->getPickupPoints(),
'choice_label' => 'address',
]);
Commands:
Use MeestClient in console commands for bulk operations:
$this->meestClient->request(new CreateOrder($orderData));
Caching:
Cache responses (e.g., pickup points) with Symfony\Component\Cache\Adapter\AdapterInterface:
$cache = $this->container->get('cache.app');
$cachedResponse = $cache->get('meest_pickup_points', fn() => $this->meestClient->request($request));
SOAP Dependencies:
ext-soap is enabled (php -m | grep soap). The bundle requires it for API communication.PHP/Symfony Version Mismatch:
composer.json for your project’s compatibility.Response Initialization:
Deprecated Fields:
zipcode) may be deprecated. Refer to the Meest B2B API docs for updates.Enable SOAP Debugging:
Configure the MeestClient to log raw SOAP requests/responses:
$client = new MeestClient(
new \Answear\MeestBundle\Client\SoapClient(['trace' => 1])
);
Common Errors:
MeestException: Validate API credentials and request payloads.SoapFault: Check for network issues or SOAP server errors (e.g., timeout).Custom Requests:
Extend Answear\MeestBundle\Request\AbstractRequest to create new API calls:
class CustomRequest extends AbstractRequest {
public function __construct(public string $customParam) {}
public function toSoapArray(): array { /* ... */ }
}
Override MeestClient:
Replace the default client in your services.yaml:
services:
Answear\MeestBundle\Service\MeestClient:
arguments:
$client: '@custom.soap.client'
Add New DTOs:
Extend Answear\MeestBundle\Response\AbstractDTO for custom response fields:
class CustomDTO extends AbstractDTO {
public string $newField;
}
No Config File: The bundle uses default API endpoints. For custom URLs, override the MeestClient constructor or use environment variables:
$client = new MeestClient(
new \Answear\MeestBundle\Client\SoapClient([
'location' => $_ENV['MEEST_API_URL'],
])
);
Rate Limiting: Meest B2B may throttle requests. Implement exponential backoff in your service layer:
use Symfony\Component\Stopwatch\Stopwatch;
$stopwatch = new Stopwatch();
$event = $stopwatch->start('meest_request');
$response = $this->meestClient->request($request);
$event->stop();
if ($event->getDuration() > 1000) { // >1s delay
sleep(1); // Backoff
}
How can I help you explore Laravel packages today?