Documentation
¶
Overview ¶
Package detect recognises PHP runtimes (the CLI, PHP-FPM, CGI, the Apache module, LiteSpeed, FrankenPHP and embedded builds) by content, not by name, and reads the version each one was built as.
Every PHP runtime links main/SAPI.c, which compiles the header "X-Powered-By: PHP/" PHP_VERSION into one NUL-terminated string, and the Zend engine, which compiles "Zend Engine v" ZEND_VERSION ", Copyright (c) ..." into another. A file is reported only when it is an executable or shared library (ELF, Mach-O or PE) and holds both strings, so source code, documentation, test fixtures and fingerprint databases that quote the header are not mistaken for PHP.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var Marker = []byte("X-Powered-By: PHP/")
Marker is the header string every PHP runtime carries.
Functions ¶
func Executable ¶
Executable reports whether data starts like an ELF, Mach-O or PE file. head may be just the first bytes of the file.
Types ¶
type Binary ¶
type Binary struct {
Path string `json:"path"`
// Version is the PHP_VERSION string compiled in, exactly as found.
Version string `json:"version"`
// Zend is the Zend engine version compiled in.
Zend string `json:"zend_version"`
// SAPI is how this file runs PHP: cli, fpm-fcgi, cgi-fcgi, apache2handler,
// litespeed, frankenphp, embed, or unknown.
SAPI string `json:"sapi"`
Size int `json:"size"`
// Digests of the file, used to confirm it is the file a package installed.
MD5 []byte `json:"-"`
SHA1 []byte `json:"-"`
SHA224 []byte `json:"-"`
SHA256 []byte `json:"-"`
SHA384 []byte `json:"-"`
SHA512 []byte `json:"-"`
// Problem is set when the file is a PHP runtime but its version cannot be
// trusted (several different versions, or a Zend version that contradicts it).
Problem string `json:"problem,omitempty"`
}
Binary is one PHP runtime file.