0

I recently shifted my development enviroment from windows to ubuntu. Lets say I require a file like this in windows:

require('core/main.php');

Now I want to do that same thing but I'd have to do it like this in ubuntu:

require('/var/www/project_folder/core/main.php');

I have many projects and most of them use the windows method of fetching the file, is it possible to do the same in linux like in windows? Do I have to set some link somewhere?

Irfan
  • 85
  • 10
  • 1
    Note the one you mention for Ubuntu is like `/var/...`, that is, full path, whereas in windows you say `core/...` - relative path. So if you use relative paths in ubuntu, it should be fine. – fedorqui Dec 28 '15 at 15:29
  • 5
    That's most probably not an issue of Linux or Windows, but how your [`include_path`](http://php.net/manual/en/ini.core.php#ini.include-path) is configured. Check your include paths on both development environments. – helmbert Dec 28 '15 at 15:31
  • That seemed to be the issue. I set the include path to the project directory and relative paths are now working. `set_include_path('/var/www/project_directory');` – Irfan Dec 28 '15 at 16:41
  • You can also define relative paths based on `__DIR__`, like `require_once(__DIR__ . '/core/main.php')`. – Ulrich Eckhardt Dec 28 '15 at 17:36

1 Answers1

0

That's most probably not an issue of Linux or Windows, but how your include_path is configured. Check your include paths on both development environments. – helmbert

That seemed to be the issue. I set the include path to the project directory and relative paths are now working. set_include_path('/var/www/project_directory'); – Irfan Dahir

Armali
  • 18,255
  • 14
  • 57
  • 171