A modern, open-source PHP cURL-based HTTP request library designed for simplicity, flexibility, and clean abstraction of HTTP requests.
- ✅ Simple, object-oriented API
- ✅ Supports GET, POST, PUT, PATCH, DELETE, HEAD
- ✅ JSON and raw body support
- ✅ Query parameter builder
- ✅ Bearer token support
- ✅ Flexible headers and options
- ✅ PSR-4 autoloading
- ✅ Easily testable
Use Composer:
composer require hitraa/openforge-curluse OpenForge\Curl\HttpRequest;
$response = (new HttpRequest('https://httpbin.org/get'))
->setMethod('GET')
->setData(['q' => 'openforge'])
->responseArray();
print_r($response);$response = (new HttpRequest('https://httpbin.org/post'))
->setMethod('POST')
->setJson([
'username' => 'harshal',
'role' => 'admin'
])
->responseObject();$response = (new HttpRequest('https://httpbin.org/post'))
->setMethod('POST')
->setRaw('<xml><user>Harshal</user></xml>')
->addHeader('Content-Type: application/xml')
->responseText();$response = (new HttpRequest('https://api.example.com/secure'))
->setMethod('GET')
->setBearer('your-token-here')
->responseArray();Here's a clean and professional README block you can insert under your Usage or Advanced section to explain the sslVerify(false) feature:
If you're working in a local development environment, unsecured server or dealing with self-signed certificates, you may want to disable SSL verification temporarily:
$response = (new HttpRequest('https://self-signed.local/api'))
->setMethod('GET')
->sslVerify(false) // ⚠️ disables certificate & hostname verification
->responseArray();
⚠️ Warning: Disabling SSL verification is not recommended for production use. It makes your HTTP client vulnerable to MITM (Man-in-the-Middle) attacks.
You can optionally disable SSL verification based on an environment variable:
$response = (new HttpRequest('https://dev.api'))
->setMethod('GET')
->sslAuto(); // disables SSL if APP_ENV = local or testingOR
// Explicitly set APP_ENV
putenv("APP_ENV=local");
// Do https cURL request
$response = (new HttpRequest('https://dev.api'))
->setMethod('GET')By default, it checks APP_ENV for local or testing.
You may also customize:
->sslAuto('MY_ENV', ['dev', 'staging'])
⚠️ This doesn't load a .env file — you must ensure environment variables are set manually or via your framework.
Run tests via PHPUnit:
vendor/bin/phpunit
# running test on local machine
APP_ENV=local vendor/bin/phpunitMake sure phpunit.xml is at the root of the project.
openforge-curl/
├── src/ # Library source code
│ └── HttpRequest.php
├── tests/ # Unit tests
│ └── HttpRequestTest.php
├── composer.json
├── phpunit.xml
├── .gitignore
├── .gitattributes
└── README.md
Harshal Khairnar
Founder, Hitraa Technologies
📧 harshal@hitraa.com
MIT License © 2025 Hitraa Technologies