I decided to try and run a debug proxy so I could run multiple connections to xdebug from KomodoIDE.
That has caused a lot of frustration.
First I copied the dbgpproxy files to the server.
I then hacked php.ini as suggested setting the xdebug.remote_host to localhost/127.0.0.1 so my php.ini looked like this:
xdebug.remote_enable = true
xdebug.remote_host = 127.0.0.1
xdebug.remote_port = 9000
xdebug.remote_handler = dbgp
xdebug.remote_log = /var/log/xdebug.log
xdebug.remote_mode = req
Restarted Apache and then I then ran the proxy like this:
root@home php.ini]# python /root/dbgp/bin/pydbgpproxy -l DEBUG
INFO: dbgp.proxy: starting proxy listeners. appid: 9795
INFO: dbgp.proxy: dbgp listener on 127.0.0.1:9000
INFO: dbgp.proxy: IDE listener on 127.0.0.1:9001
In Komodo I set the Listening port to 'system provided free port'
I set 'I am listening to a proxy' and added the IP and port of the server
But I kept getting errors:
Failed to start the listener socket on port 9001, error: -1 (the debugger proxy could not be contacted.)
If I tried to debug a file like this:
https://192.168.10.1/Test.php?XDEBUG_SESSION_START=users
I would get a proxy error like this:
WARNING: dbgp.proxy: No server with key [users], stopping request
Having tried multiple settings I finally found this page which gave me the clue :
https://confluence.jetbrains.com/display/PhpStorm/Multi-user+debugging+in+PhpStorm+with+Xdebug+and+DBGp+proxy
You have to set the proxy like this.
-i proxyserverExternalIP:port you specify in the proxy settings
-d IP:local debug port on the server (set in php.ini)
e.g.:
python /root/dbgp/bin/pydbgpproxy -d 127.0.0.1:9000 -i 192.168.10.1:9001
And presto ! You can now connect multiple users.
Somewhere to stick my notes on stuff I've learned. Hopefully it will come in useful to someone, somewhere.
Showing posts with label PHP. Show all posts
Showing posts with label PHP. Show all posts
Sunday, November 6, 2016
Tuesday, October 8, 2013
ZendDebugger x64 libssl and libcrypto errors
Following an earlier post I have an addendum for x64.....
Having virtualised my server and also shunted to x64 I was back to the error.
"I know - I have a note about this :-)"
So a few mods
First, make sure your ZendDebugger.so is in /usr/lib64/modules
Make sure the path is correct in php.ini
ln -s /lib64/libssl.so.0.9.8e /usr/lib64/libssl.so.0.9.8
ln -s /lib64/libcrypto.so.0.9.8e /usr/lib64/libcrypto.so.0.9.8
Restart your web server
Success :
# php -v
PHP 5.3.3 (cli) (built: Jul 15 2013 07:56:18)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
with Zend Debugger v5.3, Copyright (c) 1999-2010, by Zend Technologies
Having virtualised my server and also shunted to x64 I was back to the error.
"I know - I have a note about this :-)"
So a few mods
First, make sure your ZendDebugger.so is in /usr/lib64/modules
Make sure the path is correct in php.ini
ln -s /lib64/libssl.so.0.9.8e /usr/lib64/libssl.so.0.9.8
ln -s /lib64/libcrypto.so.0.9.8e /usr/lib64/libcrypto.so.0.9.8
Restart your web server
Success :
# php -v
PHP 5.3.3 (cli) (built: Jul 15 2013 07:56:18)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
with Zend Debugger v5.3, Copyright (c) 1999-2010, by Zend Technologies
Labels:
Eclipse,
libcrypto.so.0.9.8e,
libssl.so.0.9.8e,
PHP,
ZendDebugger
Monday, April 29, 2013
MySQL Dump - php code
I wanted a piece of code to dump / backup my sql tables.
I has a look and modified it very slightly.
Couple of things. SQL mode dumps the entire database. But CSV mode only does named tables and you forget to put in the table name, so I added a simple check and warning.
Why can't blogger do attachments ??? Bloody annoying. So thanks to this site for making it 'Pastable and Postable' :
<?php
set_time_limit(0);
/*---------------------------------------------------
| mysqldump.php
----------------------------------------------------
| Copyright 2006 Huang Kai
| hkai@atutility.com
| http://atutility.com/
----------------------------------------------------
| Released under the terms & conditions of v2 of the
| GNU General Public License. For details refer to
| the included gpl.txt file or visit http://gnu.org
----------------------------------------------------*/
/*
change log:
2006-10-16 Huang Kai
---------------------------------
initial release
2006-10-18 Huang Kai
---------------------------------
fixed bugs with delimiter
add paramter header to add field name as CSV file header.
2006-11-11 Huang Kia
Tested with IE and fixed the <button> to <input>
2013-04-29 ReetP
Small mods to reporting and check for CSV Table
2013-04-29 ReetP
Small mods to reporting and check for CSV Table
*/
$mysqldump_version="1.02";
$print_form=1;
$output_messages=array();
//test mysql connection
if( isset($_REQUEST['action']) )
{
$mysql_host=$_REQUEST['mysql_host'];
$mysql_database=$_REQUEST['mysql_database'];
$mysql_username=$_REQUEST['mysql_username'];
$mysql_password=$_REQUEST['mysql_password'];
if( 'Test Connection' == $_REQUEST['action'])
{
_mysql_test($mysql_host,$mysql_database, $mysql_username, $mysql_password);
// echo $mysql_host,$mysql_database, $mysql_username, $mysql_password. '<br />';
}
else if( 'Export' == $_REQUEST['action'])
{
_mysql_test($mysql_host,$mysql_database, $mysql_username, $mysql_password);
if( 'SQL' == $_REQUEST['output_format'] )
{
$print_form=0;
//ob_start("ob_gzhandler");
header('Content-type: text/plain');
header('Content-Disposition: attachment; filename="'.$mysql_host."_".$mysql_database."_".date('YmdHis').'.sql"');
echo "/*mysqldump.php version $mysqldump_version */\n";
_mysqldump($mysql_database);
//header("Content-Length: ".ob_get_length());
//ob_end_flush();
}
else if( 'CSV' == $_REQUEST['output_format'] && isset($_REQUEST['mysql_table']) && ($_REQUEST['mysql_table'] != null))
{
$print_form=0;
ob_start("ob_gzhandler");
header('Content-type: text/comma-separated-values');
header('Content-Disposition: attachment; filename="'.$mysql_host."_".$mysql_database."_".$mysql_table."_".date('YmdHis').'.csv"');
//header('Content-type: text/plain');
_mysqldump_csv($_REQUEST['mysql_table']);
header("Content-Length: ".ob_get_length());
ob_end_flush();
}
else echo "<H3>CSV Mode - No Table entered !</H3>";
}
}
function _mysqldump_csv($table)
{
$delimiter= ",";
if( isset($_REQUEST['csv_delimiter']))
$delimiter= $_REQUEST['csv_delimiter'];
if( 'Tab' == $delimiter)
$delimiter="\t";
$sql="select * from `$table`;";
$result=mysql_query($sql);
if( $result)
{
$num_rows= mysql_num_rows($result);
$num_fields= mysql_num_fields($result);
$i=0;
while( $i < $num_fields)
{
$meta= mysql_fetch_field($result, $i);
echo($meta->name);
if( $i < $num_fields-1)
echo "$delimiter";
$i ;
}
echo "\n";
if( $num_rows > 0)
{
while( $row= mysql_fetch_row($result))
{
for( $i=0; $i < $num_fields; $i )
{
echo mysql_real_escape_string($row[$i]);
if( $i < $num_fields-1)
echo "$delimiter";
}
echo "\n";
}
}
}
mysql_free_result($result);
}
function _mysqldump($mysql_database)
{
$sql="show tables;";
$result= mysql_query($sql);
if( $result)
{
while( $row= mysql_fetch_row($result))
{
_mysqldump_table_structure($row[0]);
if( isset($_REQUEST['sql_table_data']))
{
_mysqldump_table_data($row[0]);
}
}
}
else
{
echo "/* no tables in $mysql_database */\n";
}
mysql_free_result($result);
}
function _mysqldump_table_structure($table)
{
echo "/* Table structure for table `$table` */\n";
if( isset($_REQUEST['sql_drop_table']))
{
echo "DROP TABLE IF EXISTS `$table`;\n\n";
}
if( isset($_REQUEST['sql_create_table']))
{
$sql="show create table `$table`; ";
$result=mysql_query($sql);
if( $result)
{
if($row= mysql_fetch_assoc($result))
{
echo $row['Create Table'].";\n\n";
}
}
mysql_free_result($result);
}
}
function _mysqldump_table_data($table)
{
$sql="select * from `$table`;";
$result=mysql_query($sql);
if( $result)
{
$num_rows= mysql_num_rows($result);
$num_fields= mysql_num_fields($result);
if( $num_rows > 0)
{
echo "/* dumping data for table `$table` */\n";
$field_type=array();
$i=0;
while( $i < $num_fields)
{
$meta= mysql_fetch_field($result, $i);
array_push($field_type, $meta->type);
$i ;
}
//print_r( $field_type);
echo "insert into `$table` values\n";
$index=0;
while( $row= mysql_fetch_row($result))
{
echo "(";
for( $i=0; $i < $num_fields; $i )
{
if( is_null( $row[$i]))
echo "null";
else
{
switch( $field_type[$i])
{
case 'int':
echo $row[$i];
break;
case 'string':
case 'blob' :
default:
echo "'".mysql_real_escape_string($row[$i])."'";
}
}
if( $i < $num_fields-1)
echo ",";
}
echo ")";
if( $index < $num_rows-1)
echo ",";
else
echo ";";
echo "\n";
$index ;
}
}
}
mysql_free_result($result);
echo "\n";
}
function _mysql_test($mysql_host,$mysql_database, $mysql_username, $mysql_password)
{
global $output_messages;
$link = mysql_connect($mysql_host, $mysql_username, $mysql_password);
if (!$link)
{
array_push($output_messages, 'Could not connect: ' . mysql_error());
}
else
{
array_push ($output_messages,"Connected with MySQL server: $mysql_username@$mysql_host successfully <br />");
$db_selected = mysql_select_db($mysql_database, $link);
if (!$db_selected)
{
array_push ($output_messages,'Can\'t use $mysql_database : ' . mysql_error());
}
else
array_push ($output_messages,"Connected with MySQL database: $mysql_database successfully <br />");
}
}
if( $print_form >0 )
{
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>mysqldump.php version <?php echo $mysqldump_version; ?></title>
</head>
<body>
<?php
foreach ($output_messages as $message)
{
echo $message."<br />";
}
?>
<form action="" method="post">
MySQL connection parameters:
<table border="0">
<tr>
<td>Host:</td>
<td><input name="mysql_host" value="<?php if(isset($_REQUEST['mysql_host']))echo $_REQUEST['mysql_host']; else echo 'localhost';?>" /></td>
</tr>
<tr>
<td>Database:</td>
<td><input name="mysql_database" value="<?php echo $_REQUEST['mysql_database']; ?>" /></td>
</tr>
<tr>
<td>Username:</td>
<td><input name="mysql_username" value="<?php echo $_REQUEST['mysql_username']; ?>" /></td>
</tr>
<tr>
<td>Password:</td>
<td><input type="password" name="mysql_password" value="<?php echo $_REQUEST['mysql_password']; ?>" /></td>
</tr>
<tr>
<td>Output format: </td>
<td>
<select name="output_format" >
<option value="SQL" <?php if( isset($_REQUEST['output_format']) && 'SQL' == $_REQUEST['output_format']) echo "selected";?> >SQL</option>
<option value="CSV" <?php if( isset($_REQUEST['output_format']) && 'CSV' == $_REQUEST['output_format']) echo "selected";?> >CSV</option>
</select>
</td>
</tr>
</table>
<input type="submit" name="action" value="Test Connection"><br />
<br>Dump options(SQL):
<table border="0">
<tr>
<td>Drop table statement: </td>
<td><input type="checkbox" name="sql_drop_table" <?php if(isset($_REQUEST['action']) && ! isset($_REQUEST['sql_drop_table'])) ; else echo 'checked' ?> /></td>
</tr>
<tr>
<td>Create table statement: </td>
<td><input type="checkbox" name="sql_create_table" <?php if(isset($_REQUEST['action']) && ! isset($_REQUEST['sql_create_table'])) ; else echo 'checked' ?> /></td>
</tr>
<tr>
<td>Table data: </td>
<td><input type="checkbox" name="sql_table_data" <?php if(isset($_REQUEST['action']) && ! isset($_REQUEST['sql_table_data'])) ; else echo 'checked' ?>/></td>
</tr>
</table>
<br>Dump options(CSV) - Individual tables only - fill in the box :
<table border="0">
<tr>
<td>Delimiter:</td>
<td><select name="csv_delimiter">
<option value="," <?php if( isset($_REQUEST['output_format']) && ',' == $_REQUEST['output_format']) echo "selected";?>>,</option>
<option value="Tab" <?php if( isset($_REQUEST['output_format']) && 'Tab' == $_REQUEST['output_format']) echo "selected";?>>Tab</option>
<option value="|" <?php if( isset($_REQUEST['output_format']) && '|' == $_REQUEST['output_format']) echo "selected";?>>|</option>
</select>
</td>
</tr>
<tr>
<td>Table:</td>
<td><input type="input" name="mysql_table" value="<?php echo $_REQUEST['mysql_table']; ?>" /></td>
</tr>
<tr>
<td>Header: </td>
<td><input type="checkbox" name="csv_header" <?php if(isset($_REQUEST['action']) && ! isset($_REQUEST['csv_header'])) ; else echo 'checked' ?>/></td>
</tr>
</table>
<input type="submit" name="action" value="Export"><br />
</form>
</body>
</html>
<?php
}
?>
Subscribe to:
Posts (Atom)
