Home > Back-end >  Trouble with path for require function in PHP with o2switch host
Trouble with path for require function in PHP with o2switch host

Time:05-27

I have uploaded website to o2switch host. When I worked on localhost, all worked well. But on o2switch, I have this error :

Warning: require_once(models/shopManager.class.php): failed to open stream: No such file or directory in /home/myUserNameo2switch/myDomain.fr/controllers/ShopController.controller.php on line 2

Fatal error: require_once(): Failed opening required 'models/shopManager.class.php' (include_path='.:/opt/alt/php73/usr/share/pear') in /home/myUserNameo2switch/myDomain.fr/controllers/ShopController.controller.php on line 2

I use MVC model with file structure like :

index.php
-controllers
  -ShopController.controller.php
-models
  -shopManager.class.php

In my index.php I do :

require_once "controllers/ShopController.controller.php";
$shopController = new ShopController();

In ShopController.controller.php, I do :

require_once "models/shopManager.class.php";

On o2switch PHP setting (I think similar to php.ini) there is configuration for include_path equal to .:/opt/alt/php73/usr/share/pear

The trouble is it coming from include_path value ?

That's the first time I work on online website and my first question here. Sorry if I am clumsy. Thank you

CodePudding user response:

In ShopController.controller.php, you can try to change

require_once "models/shopManager.class.php";

to

require_once "../models/shopManager.class.php";

to see if the error message would disappear.

CodePudding user response:

Thanks ild flue for your answer. It doesn't work.

My trouble is fixed. I had a trouble with capital and not capital letter between file and file called on require_once... :(

The most surprising is I had no error on local.

  • Related