JOB: LAMP Artisan

Gary Thornock gthornock at
Fri Feb 28 14:36:10 MST 2014

On Friday, February 28, 2014 8:20 AM, keith smith <klsmith2020 at> wrote:
> I'm curious about putting my PHP code outside of the webroot.  Lets
> say you do so.  How do you run your code?  Do you put an index in
> the docroot and then what?  Are you using a symlink?
> It sounds like you think this is the only way and to do otherwise is
> wrong.  Every app I am familiar with is in the webroot someplace.
> For example:
> WordPress Joomla Drupal CodeIgniter laravel symfony cakephp ETC.
> I' ve only known of one person who put some of his code outside of
> the webroot.

I'm not going to go so far as to say it's "wrong" to have code in the
document root.  For a single script, or even a small collection of
scripts, that can work just fine.

For a larger application, particularly one that might have security
concerns like database connections and passwords, having the code
outside the document root is definitely a good idea.  It's not
required to use a framework for this (and I'm not entirely sold on the
notion that frameworks are always a good idea), but if frameworks are
your thing, the current versions of at least Symfony and Laravel do
keep a "public" folder for use as the document root, and all the code
is outside that folder.

In general the way this works is to have a single, small script in
the document root that uses include or require to pull in code from a
larger script outside the web root.

More information about the PLUG mailing list