Page 1 of 1

php debugging does not work for me, ever , except in getAllDatas()

Posted: 25 November 2020, 17:44
by developgame
Thanks for all who have tried to help me with this debuggin in php problem. The problem is still not resolved.
if I cannot use traces and other debugging tools in php. How far I can go with my project is very limited,

Javascript, console.log and console.dir works awesome.

I have always had problems using var_dumps, echos and traces with BGA studio.


I have been working around this by adding whatever I needed checking into result[] in getAllDatas() and then do a var_dump($result). var_dump only works in function getAllDatas()

When I do a var_dump outside getAllDatas(), I get the following error
ly_metasite.js:2 Unexpected error: Wrong formatted data from BGA gameserver 1 (method: createGame): JSON_ERROR_SYNTAX NULL
{"status":1,"data":true}
(anonymous) @ ly_metasite.js:2
I also get they same error when I use what other developers have kindly suggested to me. Could there me a problem with my account?


When I use the following traces,

self::dump( );
self::debug( $message );
self::trace( $message );
self::warn( $message );
; /
I get no syntax errors, but I also cannot find the traces in BGA request&SQL logs . I even copy everything to notepad and do a search.

Re: php debugging does not work for me, ever , except in getAllDatas()

Posted: 25 November 2020, 19:35
by fafa-fr
developgame wrote: 25 November 2020, 17:44 When I use the following traces,

self::dump( );
self::debug( $message );
self::trace( $message );
self::warn( $message );
; /
I get no syntax errors, but I also cannot find the traces in BGA request&SQL logs . I even copy everything to notepad and do a search.
Just to be sure, did you try to increase the number of lines displayed in "BGA request&SQL logs"? Did you look from the beginning of the logs from your last action? (look at the time at the beginning of the lines)
Did you add some distinctive characters / string at the beginning of your log, to find it more easily in the middle of all the SQL requests made by the framework?

I personnaly use something like

Code: Select all

self::trace( "###### my variable to check is ".var_export( $variable, true)." " );

Re: php debugging does not work for me, ever , except in getAllDatas()

Posted: 26 November 2020, 17:43
by developgame
fafa-fr wrote: 25 November 2020, 19:35
developgame wrote: 25 November 2020, 17:44 When I use the following traces,

self::dump( );
self::debug( $message );
self::trace( $message );
self::warn( $message );
; /
I get no syntax errors, but I also cannot find the traces in BGA request&SQL logs . I even copy everything to notepad and do a search.
Just to be sure, did you try to increase the number of lines displayed in "BGA request&SQL logs"? Did you look from the beginning of the logs from your last action? (look at the time at the beginning of the lines)
Did you add some distinctive characters / string at the beginning of your log, to find it more easily in the middle of all the SQL requests made by the framework?

I personnaly use something like

Code: Select all

self::trace( "###### my variable to check is ".var_export( $variable, true)." " );
thanks for your reply fafa-fr
Yes, I have tried creating really long traces. I do not see my traces. I have also increased the number of lines displayed.

Re: php debugging does not work for me, ever , except in getAllDatas()

Posted: 27 November 2020, 01:03
by Victoria_La
Could be synax error in ouf your main files, so it completely chokes. What your game url?

Re: php debugging does not work for me, ever , except in getAllDatas()

Posted: 27 November 2020, 22:06
by developgame
Victoria_La wrote: 27 November 2020, 01:03 Could be synax error in ouf your main files, so it completely chokes. What your game url?
Thanks you Victoria_la for always being so amazingly helpful!

My game is crazyeight
Not sure how to give you the game url, but I think
My game URL is https://studio.boardgamearena.com/1/cra ... ble=213642

I cannot find any of the traces or error messages traces in BGA request&SQL logs or BGA unexpected exception log

Here is the function code I ran and I am trying to do var_dump, trace, etc

Code: Select all

   function stNewHand()
	{
		$this->cards->shuffle( 'deck' );
		$got_starting_card = false;

		$this->cards->pickCardForLocation( "deck", "cardsontable" );

		$an8 = $this->cards->getCardsOfTypeInLocation( NULL, "8", "cardsontable" );

		foreach ($an8 as $starting => $drawn )
		{
			$cardtype = $drawn['type_arg'];  
				
$message = " *********************************  test *********************** ";
$this->dd($message);
var_dump( $message);
die('ok');
self::warn( " *********************************  test *********************** "); // warning level logging, goes to BGA unexpected exceptions log
self::error( " *********************************  test *********************** " );
self::warn( $message );
self::error( $message );

			$got_starting_card == true;
			if ( $cardtype == "8" )
			{
				$this->cards->moveAllCardsInLocation( "cardsontable" , "deck" );
				$this->cards->shuffle( 'deck' );
				$got_starting_card == false;
			}
		}

		$players = self::loadPlayersBasicInfos();
		foreach ( $players as $player_id => $player )
		{
			$cards = $this->cards->pickCards( 5, 'deck', $player_id );
			self::notifyPlayer($player_id, 'newHand', '', array ('cards' => $cards ));
		}

	}
	protected function dd($var, $die = false)
	{
		echo '<pre>';
		var_dump($var);
		echo '</pre>';
        
		if ($die) {
			die();
		}
	}

	 
I no longer get json errors when I do a var_dump, but I cannot see where the var_dump is.
Only when i do var_dump($result) in getAllDatas() in game.php can I get a var_dump of result on top of the game screen.

thanks again!

Re: php debugging does not work for me, ever , except in getAllDatas()

Posted: 29 November 2020, 17:30
by Victoria_La
Now sure if you are the same person who asked this on chat but it seems like these methods do not work in setup states,
I added more info on wiki on alternative debugging techniques
https://en.doc.boardgamearena.com/Pract ... my_view.29
The same problem exists if you game state immediately follow starting state, in this case create a dummy player state in which player just press OK that will transition to you game state, after you done debugging it remove the player state and shortcut the transition to your game state.