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 9315491
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 19, 20262026-06-19T02:22:46+00:00 2026-06-19T02:22:46+00:00

I’m looking for a way to disable PHP’s use of include_path in a project.

  • 0

I’m looking for a way to disable PHP’s use of include_path in a project.

Background

Perhaps you’re surprised: Why would I want to prevent the use of such a useful feature?

Unfortunately, while I’d consider the answer simple, it’s not simple to accurately describe:

In brief, include_path is (obviously) package-/library-blind.

More specifically, it’s possible to put two different versions of a library into two folders, both of which are in include_path, and ending up with executed code that is a mixture of both. Consider the following setting:

include_path=/some/server/path/lib:
    /var/www/apache/htdocs/yourApplication/library

Now imagine the canonical location for a library you want to use is in /some/server/path/lib and your build process places it there, but a developer is trying to patch a part of it and erroneously syncing the library to /var/www/apache/htdocs/yourApplication/library. Now imagine this happens:

/some/server/path/lib/moduleYouWant
    '--> A.php (old version)
/var/www/apache/htdocs/yourApplication/
    '--> SomeFile.php (uses B.php from module; previously used A.php)
/var/www/apache/htdocs/yourApplication/library/moduleYouWant
    '--> A.php (new version)
    '--> B.php (new file; uses A.php from module)

Suddenly, your application will mysteriously use or autoload (if your autoloader puts include_path to use, which most framework-supplied autoloaders do, as far as I’m aware) only half of the changes you made – the new B.php but the old A.php.

You may, of course, object to the setup I’ve described on grounds that it should never happen for other reasons. That’s fair. I’m likely to agree, even. The above scenario is a backwards-incompatible change, for example, and that’s not very nice.

Nonetheless, so far I’ve seen it happen twice in the wild (in a sufficiently complex project, with chroots muddying the water) and it’s eaten up countless confused debugging hours… and I don’t want to have that issue again. Not in this sort of constellation – or any other.

I don’t want PHP magically trying to find my files. I want PHP to demand I be specific about which files to load.

Why I don’t need include_path

With __DIR__ (or dirname(__FILE__) in older PHP versions), semantically ‘relative’ paths are easy to construct. And if I need live- and test-server distinctions, constants defining absolute locations are my friend.

So… I want non-absolute paths supplied to include() (and related functions) to fail.

This stackoverflow question from 2011 tells me that I can’t blank include_path. Is there perhaps some other way I can disable the feature? My Googlefu is weak, but nonetheless I have a creeping suspicion the answer is ‘no (unless you patch PHP itself)’.

If someone knows of a way I can put a stop to this other than by code convention agreement (or the related “please don’t use include() but this custom function I wrote“), I’d love to know. 🙂

  • 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-06-19T02:22:47+00:00Added an answer on June 19, 2026 at 2:22 am

    You indicate that the root of the problem is that you have developers writing bad relative includes where they should use be using absolute includes or autoloading.

    The solution to this is not technical but cultural. You can enforce correct behavior by adding a pre-commit-hook to your versioning-system that tries to detect erroneous includes (either relative includes, or just all includes) and block the commit.

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

Sidebar

Related Questions

I want to count how many characters a certain string has in PHP, but
I want use html5's new tag to play a wav file (currently only supported
I would like to count the length of a string with PHP. The string
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am confused How to use looping for Json response Array in another Array.
I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to understand how to use SyndicationItem to display feed which is
this is what i have right now Drawing an RSS feed into the php,
I have a French site that I want to parse, but am running into

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.