Skip to content

PHP functions and constants provided by FrankenPHP are not usable in CLI #2301

@bcourtel

Description

@bcourtel

Hello,

First of all, thanks for this great project!

It seems none of the PHP functions and constants defined by FrankenPHP cannot be called when running a CLI script.

I've iterated through all the ones defined in the stub file and cannot use any:

$ curl http://localhost:8080/script.php
==== Constants ====
FRANKENPHP_LOG_LEVEL_DEBUG: 🗸
FRANKENPHP_LOG_LEVEL_INFO: 🗸
FRANKENPHP_LOG_LEVEL_WARN: 🗸
FRANKENPHP_LOG_LEVEL_ERROR: 🗸

==== Functions ====
apache_request_headers: 🗸
apache_response_headers: 🗸
fastcgi_finish_request: 🗸
frankenphp_finish_request: 🗸
frankenphp_finish_request: 🗸
frankenphp_handle_request: 🗸
frankenphp_log: 🗸
frankenphp_request_headers: 🗸
frankenphp_request_headers: 🗸
frankenphp_request_headers: 🗸
frankenphp_response_headers: 🗸
frankenphp_response_headers: 🗸
getallheaders: 🗸
headers_send: 🗸
mercure_publish: 🗸
$ docker compose exec php php /app/public/script.php
==== Constants ====
FRANKENPHP_LOG_LEVEL_DEBUG: 𐄂
FRANKENPHP_LOG_LEVEL_INFO: 𐄂
FRANKENPHP_LOG_LEVEL_WARN: 𐄂
FRANKENPHP_LOG_LEVEL_ERROR: 𐄂

==== Functions ====
apache_request_headers: 𐄂
apache_response_headers: 𐄂
fastcgi_finish_request: 𐄂
frankenphp_finish_request: 𐄂
frankenphp_finish_request: 𐄂
frankenphp_handle_request: 𐄂
frankenphp_log: 𐄂
frankenphp_request_headers: 𐄂
frankenphp_request_headers: 𐄂
frankenphp_request_headers: 𐄂
frankenphp_response_headers: 𐄂
frankenphp_response_headers: 𐄂
getallheaders: 𐄂
headers_send: 𐄂
mercure_publish: 𐄂
$ docker compose exec php frankenphp php-cli /app/public/script.php
==== Constants ====
FRANKENPHP_LOG_LEVEL_DEBUG: 𐄂
FRANKENPHP_LOG_LEVEL_INFO: 𐄂
FRANKENPHP_LOG_LEVEL_WARN: 𐄂
FRANKENPHP_LOG_LEVEL_ERROR: 𐄂

==== Functions ====
apache_request_headers: 𐄂
apache_response_headers: 𐄂
fastcgi_finish_request: 𐄂
frankenphp_finish_request: 𐄂
frankenphp_finish_request: 𐄂
frankenphp_handle_request: 𐄂
frankenphp_log: 𐄂
frankenphp_request_headers: 𐄂
frankenphp_request_headers: 𐄂
frankenphp_request_headers: 𐄂
frankenphp_response_headers: 𐄂
frankenphp_response_headers: 𐄂
getallheaders: 𐄂
headers_send: 𐄂
mercure_publish: 𐄂
Reproduction script
<?php

// script.php

echo '==== Constants ====' . \PHP_EOL;

$constants = [
    'FRANKENPHP_LOG_LEVEL_DEBUG',
    'FRANKENPHP_LOG_LEVEL_INFO',
    'FRANKENPHP_LOG_LEVEL_WARN',
    'FRANKENPHP_LOG_LEVEL_ERROR',
];

foreach ($constants as $constant) {
    echo $constant . ': ' . (\defined($constant) ? '🗸' : '𐄂') . \PHP_EOL;
}

echo \PHP_EOL . '==== Functions ====' . \PHP_EOL;

$functions = [
    'apache_request_headers',
    'apache_response_headers',
    'fastcgi_finish_request',
    'frankenphp_finish_request',
    'frankenphp_finish_request',
    'frankenphp_handle_request',
    'frankenphp_log',
    'frankenphp_request_headers',
    'frankenphp_request_headers',
    'frankenphp_request_headers',
    'frankenphp_response_headers',
    'frankenphp_response_headers',
    'getallheaders',
    'headers_send',
    'mercure_publish',
];

foreach ($functions as $function) {
    echo $function . ': ' . (\function_exists($function) ? '🗸' : '𐄂') . \PHP_EOL;
}
# compose.yaml

services:
   php:
    image: dunglas/frankenphp:1.12.1
    environment:
      SERVER_NAME: :80
    volumes:
    - ./script.php:/app/public/script.php
    ports:
    - 8080:80

Is this expected?

My intended use case was running a (Symfony) console command directly in the container and pushing its results to clients with mercure_publish().

I opened an issue cause I feel like it's a bug but feel free to make it a discussion if it's more appropriate.

I'm available if you have any question.

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions