root/
controller/
controller.php
view/
view.php
index.php
I launch the index.php, it includes controller.php and from controller.php I want to include view.php. What's the best way to do it?
The problem is NetBeans autocomplete wants me to format the path like this:
include '../view/view.php';
But on the server, when index.php is launched, it says:
Failed opening '../view/view.php' for inclusion (include_path='.') in /mnt/.../controller/controller.php
Possible solutions:
- Now, I write inclusion from index.php include 'view/view.php'; manually (but I can't use autocomplete)
- I might put chdir(__ DIR __); before the inclusion and stole the current directory (I think it's stupid to write it before every inclusion)
- I might use project.properties hack from https://netbeans.org/bugzilla/show_bug.cgi?id=219236#c6 (not clean)
I think every PHP programmer has to deal with this but surprisingly, the web is silent. Note that any form of include ROOT.'view/view.php' is not understood by autocompletion https://netbeans.org/bugzilla/show_bug.cgi?id=186971
Thanks!