PHP Fatal Error Failed Opening Required File

PHP Fatal Error Failed opening required File

It's not actually an Apache related question. Nor even a PHP related one.
To understand this error you have to distinguish a path on the virtual server from a path in the filesystem.

require operator works with files. But a path like this

                          /common/configs/config_templates.inc.php

only exists on the virtual HTTP server, while there is no such path in the filesystem. The correct filesystem path would be

/home/viapics1/public_html/common/configs/config_templates.inc.php

where

/home/viapics1/public_html

part is called the Document root and it connects the virtual world with the real one. Luckily, web-servers usually have the document root in a configuration variable that they share with PHP. So if you change your code to something like this

require_once $_SERVER['DOCUMENT_ROOT'].'/common/configs/config_templates.inc.php';

it will work from any file placed in any directory!

Update: eventually I wrote an article that explains the difference between relative and absolute paths, in the file system and on the web server, which explains the matter in detail, and contains some practical solutions. Like, such a handy variable doesn't exist when you run your script from a command line. In this case a technique called "a single entry point" is to the rescue. You may refer to the article above for the details as well.

PHP Fatal Error: failed opening required

Your path is preceded by a forward slash (/).

In a POSIX compliant system, if you have a path that starts with a forward slash, it means that it is an absolute path. The first forward slash represents the root of the filesystem.

Remove the forward slash from your path and you should then have a path that is relative to page.php.

EDIT: Since relative paths won't work, you can use dirname(__FILE__) to get the absolute path of the directory where the current file resides.

require(dirname(__FILE__) . '/includes/sess-start.php');

PHP fatal error opening required file

The path /app/bootstrap.php looks like a root path ( and the root isn't your website root, but your Mac root directory).

Change require path to __DIR__ . '/app/bootstrap.php', it means to require a sccript that in /app/bootstrap.php relative to CURRENT directory.

PHP Fatal error: require(): Failed opening required lib prestashop

Composer is case sensitive, some letters´ path were different.

Failed opening required file

The actual current directory is not always the same than the script you are running, especially inside a framework like you seem to use right now.

To make sure this is working, use

require_once dirname(__FILE__) . '/product.php';

on 5.3, you can even say :

require_once __DIR__ . '/product.php';

Hope this helps !



Related Topics



Leave a reply



Submit