Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Resellerclubbundle Laravel Package

ap/resellerclubbundle

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Setup

  1. 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(),
    
  2. 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)%"
    
  3. 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");
        }
    }
    

Implementation Patterns

Core Workflows

  1. Customer Management

    • Signups: Use CustomerSignup entity for new registrations.
    • Updates: Use CustomerUpdate to modify existing customers.
    • Deletions: Use CustomerDelete with the target customer ID.
  2. Domain Operations

    • Registrations: Use DomainRegistration with TLD-specific rules.
    • Transfers: Use DomainTransfer for inbound transfers.
    • Renewals: Use DomainRenewal with the domain name and period.
  3. Service Integration

    • Dependency Injection: Prefer constructor injection for ResellerClubApi.
    • Command Bus: Wrap API calls in commands for decoupled workflows:
      $command = new CreateCustomerCommand($signupData);
      $this->commandBus->handle($command);
      
  4. Event-Driven Patterns

    • Extend the bundle by listening to resellerclub.post_exec events:
      $eventDispatcher->addListener('resellerclub.post_exec', function (PostExecEvent $event) {
          if ($event->getOperation() instanceof CustomerSignup) {
              $this->logCustomerCreation($event->getResult());
          }
      });
      
  5. Batch Processing

    • Loop through collections and execute operations in batches:
      foreach ($customers as $customer) {
          $this->resellerClub->setOperation(new CustomerUpdate($customer->id, $customer->data));
          $this->resellerClub->exec();
      }
      

Gotchas and Tips

Common Pitfalls

  1. Deprecated Symfony Version

    • The bundle targets Symfony 2.3 (released 2013). Use a compatibility layer like symfony/legacy-bridge if integrating with newer Symfony versions.
    • Workaround: Override the service definition in config/services.yaml:
      services:
          Ap\ResellerclubBundle\Api\ResellerClubApi:
              arguments:
                  $container: '@service_container' # Symfony 4+ compatibility
      
  2. Test Mode Quirks

    • The demo environment (reseller_test: true) may throttle requests. Mock responses for unit tests:
      $this->resellerClub->setMockResponse(['customerId' => 'TEST123']);
      
  3. Entity Validation

    • The 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;
      }
      
  4. Error Handling

    • The bundle throws generic exceptions. Catch and parse ResellerClub-specific errors:
      try {
          $result = $this->resellerClub->exec();
      } catch (\Exception $e) {
          if (strpos($e->getMessage(), 'Invalid') !== false) {
              // Handle validation errors
          }
      }
      
  5. Rate Limiting

    • ResellerClub enforces rate limits (~10 requests/second). Implement exponential backoff:
      $retryCount = 0;
      while ($retryCount < 3) {
          try {
              return $this->resellerClub->exec();
          } catch (RateLimitException $e) {
              sleep(2 ** $retryCount);
              $retryCount++;
          }
      }
      

Debugging Tips

  1. Enable API Logging Add a logger to the ResellerClubApi service:

    services:
        Ap\ResellerclubBundle\Api\ResellerClubApi:
            calls:
                - [setLogger, ['@logger']]
    
  2. 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;
    }
    
  3. Test Data Cleanup Use the CustomerDelete operation in tests to avoid cluttering the demo environment:

    $this->resellerClub->setOperation(new CustomerDelete('TEST123'));
    $this->resellerClub->exec();
    

Extension Points

  1. Custom Operations Extend the OperationInterface to add new API endpoints:

    class CustomOperation implements OperationInterface {
        public function buildXml() { /* ... */ }
        public function parseResponse($response) { /* ... */ }
    }
    
  2. Response Transformers Override the parseResponse() method in ResellerClubApi for custom data mapping:

    protected function parseResponse($response)
    {
        $data = parent::parseResponse($response);
        return $this->transformCustomerData($data);
    }
    
  3. 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');
    
  4. 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);
    }
    
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
aimeos/prisma
besmartand-pro/php-quality-config
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky
spatie/mailcoach-vapor
spatie/laravel-javascript-views