Ok following issue I am having and I will try to give as much info as possible.
I have written a custom cms for learning purposses.
As develop environment I used vagrant with a precission32 box. ( situation 1)
For reasons not important I temporarly worked with Xampp. ( situation 2)
This last week I created a vagrant environment (ubuntu trysty 64) again to work with. (situation 3)
How it's built.
or situation 1 I can't recall how it has been built up.
situation 2 (xampp):
PHP 5.6.15 Apache 2.4.17 Standard ( for Xampp) apache modules enabled
situation 3 (vagrant)
PHP 5.5.9 Apache 2.4.7 All apache modules installed as it is in xampp
The problem
In situation 1 everything worked just fine
In situation 2 everything is working just fine. No problems
In situation 3 I get an fatal error on an include
The following errors I get:
Warning: include(libs/DKW\Tracking\Logged.php): failed to open stream: No such file or directory in /vagrant/DKW-fms/index.php on line 40
Warning: include(): Failed opening 'libs/DKW\Tracking\Logged.php' for inclusion (include_path='.:/usr/share/php:/usr/share/pear') in /vagrant/DKW-fms/index.php on line 40
Fatal error: Class 'DKW\Tracking\Logged' not found in /vagrant/DKW-fms/public/main/template/nav.php on line 2
The logged.php file does exist
Line 40 in index.php
/**
* Load classes from libs
*/
spl_autoload_register(function ($class) {include LIBS. $class.".php";});
LIBS is defined in a different file.
define ('LIBS','libs/');
So now for the fatal error:
Line 2 in nav.php:
$this->logged = new DKW\Tracking\Logged();
The above codes were built in situation 1 and worked fine. During the other situations, as far as I know, nothing has been changed that could cause these problems.
I can´t figure out what is wrong. Especially because in Xampp there is absolutely no problem. Same files are used because in both environments the path is directed to the same folder.
Hopefully somebody can give me a pointer to where to look because I don´t see it anymore.
Edit:
Because I'm having second thoughts about the rights on my folder structure I have added my virtualhost file. Maybe something is wrong in this that causes this problem.
<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName dkwfms.com
ServerAlias dev.dkwfms.com
DocumentRoot /vagrant/DKW-fms
<Directory />
Options FollowSymLinks
AllowOverride FileInfo
</Directory>
<Directory /vagrant/DKW-fms>
Options +Indexes +FollowSymLinks +MultiViews
AllowOverride FileInfo
Order allow,deny
Allow from all
Require all granted
</Directory>
loglevel warn
ErrorLog ${APACHE_LOG_DIR}/error_dkw-fms.log
CustomLog ${APACHE_LOG_DIR}/access_dkw-fms.log combined
</VirtualHost>
PROBLEM SOLVED
In the errors I noticed the trailing slashes in my include part. On faceboook Elmar also pointed me to those trailing slashes. For this I had to rewrite my autoload_register.
If anybody faces this problem as well I did the following
My class folder is defined in another file (this is not needed for the solution)
define ('LIBS','libs/');
Now for the autoloader:
spl_autoload_register(function($className)
{
$namespace=str_replace("\\","/",__NAMESPACE__);
$className=str_replace("\\","/",$className);
$class=LIBS . (empty($namespace)?"":$namespace."/")."{$className}.php";
include_once($class);
});
Lets hope this will help others to.