- What is ihsw/toxiproxy-php-client used for?
- It is a PHP client for Toxiproxy that lets test suites create and manage TCP proxies and toxics that simulate latency, bandwidth limits, timeouts, and connection failures. In Laravel projects it is typically used in integration tests to verify how the application behaves when MySQL, Redis, HTTP upstreams, or queues degrade. It is a test-time chaos engineering tool, not a production runtime dependency.
- How do I install ihsw/toxiproxy-php-client in a Laravel project?
- Install it with Composer as a dev dependency, for example composer require --dev ihsw/toxiproxy-php-client. You also need a running Toxiproxy server available to your test environment, often through Docker Compose or a CI service container. The package does not appear to ship a Laravel service provider, so expect to bootstrap the client manually in a test helper or base test case.
- Does this package support Laravel and PHPUnit or Pest?
- The package is framework-agnostic PHP, so it can be used from Laravel PHPUnit or Pest tests as long as your PHP version is compatible. There is no documented Laravel service provider or Pest-specific plugin in the provided context, so integration is through normal test setup and teardown. Validate PHP, PHPUnit or Pest, and Toxiproxy server versions before standardizing.
- How do I configure the Toxiproxy server address in Laravel tests?
- Expect to pass the Toxiproxy HTTP API base URL to the client when you instantiate it, using an environment variable such as TOXIPROXY_URL. In Laravel you can set that variable in phpunit.xml or a CI job and read it from your test bootstrap. The context does not document Laravel config publishing, so manual configuration is the safe assumption.
- Can I use this package to simulate latency and timeouts in tests?
- Yes, the client can add and manage toxics including latency, bandwidth, timeout, and slicer. A typical test creates a proxy in front of the dependency, attaches a latency or timeout toxic, exercises the application, then removes the toxic and proxy. This lets you assert retry, timeout, and error-handling behavior under controlled network conditions.
- Is ihsw/toxiproxy-php-client safe for production?
- No, it is intended for test and CI environments because it injects network faults and depends on a Toxiproxy server. Keep it in require-dev and never enable Toxiproxy fault injection in deployed production request paths. Production use would add unnecessary risk and operational complexity.
- Does it support parallel test execution and proxy isolation?
- The provided context does not document parallel-test isolation or proxy namespaces. If you run Laravel tests in parallel, you should create unique proxy names per process and clean them up carefully to avoid collisions. Confirm the package behavior against your PHPUnit or Pest parallel setup before relying on it.
- What are the risks of using this package in CI?
- The main risks are low adoption, an unknown repository location, and maintainership uncertainty, which affect supply-chain review and bus factor. In CI, leaked proxies, port collisions, orphaned Toxiproxy containers, and flaky cleanup can make tests unreliable. Because it is test-only, production blast radius is limited, but you should still pin versions and review the code.
- Are there alternatives to ihsw/toxiproxy-php-client for Laravel chaos testing?
- Alternatives include calling the Toxiproxy HTTP API directly with Laravel HTTP client, writing a small internal wrapper, or using Toxiproxy CLI and Docker tooling in test setup. If you only need a few toxics, an internal helper may be simpler and easier to maintain. The package mainly reduces boilerplate around proxy and toxic management.
- How is the package maintained and which Toxiproxy versions are supported?
- The context mentions a 2025-05-29 release but does not specify supported Toxiproxy server, PHP, Laravel, or PHPUnit versions. Before adopting it, check the repository, release history, and whether it has integration tests against a real Toxiproxy server. Pin a Toxiproxy image tag and validate compatibility in a spike.