php require does not work

Asked

Viewed 338 times

-1

I have a php site hosted on a linux server in AWS, on the local server, which is windows, it is working normally, but hosted on this other server it does not work the requires.

I’m calling the pages like this:

require_once '../Model/model.php';

For testing, I just put that code on the same page, and the page gives this error: Erro esta página não está funcionando

If I give a header('location: ../Model/model.php')it redirects to this right page, however the require does not work, someone could give me a light, grateful already!

Edit: As requested, below is the folder structure:

inserir a descrição da imagem aqui

The file that has this require code is inside the folder Controller, and the requested file, within the Model

  • 1

    Make sure you have no problem with upper case and minuscule letters in the code and file names.

  • @rray, yes, I thought it could be this and it is correct, so much so that in the header it redirects

  • Have you tried using the constant DIR before require? For example: require_once DIR . '../Model/model.php'; . In a moment the require error is in finding the file. __DIR (http://php.net/manualen/language.constants.predefined.php)

  • can be, I’ll give a check, thank you

  • @elvex put it like this: require_once _ DIR _ '../Model/model.php'; but continued the page without responding(DIR with 2 underline and without the spaces between them)

  • @Leonardowalbrinch Click on [Edit] and post the structure of your files. It gets easier.

  • @Valdeirpsr, I edited and put a photo and a description of how the structure is.

  • @Leonardowalbrinch , her case controller be called by index php., use require_once 'Model/model.php';

  • @Valdeirpsr, he’s called by the page login.php, inside the briefcase View. Another strange thing is that it does not pass of this requisition, below her I put to give a echo "a" and that a did not appear, but if I put before the require he appears.

  • Usa echo __DIR__ to know which directory you are in.

  • Is in /var/www/html/Controller, I was wrong before, is in Controller , not in View

Show 6 more comments

1 answer

2


I found the solution to the problem, the default php path was not configured, I had to go to php.ini, find the line you have include_path, she was commented, so I decoded and switched to the path of the root folder of my project.

In my case it’s like this:

include_path = "/var/www/html/"

Then I just restarted the service and it worked. Thanks to all who helped!

Browser other questions tagged

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