1

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

2 Answers2

1

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.

ild flue
  • 1,323
  • 8
  • 9
0

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.

  • While developing on Windows you may get away with incorrect file name capitalisation as its filesystem is case insensitive by default. Linux filesystem, however, is case sensitive, which is why you ran into the problem. You should make sure that your code refers to all files by their exact names, including capital letters. – Wojciech Zylinski May 27 '22 at 00:17