Skip to content

Commit

Permalink
Merge pull request #8 from tideways/FrankenPHP
Browse files Browse the repository at this point in the history
Allow FrankenPHP SAPI as well, minor fixes, test adjustments
  • Loading branch information
beberlei authored Apr 24, 2024
2 parents e714abc + eef6228 commit f647ef7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/OctaneMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ class OctaneMiddleware
*/
public function handle(Request $request, Closure $next)
{
if (!class_exists('Tideways\Profiler') || php_sapi_name() !== 'cli') {
// only run when Tideways is installed and the CLI sapi is used (thats how Swoole/RR work)
if (!class_exists('Tideways\Profiler') || !in_array(php_sapi_name(), ['cli', 'frankenphp'], true)) {
// only run when Tideways is installed and the CLI/frankenphp sapi is used (thats how Swoole/RR work)
return $next($request);
}

Expand All @@ -38,7 +38,7 @@ public function handle(Request $request, Closure $next)
\Tideways\Profiler::setCustomVariable('http.method', $request->getMethod());
\Tideways\Profiler::setCustomVariable('http.url', $request->getPathInfo());

if (class_exists('Tideways\Profiler', 'markAsWebTransaction')) {
if (method_exists('Tideways\Profiler', 'markAsWebTransaction')) {
\Tideways\Profiler::markAsWebTransaction();
}

Expand Down
7 changes: 4 additions & 3 deletions tests/OctaneMiddlewareTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ public function setUp(): void
$this->markTestSkipped('Tideways\Profiler is not installed.');
}

$this->assertEquals('basic', ini_get('tideways.monitor'));

\Tideways\Profiler::stop();
}

Expand Down Expand Up @@ -46,9 +44,12 @@ function withTideawysDaemon(\Closure $callback = null, $flags = 0)
{
$callback = $callback ?: function() {};
$address = "tcp://127.0.0.1:64111";
ini_set("tideways.connection", $address);
ini_set('tideways.connection', $address);
ini_set('tideways.api_key', 'abcdefg');
ini_set('tideways.sample_rate', 0);
ini_set('tideways.monitor', 'basic');
putenv('TIDEWAYS_CONNECTION=' . $address);
$_SERVER['TIDEWAYS_CONNECTION'] = $address;
if (ini_get("tideways.connection") !== $address) {
throw new \RuntimeException('Could not set tideways.connection to ' . $address);
}
Expand Down

0 comments on commit f647ef7

Please sign in to comment.