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
How to Get the Current Page'S Full Url on a Windows/Iis Server
How to Generate a Screenshot of a Webpage Using a Server-Side Script
Insert - Number of Bind Variables Doesn't Match Number of Fields in Prepared Statement
PHP Check If File Contains a String
How to Split a String by Multiple Delimiters in PHP
What Are the Differences Between Composer Update and Composer Install
Send Post Request Using Volley and Receive in PHP
Laravel Migration: Unique Key Is Too Long, Even If Specified
Which Is Faster in PHP, $Array[] = $Value or Array_Push($Array, $Value)
Difference Between 2 Dates in Seconds
How to Re-Index the Values of an Array in PHP
How to Store File Name in Database, With Other Info While Uploading Image to Server Using PHP
Smtp Connect() Failed PHPmailer - PHP