PHP require () giving 500 error

0

I have a system recently developed in PHP7 on Windows, and I decided to migrate to Debian9. At the moment everything works, however the autoload (psr-4) located in vendor has problems requesting the classes, returning error 500 in the browser.

I executed tail -f /var/log/apache2/error.log and it returns PHP Fatal error: require(): Failed opening required 'Src/Core/Router.class.php' (include_path='.:/usr/share/php') in /var/www/html/project/vendor/autoload.php on line 16 .

I have tried to use absolute as well as relative path, but none works.

Tests

  

When I run is_writable or is_readable it also returns the error.

     

I created an index.php in root (/ var / www / html /) and included the index.html file inside the project and it worked; so I've discarded permissions, which are: folder (755) / files (644).

     

In the same index.php file I checked if the Router.class.php exists and it returns true. But if you do this in autoload it returns false.

I have always worked with Debian and this problem has never occurred.

References

link

link

    
asked by anonymous 08.05.2018 / 16:53

1 answer

0

Error 500 is gener- al, ie no use looking specifically for it, you have to read the error message from the LOG. The error in

  

PHP Fatal error: require (): Failed opening required 'Src / Core / Router.class.php'

This means that the file does not exist, the possible reasons are:

Case-sensitive:

You are using a Linux or Mac OSX server, then:

  • The ./Src folder is actually small and should be ./src

  • Or the Router.class.php file should be router.class.php in your autoload

On Windows systems you are case-insensitive, so it probably works, but if you do this in the Foo.php filename and require foo.php in a Debian / Fedora / Mac / etc it will not work. p>

File name is wrong:

It can then be a typing error, either in the file name or in the path (ie not in the folder), regardless of whether it is absolute or not.

The only way to be sure is if you tell if you enter the minimum as:

  • Is this ( Router.class.php ) a third-party framework installed via composer?
  • You created the Router.class.php and added it manually?
  • Have you set up as composer.json ? (post it in question)
08.05.2018 / 17:01