On 4/9/12 5:38 PM, "Tom Boutell" <t...@punkave.com> wrote:

>On Mon, Apr 9, 2012 at 8:27 PM, Luke Scott <l...@cywh.com> wrote:
>> Tom,
>>
>> On 4/9/12 4:47 PM, "Tom Boutell" <t...@punkave.com> wrote:
>>
>>>Let me be very clear about that... I am NOT proposing that <?php at
>>>the top be mandatory in a file loaded in code mode! I don't want to
>>>type it ever again outside of a template file, personally. See the
>>>title of the RFC.
>>
>> And the problem is what exactly? Legacy code would be 5.4 code. PHP 5.3
>>is
>> supported and code will be floating around for it for years to come. If
>>I
>> found a library on Github that was 5.4 compatible (starts with <?php) I
>> don't want to remove the starting <?php just so my autoloader will read
>> it. Ideally I'd like to be able to check out that code without touching
>>it.
>
>The RFC doesn't create this situation. .phpc files (by convention)
>would be loaded in code-first mode, .php files (your existing 5.4
>libraries) would be loaded in html-first mode. So the backwards
>compatibility problem you describe doesn't exist in the RFC.


Given that an autoloader just has the class name with the attached
namespace, how is it to know whether or not to load a .php file or a .phpc
file? I'm not going to add a stat in my autoloader (file_exists) just to
check for the existence of one or the other.

With APC I'm able to do apc.stat = 0. The stat happens once per file
before the opcode is cached. After that no stats happen. Adding a
file_exists bypasses this.

Now as others have said: File extension is irrelevant. It's up to the web
server to determine this.

>
>> Leaving out the starting <?php tag would be a much bigger security risk
>>if
>> loading code with an older version of PHP. An older version of PHP is
>> going to see this code as plain text printed to the browser. In fact I
>> would probably make sure my config files ALWAYS started with a <?php tag
>> to ensure passwords were safe.
>
>This would only be done in .phpc files, and those creating code for
>reuse elsewhere would probably only use .phpc files in libraries of
>reusable classes etc. Best practices put these outside the document
>root where Apache would not have the potential to serve them.

I would hope these files are outside the document root (I use Nginx, so
they are). But not everyone does this unfortunately.

>Of course in a pure PHP 5.x environment you could choose to configure
>Apache to serve .phpc files directly but I realize it would be a long
>time before anyone considered it best practice to write entry point
>.php files or PHP files containing passwords as .phpc files. Which is
>fine, because it is not a common practice to have more than one or two
>such in an entire framework-based application.

Not entirely sure everyone wants another extension though. Such things
shouldn't be in the RFC since it's a web server thing anyway.

>That said, allowing the skipping of an initial <?php tag at the top of
>the file probably wouldn't be a big deal to implement in code mode.


OK. If you can agree to this then I'm good. Perhaps only allow white space
before it (which is ignored - everything else throws a parse error)?

Luke



-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to