PHP require_once without the need to pass the full path

Asked

Viewed 349 times

1

I am with a legacy project, where all PHP files connect to the database through the file "oracle_ado.php"

This file is in the folder ".. /inc/" and the rest in the folder ".. /Prod/".

I am mounting another server for this application, where the files in the folder ".. /Prod/" do not find the file "oracle_ado.php"

The require is as follows...

require_once ('oracle_ado.php');

and changes to...

require_once ('../inc/oracle_ado.php');

the wheel application smoothly.

On the current server runs without the need to inform the path ".. /inc/", can anyone tell me what it might be? What’s left to configure on the new server?

Both Linux servers

  • 1

    It is a linux or windows server ?

  • Oops, sorry... it’s Linux, I’ll edit the question

  • Navigate through the terminal to the root folder of an 'ls -l', from the command in the folder 'inc' and tbm from the same command in the folder 'Prod', do this in both Servers, and check that the file 'oracle_ado.php' did not end up in the folder Prod, I think the only explanation is to have mixed the files

  • The best thing would be to use one autoloader, so always calls only him instead of the classes.

  • Hello Raoni, because it is also I think... But I just wanted to avoid having to edit all the files.

  • If you give an error_reporting (E_ALL) in the file when it doesn’t work, what response does it give you ?

  • What appeared was 22519, about ls -l, is exactly the same as the current server

Show 2 more comments

1 answer

1

what should be on this server that is running within the PHP configuration in php.ini a redirect in the ;include_path = "variable.: /path/inc:/path/Prod" there should be the absolute path of the inc folder, or other folders so it should work fine, on the new server if you set it up like this should work, but the suggestion is you use the hosts and perform on it if you use, otherwise all other running applications will have access to the files since it is global this configuration on the server.

  • The new server include_path is also exactly the same as the current server. include_path = ".: /usr/share/Pear:/usr/local/jpgraph:/u01/desenv/inc"

  • when you call require or include it returns some PHP error as failed to open stream?

  • Hello Paul, I had no error, just stopped when I called a method of "oracle_ado.php". I also included the inc path in include_path, even though it didn’t work. I have this in the "stand-by", because I had to release the micro with the "new server". I believe that tomorrow I can continue this task.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.