1

How can achieve what you can see below? I read this question but did not succeed. My OS is Lubuntu 13.10 which is based in Ubuntu 13.10

You are technically ready to go, but
there's one extra step that I like to do to make command line debugging nice
and quick. I create a bash script called "php-xdebug", which automatically
starts the debugger engine. The script looks like this (unix only): >

#!/bin/bash
export XDEBUG_CONFIG="idekey=xdebug"
/usr/bin/php "$@"
<
Run "chmod +x" on the file and put it somewhere in your $PATH list, and you can
then use this instead of php when debugging. For instance, instead of "php
myscript.php", run "php-xdebug myscript.php" to start the debugger session.
pablofiumara
  • 1,099
  • 2
  • 14
  • 29

2 Answers2

3

The PATH is a list of folders which are automatically checked for executables when you run a program name. Here is what we do.

After the comment below there seems to be more of a problem so lets start from scratch.

Open gedit

Paste in

#!/bin/bash
export XDEBUG_CONFIG="idekey=xdebug"
/usr/bin/php "$@"

Save as

php-xdebug.sh

Go to the folder (in the terminal) with the file and run

chmod +x php-xdebug.sh

Then check what your PATH is with:

echo $PATH

You could move the file into one of the folders listed when you ran this command.

Normally a better solution is to edit the PATH (tutorial here) to search inside the folder where the script already is.

Now try:

php-xdebug.sh
  • Thanks for your answer, Julian. I am not able to understand the last line of your answer. May you explain it in other words, please? Thanks in advance. – pablofiumara Dec 20 '13 at 15:16
  • Edited, does that make more sense. If not tell me exactly what is confusing you and I will try again! – Julian Stirling Dec 20 '13 at 15:21
  • Thanks for editing your answer. Now it is clearer. After reading the last paragraph of the most voted answer [http://askubuntu.com/questions/60218/how-to-add-a-directory-to-my-path] (this question),I decided to apply the answer below it (which has around 50 voted). If I type in the terminal echo $PATH, I can see many paths separated by : One of them is the one I have just added. Inside that path, there is a file I am targetting. Problem is that I sourced my .bashrc but it seems that the terminal does not recognise php-xdebug command. The error says php-xdebug: command not found – pablofiumara Dec 20 '13 at 15:33
  • Should I add .sh to the end of filename? The file has this inside it: #!/bin/bash export XDEBUG_CONFIG="idekey=xdebug" /usr/bin/php "$@" – pablofiumara Dec 20 '13 at 15:36
  • You beat me too it by 1 min!! See edit above. – Julian Stirling Dec 20 '13 at 15:39
  • Thanks again, Julian. If I type in the terminal php-xdebug.sh myscript.php, php output appears in the terminal (there is no need to use the browser).The output is the same as if I typed php myscript.php. Does this means there are no bugs in the script, doesn't it? If I type in the terminal php-xdebug.sh, the terminal gets stuck. Is this right? – pablofiumara Dec 20 '13 at 15:48
  • It means that the script is running! I don't actually know how the debug script works. Best option is to google about debug flags in PHP and if you don't get anywhere a question about this script? I think the question asked though is solved? – Julian Stirling Dec 20 '13 at 15:53
  • Yes, the question has been solved. You were very helpful. Thank you very much! – pablofiumara Dec 20 '13 at 15:54
  • No problem. Good luck with the PHP debugging! – Julian Stirling Dec 20 '13 at 15:54
1

On Ubuntu (including Lubuntu), one natural place to put such a script is in ~/bin. If that folder does not exist already, do

mkdir ~/bin

Next time you log in, it will be automatically included in PATH, i.e. no need to alter the PATH variable.

Gunnar Hjalmarsson
  • 33,540
  • 3
  • 64
  • 94