- How do I install lyhiving/dnspod_api in a Laravel project?
- Install it with Composer using composer require lyhiving/dnspod_api. Because it is written for both Laravel and standalone PHP, the Laravel side is mostly about publishing the package configuration so your DNSPod credentials live in config and .env instead of in code. After publishing, add your API token and any default domain settings to your environment file and clear the config cache.
- Do I need Laravel to use this package, or can I use it in plain PHP?
- You do not need Laravel. The package is described as a lightweight client with minimal dependencies that is usable in plain PHP projects, so you can include it via Composer and call the record and domain methods directly. The Laravel integration is a convenience layer, mainly publishable configuration and config-driven credentials.
- Which Laravel versions does lyhiving/dnspod_api support?
- Because the package is a thin wrapper with minimal dependencies, it generally works on modern Laravel releases that satisfy its PHP and Composer constraints. Exact supported versions are defined in the package's composer.json, so check that file on the GitHub repository before upgrading a major Laravel version. If you are on an older framework release, verify the PHP version requirement first.
- How do I configure DNSPod API credentials and tokens?
- Credentials are passed through the package configuration, which supports DNSPod API tokens. In Laravel, publish the config file and reference environment variables so tokens are never committed to version control. In plain PHP, supply the same token values when you instantiate the client.
- How do I list all domains in my DNSPod account?
- The client exposes a fluent method for domain listing that wraps the DNSPod domain endpoint for you. Call it and you receive a parsed array of results rather than raw JSON or cURL output. From there you can loop over the domains to find the ID or name you need for record operations.
- How do I create, update, or delete DNS records with this client?
- Record creation, modification, and deletion are each exposed as straightforward methods, so you pass the domain and record parameters and the wrapper handles the HTTP request. Responses come back as arrays, which makes it easy to check the returned status before continuing. For deletes, confirm the record ID first via a list call to avoid removing the wrong entry.
- What do the responses look like and how are API errors handled?
- The package returns consistent array responses and includes basic error handling, so you are not parsing raw DNSPod responses by hand. You should still check the status information inside the returned array after each call, since DNSPod can report logical failures in the response body. Wrap calls in try/catch where the wrapper surfaces transport-level exceptions.
- Is it safe to use this package in production for live DNS changes?
- It can be used in production, but treat every write operation as high impact: a bad record update can take a site offline. Keep tokens in environment variables, restrict who can run record-modifying code, and log the parameters and responses of each call. For critical zones consider staging the change against a test domain and verifying propagation afterward.
- How can I test DNSPod API calls without hitting the real API?
- The package does not advertise a built-in fake or mock client, so the practical approach is to wrap it behind your own small service class and swap that for a stub in tests. That keeps your application tests fast and avoids creating real DNS records. For integration checks, use a dedicated DNSPod account or test domain rather than production zones.
- What are the alternatives to lyhiving/dnspod_api?
- Alternatives include calling the DNSPod HTTP endpoints directly with Guzzle or Laravel's HTTP client, or using other community DNSPod SDKs if you need broader endpoint coverage. This package is a good fit when you want a small dependency footprint and only the common domain and record operations. If you need provider-agnostic DNS handling across registrars, a multi-provider DNS library may suit you better.