NuSphere Forums Forum Index
NuSphere Forums
Reply to topic
Someone's got to go first...
Guest


Reply with quote
I just started reading the SourceForge forum when the decision is taken to close it. My main reason for posting is to help others who were in the same position as me, so sorry if some of you out there think this is too basic. Okay, I had:

i) PHP, Apache and MySQL running successfully (in my case on Windows)
ii) Using Maguma as an IDE (I know you're nothing to do with Maguma, Dmitri Wink)
iii) Wanting to profile my existing code

Okay, before I can profile, I needed to get the debugger running. Go to PHP.ini

i) Uncomment
Code:
extension=php_dbg.dll

ii) Uncomment or add
Code:
[Debugger]
debugger.host   =   localhost
debugger.port   =   7869
debugger.enabled   = true

Now start Apache, run the debug session through the Maguma IDE and we're off. Step in, step out, and run to breakpoint all work. Maguma does have problems displaying some variable values (such as arrays) but I'm happy that that's nothing to do with DBG.

To get the profiler working, go back to PHP.ini and

i) Add
Code:
debugger.profiler_enabled = true
to the [Debugger] section

Again start Apache, run the debug session through the Maguma IDE. It's best to look at the profile information near the end of the PHP code, as you can't view it in Maguma when the page has finished rendering. Also the information displayed doesn't dynamically refresh, so you have to close the window and open it again to get the next run.

As mentioned in other posts, you can initiate the debugger from the browser. To do this

i) In Maguma select External Preview
ii) Now in the browser amend your URL so it reads
Code:
http://localhost/MyDocs/puncher/gen_herald.php?DBGSESSID=1@clienthost:7869

iii) Go back to Maguma and you are now in a debug session

The main advantage to this is that it allows you to set variables for the page. My page mentioned above has various values that can be selected and POSTed back to itself, so the second time takes a completely different route through the code from the first. If I want to profile this, then I can change the URL to something like
Code:
http://localhost/MyDocs/puncher/gen_herald.php?DBGSESSID=1@clienthost:7869&Size=3


Hope this has been useful to some people.

Cheers,

Chris
DBG Tips
Site Admin

Joined: 13 Jul 2003
Posts: 8334
Reply with quote
Yeah, thank you Chris for your clear explanations and performing my work Smile

Now few words about how it works with PhpED.
I) PhpED comes with set of pre-compiled dbg modules for different php versions. So, the line loading dbg module should include php version, for example if you have php 4.3.2 installed it should be:
Code:
extension=php_dbg.dll-4.3.2

or if you run it under Linux
Code:
extension=dbg.so-4.3.2



II) PhpED comes with commercial version of DBG and therefore it supports some more features, including for example IP security layer.
So, you can enable it by setting two lines debugger.hosts_allow and debugger.hosts_deny. For example if you run debugger from two client machines which IP addresses are 192.168.1.10 and 192.168.1.11 you can add the following:
Code:
debugger.hosts_allow=192.168.1.10, 192.168.1.11
debugger.hosts_deny=ALL


To "list" all IP addresses you can use either mask or partial IP, for example 192.168.1.10/255.255.255.0 or 192.168.1.*. You can use there host names, domain names and so forth. For detailed syntax see man pages for TCP_WRAPPERS (hosts_allow(5)).
NOTE: deny=ALL means "mostly protected" policy, all hosts are denied until they are explicitly allowed in the allow line.


III) If you debugged a script, got resulting HTML page and want to continue debugging after your submitted a new page from this one, you should keep cookies enabled and make sure that

Code:
debugger.enable_session_cookie=on


IV) If you want to start debugging a page (b) resulted as a submit from a different one (page a) you can start debugging page a, press Run In Debugger once again to finish it up, then press submit button or make another action on your page to make a submit and PhpED should automatically add debugger request, regardless you use external browser or embedded one. This functionality relies on HTTP cookies only.

V) Normally, you can just run your page in PhpED by simply pressing "Run In Debugger". But sometimes it's interesing to make an explicit debugging request from a page. In this case you can
add DBGSESSID variable using one of the following forms

V.a)
Code:
<form action="scriptb.php?DBGSESSID=1@clienthost:7869" method="GET">
....


V.b)
Code:
<form action="scriptb.php" method="POST">
<input type="hidden" name="DBGSESSID" value="1@clienthost:7869">
....


V.c)
you run your script as, for example:
Code:
http://yoursite/yourdir/yourscript.php?DBGSESSID=1@clienthost:7869


