Re: debugger for CLI PHP scripts...?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thursday 12 May 2005 17:35, Christopher J. Bottaro wrote:
> Is there such a thing?  

Hi Christopher

Spoken as someone who actively uses PHP both in webpages, and for scripts on 
CLI, the only debugger I am aware of is Gubed (but that's only for PHP & 
Webbpages)

Personally, I use the following setup (pseudo code, I could give you the 
actuall source code, but this is better because it will actually enhance your 
knowledge)

This does not have breakpoints, but if you want them, you can write a function
function breakpoint($info)
{debug($info);
 die();}

After that if you want conditional breakpoints, use an assert like function

function assert($var,$value,$msg)
{if($var==$value)
  breakpoint($msg);
}


Do you see the light yet?

If you implement it properly, you don't even need to change your source code 
when debugging is done.


example flow:

Register_shutdownfunction("debug","dump");

then everywhere in the script, 

function dosomething($param)
{debug("domsomething($param)");
...
}

function debug()
{static $data='';
 get parameter list
 if first param="dump"
 {if preferences=dumtofile
   writetofile $data
  else
   writetoconsole $data
	}
 else
  data[]=$parameters
}
}

Can you see the use of this?

Kind regards


Andy

-- 
Registered Linux User Number 379093
-- --BEGIN GEEK CODE BLOCK-----
Version: 3.1
GAT/O/>E$ d-(---)>+ s:(+)>: a--(-)>? C++++$(+++) UL++++>++++$ P-(+)>++
L+++>++++$ E---(-)@ W+++>+++$ !N@ o? !K? W--(---) !O !M- V-- PS++(+++)
PE--(-) Y+ PGP++(+++) t+(++) 5-- X++ R*(+)@ !tv b-() DI(+) D+(+++) G(+)
e>++++$@ h++(*) r-->++ y--()>++++
-- ---END GEEK CODE BLOCK------
--
Check out these few php utilities that I released
 under the GPL2 and that are meant for use with a 
 php cli binary:
 
 http://www.vlaamse-kern.com/sas/
--

--

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux