Search code examples
phprequire

require_once show warning and fatal error but in correct dir


My web is running normally until i create index.php and show me this error messege.

Warning: require_once(../_asset/faker/vendor/fzaninotto/faker/src/autoload.php): failed to open stream: No such file or directory in C:\xampp\htdocs\belajar\covid_config\config.php on line 10

Fatal error: require_once(): Failed opening required '../_asset/faker/vendor/fzaninotto/faker/src/autoload.php' (include_path='C:\xampp\php\PEAR') in C:\xampp\htdocs\belajar\covid_config\config.php on line 10

This my program that maybe cause the error (index.php)

include "_config/config.php";

And this my config.php

require_once "../_asset/faker/vendor/fzaninotto/faker/src/autoload.php";

My folder tables: start from htdocs

belajar-covid-_asset
             |-_config
             |-auth
             |-dashboard
             |-index.php

Solution

  • On require, require_once, include and include_once statements, PHP search the source file basing on the following priority order:

    1. The full pathname, if any (e.g. include 'c:/my_include/autoload.php';)
    2. The include_path (in your case is C:\xampp\php\PEAR)
    3. The calling script's own directory
    4. The current working directory

    The file you require ('../_asset/faker/vendor/fzaninotto/faker/src/autoload.php') is not in any of these locations.

    See PHP manual for details