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

Laravel Valuedomain Api Laravel Package

shibuyakosuke/laravel-valuedomain-api

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Setup

  1. Installation

    composer require shibuyakosuke/laravel-valuedomain-api
    

    Publish the config file:

    php artisan vendor:publish --provider="ShibuyaKosuke\ValueDomainApi\ValueDomainApiServiceProvider" --tag="config"
    
  2. Configuration Edit .env with your ValueDomain API credentials:

    VALUEDOMAIN_API_KEY=your_api_key_here
    VALUEDOMAIN_API_SECRET=your_api_secret_here
    
  3. First Use Case Fetch domain availability in a controller:

    use ShibuyaKosuke\ValueDomainApi\Facades\ValueDomainApi;
    
    public function checkDomainAvailability(Request $request)
    {
        $domain = $request->input('domain');
        $result = ValueDomainApi::checkDomain($domain);
        return response()->json($result);
    }
    

Key Files to Review

  • config/valuedomain-api.php (API endpoints, defaults)
  • src/Facades/ValueDomainApi.php (Facade for quick access)
  • src/ValueDomainApiManager.php (Core logic)

Implementation Patterns

Common Workflows

1. Domain Availability Checks

// Basic check
$isAvailable = ValueDomainApi::checkDomain('example.com');

// With callback for async handling
ValueDomainApi::checkDomain('example.com', function ($response) {
    // Handle response
});

2. Domain Pricing

$pricing = ValueDomainApi::getDomainPricing('example.com');

3. Bulk Operations

$domains = ['example1.com', 'example2.com'];
$results = ValueDomainApi::checkDomains($domains);

4. Integration with Laravel Jobs

// Dispatch a job for async domain checks
CheckDomainJob::dispatch('example.com');

Integration Tips

  • Caching Responses: Cache API responses to reduce calls:

    $cacheKey = "valuedomain_{$domain}";
    if (Cache::has($cacheKey)) {
        return Cache::get($cacheKey);
    }
    $result = ValueDomainApi::checkDomain($domain);
    Cache::put($cacheKey, $result, now()->addHours(1));
    
  • Error Handling: Wrap API calls in try-catch:

    try {
        $result = ValueDomainApi::checkDomain('example.com');
    } catch (\Exception $e) {
        Log::error("ValueDomain API Error: " . $e->getMessage());
        return response()->json(['error' => 'Service unavailable'], 503);
    }
    
  • Rate Limiting: Use Laravel’s throttle middleware if the API has rate limits.


Gotchas and Tips

Pitfalls

  1. API Key Exposure

    • Ensure .env is in your .gitignore. Avoid hardcoding keys in config files.
  2. Rate Limits

    • The package doesn’t enforce rate limits by default. Monitor API responses for 429 Too Many Requests.
  3. Deprecated Endpoints

    • The package may not auto-update if ValueDomain changes their API. Check the ValueDomain API docs for breaking changes.
  4. No Built-in Retry Logic

    • Transient failures (e.g., network issues) won’t auto-retry. Implement retry logic if needed:
      use Illuminate\Support\Facades\Http;
      
      Http::retry(3, 100)->post(...);
      

Debugging Tips

  • Enable Debug Mode Set debug to true in config/valuedomain-api.php to log raw API responses:

    'debug' => env('VALUEDOMAIN_DEBUG', false),
    
  • Check HTTP Client The package uses Laravel’s HTTP client. Inspect requests with:

    php artisan route:list
    

    or use a tool like Postman to verify endpoints manually.

Extension Points

  1. Custom Responses Override the default response handling by extending ShibuyaKosuke\ValueDomainApi\ValueDomainApiManager:

    class CustomValueDomainApiManager extends ValueDomainApiManager
    {
        public function checkDomain($domain)
        {
            $response = parent::checkDomain($domain);
            // Transform response here
            return $this->customTransform($response);
        }
    }
    
  2. Add New Endpoints Extend the makeRequest method to support additional API routes:

    public function getNewEndpoint($param)
    {
        return $this->makeRequest('GET', '/new-endpoint', ['param' => $param]);
    }
    
  3. Mocking for Tests Use Laravel’s HTTP mocking in tests:

    Http::fake([
        'api.valuedomain.com/*' => Http::response(['available' => true]),
    ]);
    
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.
hamzi/corewatch
minionfactory/raw-hydrator
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle
atriumphp/atrium
sandermuller/package-boost-laravel
sandermuller/boost-skills
redaxo/core
yusufgenc/filament-api-forge
l3aro/rating-star-for-filament
leek/filament-subtenant-scope