Reputation: 1029
I am using a hosting solution for my Zend Framework app, but cannot get it to load the application/bootstrap.php file.
When I ftp on to the server, my doc root is /webspace/httpdocs/euro.millionsresults.com
I placed the application, public, library etc. dirs in this directory.
I then created a .htaccess, as per http://akrabat.com/zend-framework/zend-framework-on-a-shared-host/
/webspace/httpdocs/euro.millionsresults.com/.htaccess
RewriteEngine On
RewriteRule .* index.php
This rewrites everything to my index.php file, which then includes the public/index.php file of the ZF, which is correct and works fine. The index.php file is:
/webspace/httpdocs/euro.millionsresults.com/index.php
<?php
include 'public/index.php';
If I put in an echo in the public/index.php file, it works fine, proving public/index.php is now called when you try to access the site.
The problem is, the public/index.php file needs to include the ../application/bootstrap.php file:
/webspace/httpdocs/euro.millionsresults.com/public/index.php
<?php
echo "this is working";
require('../application/bootstrap.php');
However, application/bootstrap.php does not get included.
If I put a die at the very top of application/bootstrap.php, nothing gets rendered.
I have tried the following for public/index.php:
require('../../../application/bootstrap.php'); require('/webspace/httpdocs/euro.millionsresults.com/application/bootstrap.php');
But nothing works in including application/bootstrap.php.
Does anyone know what to do here? It is a cheap host I am on, with no access to php.ini.
Additional Info:
The issue seems to be with the include_path. When I do get_include_path(), I have:
:/php/includes:/usr/share/pear:/usr/libexec/php4-cgi/share/pear:/opt/alt/php55/usr/share/pear:/opt/alt/php54/usr/share/pear:/opt/alt/php53/usr/share/pear
I can set_include_path(), but what do I set it to?
I have tried:
set_include_path('/webspace/httpdocs/euro.millionsresults.com/application' . PATH_SEPARATOR. get_include_path());
set_include_path('/../../../application' . PATH_SEPARATOR . get_include_path());
set_include_path('../application' . PATH_SEPARATOR . get_include_path());
None of which work, i.e. when I have the following in my public/index.php file, I always get "does not exist":
<?php
echo "In file public/index.php <br>";
set_include_path('/../../../application' . PATH_SEPARATOR . get_include_path());
echo get_include_path();
if (file_exists('/../application/bootstrap.php')){
echo "<br>exists";
}
else {
echo "<br>does not exist";
}
It doesn't matter what file I check existence of - any file in the application folder, or any folder not in public, is not found.
Upvotes: 0
Views: 212
Reputation: 3663
In your public/index.php
file, this line:
require('../application/bootstrap.php');
assumes that your current working directory is public/
and that relative to this dir, one dir up, there is an application/bootstrap.php
- relative require
calls are relative to the current working directory or to the include_path. It seems that the ZF code assumes public/
is the document root, which is not true in your case.
In Web environments, usually, the current working directory is the document root. So in your case, you may want to change require('../application/bootstrap.php')
to:
require('application/bootstrap.php');
If that does not work, I suggest finding out what the current working directory is vs. the public/index.php
directory by running something like:
var_dump(getcwd(), __DIR__);
(if your PHP version is outdated, replace __DIR__
with dirname(__FILE__)
)
and, do your require
call relative to that.
Upvotes: 1