Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
use PhpCsFixer\Finder;
use PhpCsFixer\Runner\Parallel\ParallelConfigFactory;

ini_set('memory_limit', -1);

return (new Config)
->setParallelConfig(ParallelConfigFactory::detect())
->setFinder(Finder::create()->in([__DIR__.'/src', __DIR__.'/tests']))
Expand Down
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "3.13.1"
".": "3.14.0"
}
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
# Changelog

## 3.14.0 (2026-02-03)

Full Changelog: [v3.13.1...v3.14.0](https://github.com/browserbase/stagehand-php/compare/v3.13.1...v3.14.0)

### Features

* use `$_ENV` aware getenv helper ([648193c](https://github.com/browserbase/stagehand-php/commit/648193c0d5db24aec73e908a6415342059106763))


### Chores

* **internal:** php cs fixer should not be memory limited ([85b427d](https://github.com/browserbase/stagehand-php/commit/85b427d1f6c2d7074950c2b02a9731491e3f8a60))

## 3.13.1 (2026-01-31)

Full Changelog: [v3.13.0...v3.13.1](https://github.com/browserbase/stagehand-php/compare/v3.13.0...v3.13.1)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ The REST API documentation can be found on [docs.stagehand.dev](https://docs.sta
<!-- x-release-please-start-version -->

```
composer require "browserbase/stagehand 3.13.1"
composer require "browserbase/stagehand 3.14.0"
```

<!-- x-release-please-end -->
Expand Down
16 changes: 11 additions & 5 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,17 @@ public function __construct(
?string $baseUrl = null,
RequestOptions|array|null $requestOptions = null,
) {
$this->browserbaseAPIKey = (string) ($browserbaseAPIKey ?? getenv('BROWSERBASE_API_KEY'));
$this->browserbaseProjectID = (string) ($browserbaseProjectID ?? getenv('BROWSERBASE_PROJECT_ID'));
$this->modelAPIKey = (string) ($modelAPIKey ?? getenv('MODEL_API_KEY'));

$baseUrl ??= getenv(
$this->browserbaseAPIKey = (string) ($browserbaseAPIKey ?? Util::getenv(
'BROWSERBASE_API_KEY'
));
$this->browserbaseProjectID = (string) ($browserbaseProjectID ?? Util::getenv(
'BROWSERBASE_PROJECT_ID'
));
$this->modelAPIKey = (string) ($modelAPIKey ?? Util::getenv(
'MODEL_API_KEY'
));

$baseUrl ??= Util::getenv(
'STAGEHAND_BASE_URL'
) ?: 'https://api.stagehand.browserbase.com';

Expand Down
17 changes: 17 additions & 0 deletions src/Core/Util.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,23 @@ final class Util

public const JSONL_CONTENT_TYPE = '/^application\/(:?x-(?:n|l)djson)|(:?(?:x-)?jsonl)/';

public static function getenv(string $key): ?string
{
if (array_key_exists($key, array: $_ENV)) {
if (!is_string($value = $_ENV[$key])) {
throw new \InvalidArgumentException;
}

return $value;
}

if (is_string($value = getenv($key))) {
return $value;
}

return null;
}

/**
* @return array<string,mixed>
*/
Expand Down
2 changes: 1 addition & 1 deletion src/Version.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
namespace Stagehand;

// x-release-please-start-version
const VERSION = '3.13.1';
const VERSION = '3.14.0';
// x-release-please-end
3 changes: 2 additions & 1 deletion tests/Services/SessionsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use PHPUnit\Framework\Attributes\Test;
use PHPUnit\Framework\TestCase;
use Stagehand\Client;
use Stagehand\Core\Util;
use Stagehand\Sessions\SessionActResponse;
use Stagehand\Sessions\SessionEndResponse;
use Stagehand\Sessions\SessionExecuteResponse;
Expand All @@ -28,7 +29,7 @@ protected function setUp(): void
{
parent::setUp();

$testUrl = getenv('TEST_API_BASE_URL') ?: 'http://127.0.0.1:4010';
$testUrl = Util::getenv('TEST_API_BASE_URL') ?: 'http://127.0.0.1:4010';
$client = new Client(
browserbaseAPIKey: 'My Browserbase API Key',
browserbaseProjectID: 'My Browserbase Project ID',
Expand Down