Page 1 of 1

require_once(modules/php/utils/cards.inc.php): Failed to open stream

Posted: 15 May 2025, 16:14
by zim921
Hi people! im new here and im having issues with the require_once

I have a file in modules/php/utils/cards.inc.php, just a constant with values something like this

<?php

// Suit
const CARD_SUITS = [];

?>

In modules/php/Game.php im triyng to "import" this file by doing

require_once("modules/php/utils/cards.inc.php"); before the class definition

Im receiving the error

Wrong formatted data from gameserver 1 (method: createGame): JSON_ERROR_SYNTAX <br />
<b>Warning</b>: require_once(modules/php/utils/cards.inc.php): Failed to open stream: No such file or directory in <b>/var/tournoi/release/games/truco/999999-9999/modules/php/Game.php</b> on line <b>24</b><br />
{"status":"0","exception":"feException","error":"Fatal error during truco setup: Namespaced game module could not be loaded: \\Bga\\Games\\truco\\Game: Failed opening required 'modules\/php\/utils\/cards.inc.php'

What im doing wrong?
Thanks a lot!

Re: require_once(modules/php/utils/cards.inc.php): Failed to open stream

Posted: 15 May 2025, 16:22
by zim921
I'm trying to split my Game.php file to make it more maintainable and easier to understand. Any advice or tips about file structure would be really helpful!
I've completed the Reversi and Hearts tutorials, but I still feel like I have very little knowledge about how to actually make a game.

Re: require_once(modules/php/utils/cards.inc.php): Failed to open stream

Posted: 15 May 2025, 17:06
by zim921
Fixed! Ok, the issue was the path. SHould be use relative path no absolute