VI) If you want to order DBG not to start debug session in case when it normally starts, you'd add -1 as a session id, for example
"DBGSESSID=-1". No other stuff should be there, no clienthost, no 7869.

VII) If you are running your site otside of your local IP space, for example when your address is 192.168.1.10 while IP address of your server is normal Internet IP, you'd tune your NAT and firewall to enable dbg module running on server to have an access to dbg listener running on your client machine. For example, it NAT runs on 192.168.1.1 you'd add there NAT rule as follows:
Code:
external port=7869
internal port=7869
internal host=192.168.1.10
type=TCP

Anyway, before doing it, please consult with your network administrator regarding security risks.

Best regards,
Dmitri.
View user's profileFind all posts by dmitriSend private messageVisit poster's website
PHP gets stuck


Joined: 20 Jul 2003
Posts: 2
Location: Sharon Hills
Reply with quote
I've got a problem..

I've downloaded both PhpEdit and DBG alone, but none of the DBG DLLs work. When I add the line "extension=php_dbg.dll-4.3.2.dll" or "extension=php_dbg.dll", php just stops working and any attempt to run a PHP file through IIS will result in a script timeout

For the matter, adding an extension line with a nonexistent DLL name causes the same thing..
I'm using PHP 4.3.2 (windows installer) and IIS on W2K, if that helps.

Please help.. :/

- Gauche
View user's profileFind all posts by GaucheSend private message


Joined: 20 Jul 2003
Posts: 2
Location: Sharon Hills
Reply with quote
Update!
I was running the program from the terminal server so I didn't see the msgboxes.
It appears that PHP showed me msgboxes and that's why there was a timeout. Here are the error messages:

If I add "extension=php_dbg.dll" I get:
unknown(): Unable to load dynamic library 'c:\php\php_dbg.dll' - The specified procedure could not be found.

If I add "extension=php_dbg.dll-4.3.2.dll" I get:
unknown(): Unable to load dynamic library 'c:\php\php_dbg.dll-4.3.2.dll' - Access is denied.
(note that IUSR does have permission for c:\php)

Now hear this. After I renamed php_dbg.dll-4.3.2.dll to php_dbg.2.dll, it seems to load fine!

But it's not over. Now I can't find any editor that can work nicely with DBG. PHPedit works partially the first time (it traces, but it doesn't show me array variables and won't let me add watches) but the next time I try debugging a file (reload), it reports: "File embedding doesn't work!".

Here's what the listener says after the second time I try debugging
20/07/2003 17:57:11 Different version (2.04) of IDE CoClass, 2.11.23 expected
20/07/2003 17:58:16 10.0.0.150 client connected
20/07/2003 17:58:16 Listener is started
20/07/2003 17:58:20 Failed to initialize instance of IDE CoClass {D55B5E5E-B97E-4B88-A808-6FB7E337EA13}. OSERR (0x80010108) 'The object invoked has disconnected from its clients.'.

(I did get more error messages before I took the DBG package from this site, copied it to the DBG subdirectory and re-registered it with regsvr32)
View user's profileFind all posts by GaucheSend private message
Site Admin

Joined: 13 Jul 2003
Posts: 8334
Reply with quote
DBG has has 8)never8) been called php_dbg.dll-4.3.2.dll
Obviously you mistyped. It should be php_dbg.dll-4.3.2

Regarding PHPEdit, I don't know why it does not show arrays. I'm sure it's a kind of front-IDE problems. At least according to message logs, that particular version of PHPEdit expected DBG 2.04.xx instead of 2.11.xx.
Seems, it's mostly outdated. Please contact marms for details.

I don't know why you don't see any IDEs that work with DBG. NuShere PHPEd does work. Believe you or not DBG 2.14.9 shipped with the most recent version of this IDE shares the same variable serializer as DBG 2.11.23, so if there was any problem with arrays in 2.11.23 the same problem would be with PHPEd too. You can try and make sure that PHPEd does work fine.
View user's profileFind all posts by dmitriSend private messageVisit poster's website
extension_dir


Joined: 05 Aug 2003
Posts: 1
Reply with quote
Do not forget to set the directory where you have your extension dlls in your php.ini:

extension_dir = "C:\php\extensions"

Default is empty, and PHP will not find any of them unless you specify the full path when loading the DLL.
View user's profileFind all posts by xervSend private message
Someone's got to go first...
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
All times are GMT - 5 Hours  
Page 1 of 1  

  
  
 Reply to topic