1
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:

  1. Now, I write inclusion from index.php include 'view/view.php'; manually (but I can't use autocomplete)
  2. I might put chdir(__ DIR __); before the inclusion and stole the current directory (I think it's stupid to write it before every inclusion)
  3. 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!

Edvard Rejthar
  • 1,245
  • 13
  • 14
  • change `include '../view/view.php';` to `include dirname(__FILE__).'/../view/view.php';` – Chetan Ameta Jan 11 '16 at 06:26
  • As I stated in the end of the question, this syntax is not supported by autocompletion. There is an enhancement request for this since 2010 but with very low priority. – Edvard Rejthar Jan 12 '16 at 01:40

0 Answers0