rfc:phpp
no way to compare when less than two revisions
Differences
This shows you the differences between two versions of the page.
Previous revisionNext revision | |||
— | rfc:phpp [2012/04/12 23:06] – status kriscraig | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== Request for Comments: New File Type for Pure-Code PHP Scripts ====== | ||
+ | * RFC Version: 1.10 | ||
+ | * Target PHP Version: 6.0 | ||
+ | * Date: 2012-04-12 | ||
+ | * Author: Kris Craig < | ||
+ | * Status: Under Discussion | ||
+ | * First Published at: http:// | ||
+ | |||
+ | |||
+ | ===== Abstract ===== | ||
+ | |||
+ | This RFC proposes the creation of a new .phpp file type. This file type will be parsed by the webserver as 100% PHP code; that is, all code will be executed //without// <?php and ?> tags. No raw HTML output would be allowed in these scripts using ?>, though echo/print and other output statements will continue to work in those scripts without any restriction. | ||
+ | |||
+ | ===== Background ===== | ||
+ | |||
+ | ==== PHP as a Templating Language ==== | ||
+ | |||
+ | PHP was originally created to operate as server-side code embedded within a block of HTML with the intention of allowing dynamic, conditional output to be directly and easily inserted into HTML pages. | ||
+ | |||
+ | ==== Modern Frameworks and Standards ==== | ||
+ | |||
+ | The web has evolved considerably since the late 1990s when most people' | ||
+ | |||
+ | As the web has evolved, so too have the various methods for developing in it. PHP now largely takes the form of classes and code-only libraries that are hooked from the UI layer of the modern website. | ||
+ | |||
+ | ==== The Tags ==== | ||
+ | |||
+ | Over the years, people have occasionally called for one of a few fundamental changes to how PHP scripts are executed, typically involving the removal of the <?php and/or ?> tags or changing it so that PHP files default to PHP mode instead of HTML when parsing. | ||
+ | |||
+ | This RFC does **NOT**, in any way, change the way in which .php scripts are parsed, period! | ||
+ | |||
+ | ==== The Webserver ==== | ||
+ | |||
+ | The webserver must be configured so that PHP will be called to execute a file with a given extension (.php), otherwise the code would just be displayed as text. | ||
+ | |||
+ | ===== Current Behavior ===== | ||
+ | |||
+ | The <?php tag, contained within one of these files, tells the webserver to, in essence, " | ||
+ | |||
+ | ===== The Problem ===== | ||
+ | |||
+ | Pure-code PHP files (i.e. PHP scripts that have <?php at the top and never use the ?> tag; thus never " | ||
+ | |||
+ | The first observer might then counter that having to include a <?php tag at the top of every file, while admittedly very low-impact, is tedious and sometimes even forgotten (though not for long if the developer bothers to test his/her own code). | ||
+ | |||
+ | ===== The Solution ===== | ||
+ | |||
+ | It is my view that both of these hypothetical observers are correct. | ||
+ | |||
+ | A .phpp file would behave exactly like a .php file, //except// for the following: | ||
+ | |||
+ | * Instead of defaulting to HTML, everything within the file is parsed as if it was in a <?php tag. | ||
+ | * If ?> tag is reached within one of these files, an E_RECOVERABLE_ERROR will be thrown and those tags, as well as any raw HTML code, will be ignored. | ||
+ | * If a <?php tag is reached within one of these files, an E_NOTICE error will be thrown. | ||
+ | * Any .phpp scripts included by a .phpp file must also adhere to these rules and contain only pure HTML code. | ||
+ | * A regular .php script cannot be included from a .phpp script. | ||
+ | |||
+ | ==== Inclusion of Mixed Code ==== | ||
+ | |||
+ | It has been suggested that regular .php files that contain raw HTML should be able to be included by a .phpp file because someone might want to include a regular .php library from a .phpp file. Unfortunately, | ||
+ | |||
+ | Besides, such an allowance is completely unnecessary anyway, since using non-horrible architecture can achieve the exact same result without having to pollute your .phpp stack. | ||
+ | |||
+ | {{: | ||
+ | |||
+ | ===== Final Thoughts ===== | ||
+ | |||
+ | I targetted this for PHP 6 since, even though it doesn' | ||
+ | |||
+ | With this new feature, developers will be able to adopt best-practices architectural models with far greater ease. Companies that develop and maintain PHP implementations will be better able to hire designers with little-to-no programming ability and vice versa. | ||
+ | |||
+ | ===== Vote ===== | ||
+ | |||
+ | Voting has not yet been initiated. | ||
+ | |||
+ | ===== Changelog ===== | ||
+ | |||
+ | Version 1.10 : Status => Under Discussion. | ||
+ | |||
+ | Version 1.00 : Initial proposal. | ||
rfc/phpp.txt · Last modified: 2017/09/22 13:28 by 127.0.0.1