Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:131030 X-Original-To: internals@lists.php.net Delivered-To: internals@lists.php.net Received: from php-smtp4.php.net (php-smtp4.php.net [45.112.84.5]) by lists.php.net (Postfix) with ESMTPS id 410F81A00BC for ; Thu, 28 May 2026 04:03:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1779940995; bh=T+obliDZAulOTyccSq1fRO6TivLF6E51AYjtj/9D3xE=; h=From:Subject:Date:References:To:In-Reply-To:From; b=JCwZNEypMBSDd2Xc5SkLxQ/SzZ2rm+3Gi6XpeFo8L5XdFmwDYKF8Bk9OXN9/jaPnF j7+5e9JvDtxgBp7muthnQ8+MztiEzbiTuGDX30ix1Xf0bjtrvtqDkeVo7lKxnq3qYZ OrUWUEywsJF++RKevhrnpd251KzCmj6OOEJuBnz2YTtuegboy7F03kVNUUPK9Y4h8f un5X296kcudMHVKzECekAfGzGmeqHBfOzxfPJRXX5YbQ3oHiJFLEp9eUYXidjik6BX glcHegYvjNwXHQXwSoQ/A7C35ILuC1mOGS280IkyEGixMRrcPnE9IuN1lMHcd5KdZE tzV4GHGsLMkpA== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 479FF180056 for ; Thu, 28 May 2026 04:03:11 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on php-smtp4.php.net X-Spam-Level: * X-Spam-Status: No, score=1.9 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,FORGED_GMAIL_RCVD, FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,T_SPF_TEMPERROR autolearn=no autolearn_force=no version=4.0.1 X-Spam-Virus: No X-Envelope-From: Received: from mail-wr1-f53.google.com (mail-wr1-f53.google.com [209.85.221.53]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Thu, 28 May 2026 04:03:10 +0000 (UTC) Received: by mail-wr1-f53.google.com with SMTP id ffacd0b85a97d-44dd5cb0f81so8672346f8f.0 for ; Wed, 27 May 2026 21:03:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1779940984; x=1780545784; darn=lists.php.net; h=message-id:in-reply-to:to:references:date:subject:mime-version :content-transfer-encoding:from:from:to:cc:subject:date:message-id :reply-to; bh=T+obliDZAulOTyccSq1fRO6TivLF6E51AYjtj/9D3xE=; b=BomytxYA1qKk7Xl0FpXmR2Olwi/93M8kTu1BMhBIYoo7tInrdMhDjvgf7iD3sV+hu/ EFUy5XyKuy03wazQqTpVvnaCLO3IwRAHqjLzqXk8xjF89uK0GquEqV/Fh5zscyqWRFIt Q/y/DC7ewegSxL+MeMGQAJVEbgGqeOplEoaW5j2RFz3DDPM0vYSPdgG2dbYN5uVxQ4KP i4Ax7JmO6s9dvVT9JqU33iaJdCdYbeAAP5Udachy2IIGv542UE/W1vF0kITk4ruBG/9S 2cgOzpwnkkxjlH/Z+XkKd3GmqMXw6F7UgbHQTJg36c676nOrsjTFEgWIakZMiueBx4cN 3zkA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779940984; x=1780545784; h=message-id:in-reply-to:to:references:date:subject:mime-version :content-transfer-encoding:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=T+obliDZAulOTyccSq1fRO6TivLF6E51AYjtj/9D3xE=; b=CRsAwSggxdx25Lu6VIrkxgPtB3XuzwnqIMJX4HHenZZF9qWgUdtQEBBMCnhIpE+0mM 6XT4WiSIm5lAzvIxIJ/ZUrOn8MD9KP5bktM6tCVf8nZELPTQabQ06AZIM1wg/yR45/5L 1pElcdbkHgLDEQOhy8L9x2N9jhggnwbHyDgfuxuPO8C6faM7xBAieDrbWB42gjrUtPZH 7nVLawpWoBSf8yZhOttag3ALfjNsZuKcWKYYEo52XRiVQfRHs8ggWIjq4zRW8zaE8dfj L2uZtoHqRepJaxaNk4xwVioMOraWOA+wiGY+A223e+hbpI+ku5zAJ4q65ICq5AQQz4D6 Hf7g== X-Gm-Message-State: AOJu0YyErW5zwcSsiOBiYhwHzoFK6380yGw+uoQ2X0jTt0nROCvO07e/ RJNw06FHQwPaAdstG53xGCzv3QH1Rd3F3PZVv2t4Q7qxBLokISBP/YbOizRaWjN5 X-Gm-Gg: Acq92OEONCZ3PfyHSCutIJ5MkPucBSER47uw4V1zVzTP8km8zqWMw7yNheRtBx2MFl7 KDDKzJJPnqtA6l+H0TfOwXSheNPQrXyRtnhShjWscHbvQ6zOvnHawA5EI5/fD6f9s/ZUXzG8Qxj 1jxYPEB2hCmdX1XhsiKr9ThWO2zTRwzLv9SXTi0q80XZgTtowUVFQXM9MKl0oQULhCmUxfgT+py jrQNE0uaWMONk9iWRIEdD7AJmXYq4A3Hxnh85dS8yZ5uCVqA3evQaqzC/eO/FWcjd4nfdAUXdSn qR7lPqT6oOv27D6RtKw67wIzPkPYqqU3cKJ1XhUqBE/bUOEYfkjuXeyW5jVREk+udSm1GB9z9tz 2xgL1EQUXCWNbYP9FpMEkbRF4+dHoY169qNpQUrbTklBCIf4Ga4g/+318/nO0uuj2Tsz3MTGckC H4rkX4FDEQa39H9303cN2EvRgfJ+vi6FfGE4pxt7rUxpR/sLQpQKOjEwl1MSZuMeCBmmdrpRI6i d4BC6s0vC2DnA== X-Received: by 2002:a5d:64e7:0:b0:45e:8e69:955a with SMTP id ffacd0b85a97d-45ea314859cmr46955795f8f.9.1779940984236; Wed, 27 May 2026 21:03:04 -0700 (PDT) Received: from smtpclient.apple (p508ccfb8.dip0.t-ipconnect.de. [80.140.207.184]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-45edb5a2a7esm10898057f8f.20.2026.05.27.21.03.02 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 27 May 2026 21:03:02 -0700 (PDT) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Precedence: list list-help: list-unsubscribe: list-post: List-Id: x-ms-reactions: disallow Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3864.600.51.1.1\)) Subject: Re: [PHP-DEV] [Pre-RFC] Pure-code source files via .phpc extension Date: Thu, 28 May 2026 06:02:50 +0200 References: <9E95EA03-B86A-D248-A980-B1E838F94C13@hxcore.ol> <20260527131921.086BB1A00BD@lists.php.net> <8AE9A269-2E40-42F0-A0F8-C6690B2935FE@gmail.com> <20260528023149.C97961A00BD@lists.php.net> To: internals@lists.php.net In-Reply-To: <20260528023149.C97961A00BD@lists.php.net> Message-ID: <76D39851-7DAC-4F56-9615-B98B0A918770@gmail.com> X-Mailer: Apple Mail (2.3864.600.51.1.1) From: hmennen90@gmail.com (Hendrik Mennen) > Am 28.05.2026 um 04:31 schrieb Ben Ramsey : >=20 > On 5/27/26 09:27, Hendrik Mennen wrote: >>> Am 27.05.2026 um 15:19 schrieb Ben Ramsey : >>>=20 >>> The problem with assigning meaning to a file extension is that the >>> interpreter (currently) doesn't care what the file extension is. As = long >>> as it's text, it'll process any file and execute what comes after = any >>> > Right, that is the current behavior, and changing it is exactly what = the proposal is about. The engine would learn to check the file = extension at the entry point (zend_compile_file for SAPI/CLI, and the = include/require family for nested loads) and use that to set the initial = lexer state. The .php behavior remains untouched. >=20 >=20 > The behavior right now is that the file extension isn't checked. So, = whether it's .php, .phtml, .php3, .rb, .py, or .txt doesn't matter. = Using .php is a convention, not a requirement. If the proposal places = any restrictions on the file extension, that's a major BC break. >=20 > So, the logic will need to be something like: if .phpc, then parse = assuming there are no =20 >=20 >> That said, you point indirectly at something I do need to address: = there are entry paths where the engine does not have a filename, or has = one it should not trust. Off the top of my head: >> - stdin (cat foo.phpc | php). No filename available. Options: require = an explicit CLI flag (php --pure), or simply not support this path and = document it. >> - eval(). Operates on strings, not files. Extension is irrelevant = here; eval() continues to require > - Phar archives. Internal entries have filenames, so dispatch by = extension should work, but I would need to verify. >> - include of a URL stream (rare, often disabled). Same question. = Probably handled by extension on the URL path. >> I will work these out explicitly in the RFC draft. Thanks for = surfacing it. >>> At the risk of bike-shedding, I think it could be easy for others to >>> confuse .phpc files as byte-code files, since it's common to see = Python >>> byte-code files with the .pyc extension. >> Fair point, and one I had not weighed heavily enough. The Python .pyc = parallel is real and would cause exactly the kind of one-time confusion = that adds friction to adoption. Boutell's 2012 RFC used .phpp (Pure PHP) = for the same purpose, which avoids the bytecode association. I am open = to .phpp or other suggestions; the disambiguator matters less than the = mechanism. >=20 >=20 > I'm still unsure about assigning any meaning to the extension. Maybe = this is something that could be handled at the SAPI configuration level = similar to how .phps files are configured? Likewise, maybe the CLI = should have a `-p` flag that tells it to process the input without = checking for =20 > For what it's worth, `php foo.phps` still executes the file. You need = to run `php -s foo.phps` to output HTML syntax-highlighted source. The = .phps extension has no meaning to the interpreter. >=20 > That said, I'm not sure how you'd handle this with include/require or = in Phar files. >=20 >=20 > Cheers, > Ben Hi Ben, > I'm still unsure about assigning any meaning to the extension. Maybe > this is something that could be handled at the SAPI configuration > level similar to how .phps files are configured? Thanks, and also thanks for the correction on .phps. I had the wrong = mental model there: I assumed the extension carried interpreter meaning, = when in fact it is purely an Apache handler convention plus the php -s = flag. Useful to have that straight before drafting. That said, SAPI-level configuration is exactly the path I do not think = can carry the full mechanism, and I think your own observation at the = end of your mail is the reason: > That said, I'm not sure how you'd handle this with include/require or > in Phar files. Right, and this is the crux. include, require, and Phar entry resolution = all happen below the SAPI layer, inside the engine. A web server handler = mapping .phpc to a pure-code mode would work for the directly-served = entry file, but the moment that file does require __DIR__ . = '/lib/something.phpc', the engine has to decide what to do with the = included file on its own, with no SAPI in the loop. The same applies to = CLI: php script.php works through one path, php -f script.php through = another, both bypassing any web-server config. And Phar internals never = see SAPI at all. So I think the dispatch has to live in the engine. The extension is just = the most ergonomic signal I can think of for the engine to use, but I am = open to other engine-level signals (a magic first line, a declare-like = marker, even a per-Phar manifest flag). What I do not think works is = delegating the decision to layers above the engine, because those layers = do not cover all entry paths. > Likewise, maybe the CLI should have a -p flag that tells it to process > the input without checking for