Installation Add the bundle via Composer:
composer require ap/resellerclubbundle:1.0.*@dev
Register the bundle in config/bundles.php (Symfony 4+) or AppKernel.php (Symfony 2.3):
new Ap\ResellerclubBundle\ApResellerclubBundle(),
Configuration
Define credentials in .env (recommended) or config/packages/resellerclub.yaml:
resellerclub:
auth_userid: "%env(RESELLER_AUTH_USERID)%"
api_key: "%env(RESELLER_API_KEY)%"
test_mode: "%env(bool:RESELLER_TEST_MODE)%"
First Use Case Inject the API service in a controller/service and create a customer:
use Ap\ResellerclubBundle\Api\ResellerClubApi;
class CustomerController extends AbstractController
{
public function __construct(private ResellerClubApi $resellerClub) {}
public function createCustomer()
{
$signup = new \Ap\ResellerclubBundle\Entity\CustomerSignup(
'user@example.com',
'password123',
'John Doe',
'Company',
'123 Main St',
'City',
'State',
null,
'US',
'12345',
'123',
'1234567890',
'en'
);
$this->resellerClub->setOperation($signup);
$customerId = $this->resellerClub->exec();
return new Response("Customer created with ID: $customerId");
}
}
Customer Management
CustomerSignup entity for new registrations.CustomerUpdate to modify existing customers.CustomerDelete with the target customer ID.Domain Operations
DomainRegistration with TLD-specific rules.DomainTransfer for inbound transfers.DomainRenewal with the domain name and period.Service Integration
ResellerClubApi.$command = new CreateCustomerCommand($signupData);
$this->commandBus->handle($command);
Event-Driven Patterns
resellerclub.post_exec events:
$eventDispatcher->addListener('resellerclub.post_exec', function (PostExecEvent $event) {
if ($event->getOperation() instanceof CustomerSignup) {
$this->logCustomerCreation($event->getResult());
}
});
Batch Processing
foreach ($customers as $customer) {
$this->resellerClub->setOperation(new CustomerUpdate($customer->id, $customer->data));
$this->resellerClub->exec();
}
Deprecated Symfony Version
symfony/legacy-bridge if integrating with newer Symfony versions.config/services.yaml:
services:
Ap\ResellerclubBundle\Api\ResellerClubApi:
arguments:
$container: '@service_container' # Symfony 4+ compatibility
Test Mode Quirks
reseller_test: true) may throttle requests. Mock responses for unit tests:
$this->resellerClub->setMockResponse(['customerId' => 'TEST123']);
Entity Validation
CustomerSignup entity lacks built-in validation (e.g., email format). Add constraints manually:
use Symfony\Component\Validator\Constraints as Assert;
class CustomerSignup {
/**
* @Assert\Email
*/
public $email;
}
Error Handling
try {
$result = $this->resellerClub->exec();
} catch (\Exception $e) {
if (strpos($e->getMessage(), 'Invalid') !== false) {
// Handle validation errors
}
}
Rate Limiting
$retryCount = 0;
while ($retryCount < 3) {
try {
return $this->resellerClub->exec();
} catch (RateLimitException $e) {
sleep(2 ** $retryCount);
$retryCount++;
}
}
Enable API Logging
Add a logger to the ResellerClubApi service:
services:
Ap\ResellerclubBundle\Api\ResellerClubApi:
calls:
- [setLogger, ['@logger']]
Raw API Responses
Extend the exec() method to log raw responses:
public function exec()
{
$response = parent::exec();
$this->logger->debug('ResellerClub Response', ['raw' => $this->getLastResponse()]);
return $response;
}
Test Data Cleanup
Use the CustomerDelete operation in tests to avoid cluttering the demo environment:
$this->resellerClub->setOperation(new CustomerDelete('TEST123'));
$this->resellerClub->exec();
Custom Operations
Extend the OperationInterface to add new API endpoints:
class CustomOperation implements OperationInterface {
public function buildXml() { /* ... */ }
public function parseResponse($response) { /* ... */ }
}
Response Transformers
Override the parseResponse() method in ResellerClubApi for custom data mapping:
protected function parseResponse($response)
{
$data = parent::parseResponse($response);
return $this->transformCustomerData($data);
}
Webhook Integration
Use Symfony’s HttpClient to poll ResellerClub’s webhook endpoints:
$client = $this->container->get('http_client');
$response = $client->request('GET', 'https://api.resellerclub.com/webhook');
Caching Layer Cache frequent operations (e.g., domain availability checks) with Symfony’s cache component:
$cache = $this->container->get('cache.app');
$key = 'domain_availability_' . $domain;
if (!$cache->has($key)) {
$result = $this->resellerClub->checkDomainAvailability($domain);
$cache->set($key, $result, 3600);
}
How can I help you explore Laravel packages today?