Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1049261
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T16:35:15+00:00 2026-05-16T16:35:15+00:00

We are developing several web applications to run on our own server that will

  • 0

We are developing several web applications to run on our own server that will share a number of core classes as part of their MVC setup.

I’m thinking of putting the classes above the web root so all applications can autoload() those classes using just one copy and not worry about synching issues.

Specialised classes would go in their relevant web directory, but shared libraries would go under /var/www/shared-libraries or something similar.

Apart from the potential to crash all sites simultaneously with a bad line of code, is there any reason why I wouldn’t want to go down this path?

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T16:35:16+00:00Added an answer on May 16, 2026 at 4:35 pm

    Zend Framework is using that technique, which makes the entire application safe from outputting sensitive PHP code as plain text since everything is outside the document root, and using mod_redirect to know what module/controller/action to dispatch to.

    A basic project layout looks something like

    application
    - controllers
    - views
    - - scripts
    public
    - .htaccess 
    - index.php
    library
    - Zend
    

    and having ../library in your include path let’s you autoload all Zend classes (i.g. Zend_View) easily from anywhere in the application. Naturally, Zend also comes with class autoloaders for view helpers and other custom class prefixes, but this is beside the question scope.

    Since everything is outside the document root (/public), the only script a user could see (in case something goes wrong and users start to see exposed PHP code) is a call to the application bootstrap and other initialization lines (i.g. include paths and and some constants, but you could also have all these initialized by including another external file…).

    In short, yes it is a good idea, and a good practice, to put the core classes outside the document root. All you need, then, is to add the path to your shared library in the include path list with something like :

    set_include_path(implode(PATH_SEPARATOR, array(
        LIBRARY_PATH,
        get_include_path(),
    )));
    

    where LIBRARY_PATH is the relative or absolute path to your shared library.

    Be aware, however, that more paths you add, the slower autoloading classes will be. It is good practice to only have about 3 paths in there or less. Take a look at how Zend managed to get around this with their autoloaders.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am developing a web-service that will be used by several clients. I am
I am developing a web page that will be used in several different contexts,
I'm developing a web project that contains several modules (JSP, JS and CSS). What's
This is the scenario i have: im developing a web app that will list
I've been developing Microsoft Windows based applications (both desktop and web) for several years
I am developing a rather complex web application that invokes several externally executed processes,
I'm developing a class library that will be used in a number of different
I'm developing web application that uses AJAX a lot. It sends several AJAX requests
I am developing a website that requires several user types. I have been able
I am developing an iPhone app that displays several views, all acessed via Tab

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.