2
votes

I have a small project in local. I'm working under Windows and with XAMPP. My file directory structure is:

Root directory:

C:\xampp\htdocs\routes
Under this folder, I have my bootstrap.php with the configuration I want to initialize my project.

Public folder:

C:\xampp\htdocs\routes\htdocs
Under this folder I have my index.php and my .htaccess.

Inside this .htaccess I have the following configuration:

php_value include_path .:/routes
php_value auto_prepend_file bootstrap.php

If I do a get_include_path() inside the index.php, it shows ".:/routes". But the message I get on my web browsers (after typing http://localhost/routes/htdocs) all the time is:

Fatal error: Unknown: Failed opening required 'bootstrap.php' (include_path='.:/routes') in Unknown on line 0

I have tried a lot of combinations of include_path inside the .htaccess:

php_value include_path ".:/routes"
php_value include_path .:../routes
php_value include_path ".:./routes"
php_value include_path ".:routes"
...

The configuration of my httpd.conf is:

DocumentRoot "C:/xampp/htdocs"
<Directory />
    AllowOverride none
    Require all denied
</Directory>
<Directory /routes>
    AllowOverride all
</Directory>

If I hard code the info in bootstrap inside the index.php, it works (at least this tells me the requirements inside bootstrap are well configured). I don't know what to do for my project to recognize the bootstrap.php.

What am I missing? What am I doing wrong?

Thank you in advance for your help

2
have you tried omitting Require all denied? if it's trying to include a file from the root folder then this may be preventing it from doing so - verbumSapienti
Yes, I've tried. And nothing. I tried also "AllowOverride all" inside <Directory />. It didn't work so I created the <Directory /routes> - pmguti

2 Answers

0
votes
  • First, the <Directory> block has no effect for include. Since this is not an Apache query, but rather a preprocessing order.
  • Second, use absolute paths in your include_path, to make it independent from where your files are sitting.
  • Third, make sure the path to bootstrap.php is openable by the user your webserver runs as, and that the file itself is readable.
0
votes

if you are using Windows it should be ;

php_value include_path ".;./routes"