I now upload my project to server in digital ocean,but I get this error in apache2 error log
require_once(/var/www/html/example/v1../include/DbHandler.php): failed
to open stream: No such file or directory
The 2 line that occur error is this,is working well in localhost,but when go to server it having the error above
require_once '../include/DBHandler.php';
require_once '../include/PassHash.php';
My directory is as below,I have to required DBhandler.php which in include folder,and index.php is from v1 folder(the place that require_once calling from).
-include
-DBhandler.php
-PassHash.php
-v1
-index.php
Here is the error log I got
[Fri May 19 12:33:19.621030 2017] [:error] [pid 5236] [client 115.133.247.14:575 22] PHP Warning: require_once(/var/www/html/example/v1../include/ DbHandler.php): failed to open stream: No such file or directory in /var/www/htm l/example/v1/index.php on line 9
What I tried so far
require_once $_SERVER['DOCUMENT_ROOT'].'/include/DBHandler.php';
require_once $_SERVER['DOCUMENT_ROOT'].'/include/PassHash.php';
And this,but none of this solve the problem
require_once __DIR__."/../include/DBHandler.php";
require_once __DIR__."/../include/PassHash.php";
Someone please help!Give me the a right direction,so I can proceed
Your require :
require_once '../include/DbHandler.php';
Your filename:
DBhandler.php
The name is different.
Change your require to:
require_once '../include/DBHandler.php';
May be your file name case: DBHandler intead of DbHandler
Just Remove the symbol / this on staring of file path your problem will be sovled.
require_once(var/www/html/example/v1../include/DbHandler.php): failed to open stream: No such file or directory
Related
I have a smarty project:
in the devidate_server.php:
<?php
include($_SERVER['DOCUMENT_ROOT'] . '/ax/ax_conf/CONSTANTS.php');
include($_SERVER['DOCUMENT_ROOT'] . '/ax/utils/utils.php');
...
there I will get error, but I can not get the error information, because I am develop WHMCS, I don't know the traceback's place. Give me information is the interface is blank.
But if I comment the include($_SERVER['DOCUMENT_ROOT'] . '/ax/utils/utils.php'); there will not get error.
There will shows the interface content.
in the utils.php there is:
<?php
include($_SERVER['DOCUMENT_ROOT'].'/qi_cloud/utils/http_util.php');
include($_SERVER['DOCUMENT_ROOT'].'/qi_cloud/qi_cloud_config/urls.php');
include($_SERVER['DOCUMENT_ROOT'].'/qi_cloud/libs/Requests/library/Requests.php');
Requests::register_autoloader();
function fetch_qicloud_access_tokens($params){
$result = Requests::post('http://localhost:8000/o/token', [
// headers
'Accept'=>'application/json'
], $params, [
// options
'auth' => new Requests_Auth_Basic([QICLOUD_whmcs_pj_client_id, QICLOUD_whmcs_pj_client_secret])
]);
return $result;
}
I don't know why I get include error, who can help me why I comment that line there will be normal?
EDIT-01
I get the error log:
[Wed Jul 18 11:26:52.040872 2018] [proxy_fcgi:error] [pid 29189:tid 139662983087872] [client 118.113.136.133:29440] AH01071: Got error 'PHP message: PHP Warning: require(/usr/local/httpd/htdocs/whmcs/qi_cloud/libs/Requests/library/Requests.php): failed to open stream: No such file or directory in /usr/local/httpd/htdocs/whmcs/qi_cloud/utils/http_util.php on line 9\nPHP message: PHP Warning: require(/usr/local/httpd/htdocs/whmcs/qi_cloud/libs/Requests/library/Requests.php): failed to open stream: No such file or directory in /usr/local/httpd/htdocs/whmcs/qi_cloud/utils/http_util.php on line 9\nPHP message: PHP Fatal error: require(): Failed opening required '/usr/local/httpd/htdocs/whmcs/qi_cloud/libs/Requests/library/Requests.php' (include_path='.:/usr/share/pear:/usr/share/php') in /usr/local/httpd/htdocs/whmcs/qi_cloud/utils/http_util.php on line 9\n', referer: http://www.example.net/clientarea.php
EDIT-2
the qi_cloud/utils/utils.php
<?php
include($_SERVER['DOCUMENT_ROOT'].'/qi_cloud/utils/http_util.php');
include($_SERVER['DOCUMENT_ROOT'].'/qi_cloud/qi_cloud_config/urls.php');
include($_SERVER['DOCUMENT_ROOT'].'/qi_cloud/libs/Requests/library/Requests.php');
Requests::register_autoloader();
...
the urls.php
<?php
require('./CONSTANTS.php');
define('qicloud_oauth_token_url', QICLOUD_BASE_API . 'o/token/'); //
the CONSTANTS.php:
<?php
define('QICLOUD_BASE_API', 'http://103.200.32.76:8000/');
...
You should not rely on documents root.
Do something like:
require_once(DIR . '/relative/path/from/current/directory/file.php');
The require once will stop execute ifbfile is not there since it's require. The once will make sure you don't include the file twice if you pass by this code a second time. You should never include a file that as finction/class/constant declaration more than one. And if you use a proper IDE (like phpstorm) you will have a warning if the file path is invalid. This cannot be achieved with the document root variable.
But I don't know your exact contalext but you should check something like composer.json to handle your dependencies.
P.s. there is 2 underscore before and after the DIR magic constant but formatting on the mobile web version is limited and force bold...
I know, that's stupid, but I can't solve the problem with my project.
I wrote project on WAMP firstly and all works.
After, I try to migrate on live server, and find a problem - server don't require my files.
Project structure is:
application
core
Controller.php
Model.php
View.php
Route.php
models
views
controllers
included
config.php
app.php
index.php
when I try to run it, server return error:
Warning: require_once(core/model.php): failed to open stream: No such
file or directory in /home/u224052355/public_html/application/app.php
on line 4
This is the app.php code:
session_start();
require_once 'config.php';
require_once 'core/model.php';
require_once 'core/view.php';
require_once 'core/controller.php';
require_once 'core/route.php';
spl_autoload_register(function($class_name){
include 'included/' . $class_name . '.php';
});
Route::start();
When I try solve this by adding __DIR__ to require_once I gave this message:
Warning:
require_once(/home/u224052355/public_html/application/core/model.php):
failed to open stream: No such file or directory in
/home/u224052355/public_html/application/app.php on line 4
Fatal error: require_once(): Failed opening required
'/home/u224052355/public_html/application/core/model.php'
(include_path='.:/opt/php-5.5/pear') in
/home/u224052355/public_html/application/app.php on line 4
Using the $_SERVER['DOCUMENT_ROOT'] and etc. - same result.
How can I solve this problem?
Getting this warning when trying to run my local PHP project (index.php):
Warning: require_once(/Controller/BulletinController.php): failed to open stream: No such file or directory in /Library/WebServer/Documents/WEBB_SERVER/6.2.1x/index.php on line 2
Fatal error: require_once(): Failed opening required '/Controller/BulletinController.php' (include_path='.:') in /Library/WebServer/Documents/WEBB_SERVER/6.2.1x/index.php on line 2
No such file or directory? This is my first 6 rows in index.php:
<?php
require_once ("/Controller/BulletinController.php");
require_once ("/General/MasterPage.php");
require_once ("./General/dbConnection.php");
session_start();
I've tried giving BulletinController.php 777 rights (just developing locally), but no luck.
This is what my structure looks like, so everything is in place:
Thankful for any advice you may have.
require_once ("/Controller/BulletinController.php");
must be
require_once ("Controller/BulletinController.php");
I think you need the whole path:
require_once dirname(__FILE__) . "/Controller/BulletinController.php";
I have a site that I am have several issues with. I am not sure if the hosting company did changed something or the site was hacked. I hope this is OK as I have listed a list of errors when a user tries to register for the site. This is also happening when a user tries to use the search function, however in the search function the errors appear at the top and then the search results actually display below. The registration page does not show anything but the following errors.
Warning: include(dbconn.php): failed to open stream: No such file or directory in /home1/hoapres/public_html/users/register/index.php on line 26
Warning: include(dbconn.php): failed to open stream: No such file or directory in /home1/hoapres/public_html/users/register/index.php on line 26
Warning: include(): Failed opening 'dbconn.php' for inclusion (include_path='.:/opt/php54/lib/php') in /home1/hoapres/public_html/users/register/index.php on line 26
Warning: include(functions.php): failed to open stream: No such file or directory in /home1/hoapres/public_html/users/register/index.php on line 27
Warning: include(functions.php): failed to open stream: No such file or directory in /home1/hoapres/public_html/users/register/index.php on line 27
Warning: include(): Failed opening 'functions.php' for inclusion (include_path='.:/opt/php54/lib/php') in /home1/hoapres/public_html/users/register/index.php on line 27
Fatal error: Call to undefined function userText2Web() in /home1/hoapres/public_html/users/register/index.php on line 40
Without knowing your directory structure it is tricky to offer a precise answer, but the first thing I would do before trying to include files is to explicitly set your include path.
Assuming that the site root ( DOCUMENT_ROOT ) is /home1/hoapres/public_html and you have a folder for storing all your include files called includes, the path would be /home1/hoapres/public_html/includes
<?php
set_include_path( $_SERVER['DOCUMENT_ROOT'] . '/includes' );
if( !realpath( get_include_path() ) ) exit('Bad path');
/* Test to see what files exist perhaps */
print_r( glob( get_include_path() . '/*.*' ) );
/* Can you see the files you expect? */
include 'dbconn.php';
include 'functions.php';
?>
Your problem is include path you have used is not correct.
Please check your code where you have include the files like
include("dbconn.php");
you can try by this way
$fullpath = "http://yourdomain.com/";
if the dbconn.php is under any folder then
$fullpath = "http://yourdomain.com/foldername/";
include($fullpath."dbconn.php");
I have a Slim Application with the following directory structure:
app/
vendor/
www/
config.php
In app/ I have the relevant files of the project, in vendor/ the dependencies managed by composer and in www/ the files accesible by the web server.
So I am thinking to create a Phar file along the lines of:
<?php
$full_path = '/home/.../forms/';
$package_name = 'www/package.phar';
try {
$phar = new Phar($full_path . $package_name,
FilesystemIterator::CURRENT_AS_FILEINFO | FilesystemIterator::KEY_AS_FILENAME, $full_path . $package_name);
$phar->startBuffering();
$phar->addFile($full_path . 'www/index.php');
$phar->addFile($full_path . 'www/bootstrap.php');
$phar->addFile($full_path . 'www/session_start.php');
// Grab config
$phar->addFile($full_path . 'config.php');
$phar->buildFromIterator(new RecursiveIteratorIterator (new RecursiveDirectoryIterator('../app', FilesystemIterator::SKIP_DOTS)),'../app');
$phar->buildFromIterator(new RecursiveIteratorIterator (new RecursiveDirectoryIterator('../vendor', FilesystemIterator::SKIP_DOTS)),'../vendor');
$phar->setDefaultStub('bootstrap.php', 'bootstrap.php');
$phar->stopBuffering();
echo "Phar created.";
} catch (Exception $e) {
// handle errors here
echo $e->getMessage();
}
So I create that way the phar and then I have:
deploy.php
<?php
require_once 'phar://package.phar/bootstrap.php';
$app->run();
But when accesing /deploy.php I am getting:
[Fri May 15 20:07:02 2015] [error] [client 10.0.2.2] PHP Warning:
require_once(phar://package.phar/bootstrap.php) [function.require-once]: failed to
open stream: Cannot open archive
"/vagrant/www/package.phar", invalid alias in
/vagrant/www/deploy.php on line 3 [Fri May 15 20:07:02 2015] [error]
[client 10.0.2.2] PHP Fatal error: require_once() [function.require]: Failed opening required
'phar://package.phar/bootstrap.php'
(include_path='.:/usr/share/php:/usr/share/pear') in
/vagrant/www/deploy.php on line 3
Do you think I should be addressing it like this?
Thanks
EDIT:
"Creating the phar in a shared folder of a Vagrant box caused that problem. Once I changed "output" property to a location outside the shared folder the error went away."
source
You should check your php.ini:
phar.require_hash = Off
Or sign your Phar with setSignatureAlgorithm()
Or with Phing:
<pharpackage ... signature="sha512"> ...