dolibarr  7.0.0-beta
xdebug.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2009-2014 Laurent Destailleur <eldy@users.sourceforge.net>
3  *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17 
23 require '../../main.inc.php';
24 
25 $langs->load("admin");
26 
27 if (!$user->admin)
29 
30 
31 /*
32  * View
33 */
34 
35 llxHeader();
36 
37 print load_fiche_titre("XDebug",'','title_setup');
38 
39 print "<br>\n";
40 
41 
42 if (!function_exists('xdebug_is_enabled'))
43 {
44  print 'XDebug seems to be not installed. Function xdebug_is_enabled not found.';
45  llxFooter();
46  exit;
47 }
48 
49 
50 if (function_exists('socket_create'))
51 {
52  $address = ini_get('xdebug.remote_host')?ini_get('xdebug.remote_host'):'127.0.0.1';
53  $port = ini_get('xdebug.remote_port')?ini_get('xdebug.remote_port'):9000;
54 
55  print "<strong>Current xdebug setup:</strong><br>\n";
56  print "* Remote debug setup:<br>\n";
57  print 'xdebug.remote_enable = '.ini_get('xdebug.remote_enable')."<br>\n";
58  print 'xdebug.remote_host = '.$address."<br>\n";
59  print 'xdebug.remote_port = '.$port."<br>\n";
60  print "* Profiler setup ";
61  if (function_exists('xdebug_get_profiler_filename')) print xdebug_get_profiler_filename()?"(currently on into file ".xdebug_get_profiler_filename().")":"(currently off)";
62  else print "(currenlty not available)";
63  print ":<br>\n";
64  print 'xdebug.profiler_enable = '.ini_get('xdebug.profiler_enable')."<br>\n";
65  print 'xdebug.profiler_enable_trigger = '.ini_get('xdebug.profiler_enable_trigger')."<br>\n";
66  print 'xdebug.profiler_output_dir = '.ini_get('xdebug.profiler_output_dir')."<br>\n";
67  print 'xdebug.profiler_output_name = '.ini_get('xdebug.profiler_output_name')."<br>\n";
68  print 'xdebug.profiler_append = '.ini_get('xdebug.profiler_append')."<br>\n";
69  print "<br>\n";
70 
71  echo "To run a debug session, add parameter<br>";
72  echo "* XDEBUG_SESSION_START=aname on your URL. To stop, remove cookie XDEBUG_SESSION_START.<br>\n";
73  echo "To run a profiler session (when xdebug.profiler_enable_trigger=1), add parameter<br>\n";
74  echo "* XDEBUG_PROFILE=aname on each URL.<br>";
75  print "<br>";
76 
77  print "<strong>Test debugger server (Eclipse for example):</strong><br>\n";
78  $socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
79  if (empty($socket)) die('Unable to prepare a socket');
80  //socket_bind($sock, $address, $port) or die('Unable to bind on address='.$address.' port='.$port);
81  //socket_listen($sock);
82  //$client = socket_accept($sock);
83  $client=socket_connect($socket, $address, $port);
84  if ($client)
85  {
86  echo "Connection established: ".$client." - address=".$address." port=".$port."<br>\n";
87  echo "There is a Remote debug server at this address.<br>\n";
88  echo "<br>\n";
89  echo "To be sure this debugger accepts input from your PHP server and xdebug, be sure to have\n";
90  echo "your php.ini file with this :<br>\n";
91  echo '<textarea cols="80" rows="16">'."xdebug.remote_enable=on
92 xdebug.remote_handle=dbgp
93 xdebug.remote_host=localhost
94 xdebug.remote_port=9000
95 xdebug.profiler_enable=0
96 xdebug.profiler_enable_trigger=1
97 xdebug.show_local_vars=off
98 xdebug.profiler_output_dir=/tmp/xdebug
99 xdebug.profiler_append=0
100 ; for xdebug 2.2+
101 xdebug.trace_enable_trigger=1
102 xdebug.show_mem_delta=1
103 xdebug.trace_output_dir=/tmp/trace
104 xdebug.auto_trace=0
105 </textarea>\n";
106  print "<br><br>\n";
107  echo 'Then check in your debug server (Eclipse), you have setup:<br>
108  XDebug with same port than in php.ini<br>
109  Allow Remote debug=yes or prompt<br>'."\n";
110  print "<br>\n";
111  }
112  else
113  {
114  print socket_strerror(socket_last_error());
115  echo "Failed to connect to address=".$address." port=".$port."<br>\n";
116  echo "There is no Remote debug server at this address.\n";
117  }
118  socket_close($socket);
119 }
120 else
121 {
122  print "Can't test if PHPDebug is OK as PHP socket functions are not enabled.";
123 }
124 
125 
126 llxFooter();
127 
128 $db->close();
llxFooter()
Empty footer.
Definition: wrapper.php:58
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
load_fiche_titre($titre, $morehtmlright='', $picto='title_generic.png', $pictoisfullpath=0, $id=0, $morecssontable='', $morehtmlcenter='')
Load a title with picto.
llxHeader()
Empty header.
Definition: wrapper.php:46
print
Draft customers invoices.
Definition: index.php:91