Skip to content

Stdlib: gethostname() — local hostname string (ext/standard/basic_functions.c parity) #3465

Closed

Description

@PurHur

Category

stdlib

Problem

gethostname(): string|false returns the local host name from the OS (gethostname(2) on Linux). Logging, mail headers (mail() #3285 / #3493), and deployment probes call it alongside DNS helpers (#3258). The builtin is not registered in ext/standard/Module.php — invoking it is an undefined function under bin/vm.php (May 2026).

php-src reference

Repro (failure today)

<?php
echo gethostname(), "\n";
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php bin/vm.php -r "echo gethostname(), PHP_EOL;" 2>&1 | tail -3
php -r "echo gethostname(), PHP_EOL;"
'

Expected (Zend): non-empty hostname string (may be short name or FQDN).
Actual (this compiler): Call to undefined function gethostname().

Scope (this repo)

Layer Files
VM ext/standard/gethostname.php — wrap gethostname() with buffer growth on ERANGE (php-src loop)
Register ext/standard/Module.php
JIT Optional lib/JIT/Builtin/ handler or VM-only note in matrix
Tests test/compliance/cases/stdlib/gethostname.phpt

Done when

  • gethostname() returns non-false string on Linux Docker harness
  • function_exists('gethostname') is true
  • Compliance PHPT green under VMTest
  • script/capability-matrix.php row: gethostname VM=yes

Verification

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php bin/vm.php -r "echo gethostname();"
./script/ci-fast.sh --filter VMTest -- tests matching gethostname
'

Activity

  1. added
    enhancementNew feature or request
    phase-4:stdlibPhase 4 – stdlib for web apps
    area:vmVirtual machine
    implementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claim
    on May 30, 2026
  2. PurHur commented on May 30, 2026

    @PurHur
    OwnerAuthor

    claim: PHP Compiler STD Lib — starting this run

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:vmVirtual machineenhancementNew feature or requestimplementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claimphase-4:stdlibPhase 4 – stdlib for web apps

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions