views:

40

answers:

6

I am defining naming conventions for a simple plugin framework. For example:

  • index.php - the main plugin file
  • info.php - returns an array with plugin information
  • install.php - self-explanatory

can you think of an elegant, short-hand name for a PHP file that contains the code that is to be executed before any HTML is output? Do any examples from other frameworks come to your mind?

What I have been thinking of:

  • head.php - misleading, could be mixed up with HTML <head>
  • before_output.php - clumsy, too long
  • init.php - not exactly correct
  • start.php - current favourite
+1  A: 

How about prefix.php, preface.php, or prologue.php?

Ignacio Vazquez-Abrams
Nice, I like *preface*.
Pekka
Similar to preface is "preamble".
Robert
or simply "pre"
thetaiko
+1  A: 

what about:

  • pre_render.php
  • pre_load.php
  • pre_output.php
  • initializier.php
Robert
+1  A: 

I like header.php.

Jacob Relkin
A: 

You can do a lot of things before outputting HTML. What is the file doing? How about

  • bootstrap.php
  • setup.php
  • configure.php
  • run_before.php
  • predispatch.php
Gordon
+1  A: 

Coming from a PHP background, I like the idea of prepend.php (and append.php if you have something that must come after everything).


Why is that ? Because of the PHP configuration directives called auto_prepend_file and auto_append_file (quoting) :

Specifies the name of a file that is automatically parsed before the main file.

And

Specifies the name of a file that is automatically parsed after the main file.


But it might not be immediate to get used to those names for someone who doesn't have a PHP background, like someone who mostly works with HTML.

Pascal MARTIN
A: 

My framework uses this kind of structure:

/
|-- layouts
|   |-- layout.header.php
|   |-- layout.footer.php
|-- ...
|-- index.php

Since header and footer can be confusing, I prepend the "layout" prefix to indicate that these files are HTML-based.

"Header" actions (like initializing objects or so) can be placed on something like "app.init.php". (Since I also studied .NET, I'm confortable with the namespace-like filenames, with dot-delimited logical categories).

"index" handles all app/web operations; hence, the program flow. What's between "header" and "footer" files is a page file, that I usually build with templates.

Joel Alejandro