Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 323931 - PHP Script arguments not passed to script
Summary: PHP Script arguments not passed to script
Status: CLOSED FIXED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: PDT (show other bugs)
Version: unspecified   Edit
Hardware: Macintosh Mac OS X - Carbon (unsup.)
: P2 major with 7 votes (vote)
Target Milestone: ---   Edit
Assignee: Wojciech Galanciak CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 331312 (view as bug list)
Depends on:
Blocks:
 
Reported: 2010-08-30 04:17 EDT by Jérôme Vieilledent CLA
Modified: 2020-05-14 11:08 EDT (History)
15 users (show)

See Also:


Attachments
Image reproducing Bug 323931 (76.41 KB, image/png)
2013-11-08 21:10 EST, Sadek Baroudi CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jérôme Vieilledent CLA 2010-08-30 04:17:47 EDT
Build Identifier: 20100617-1415

PHP Script arguments not passed to script while debugging ($argv)

Reproducible: Always

Steps to Reproduce:
1. Define a new debug script configuration
2. Define PHP scripts arguments in dedicated tab
3. Add a breakpoint in your cli script to debug.
4. Inspect $_SERVER['argv']
Comment 1 Jérôme Vieilledent CLA 2010-08-30 04:18:40 EDT
I'm using PHP 5.2.14 compiled with MacPorts
Comment 2 Jérôme Vieilledent CLA 2010-08-30 04:20:17 EDT
Mac OS X 10.6.4, PDT 64bits
Comment 3 Zhongwei Zhao CLA 2010-09-01 22:23:58 EDT
Hi Jerome

I could not reproduce your problem when I use "debug as php script".

both $argv and $_SERVER['argv'] show the arguments that I write in 'PHP Script Arguments' tab.
Comment 4 Zhongwei Zhao CLA 2010-09-06 01:19:50 EDT
works for me
Comment 5 Jérôme Vieilledent CLA 2010-09-08 11:48:34 EDT
Hi

Both $argv and $_SERVER['argv'] only contain path to my PHP script :-(
Which version of XDebug do you use ? I'm using 2.0.5 installed with Macports.
Thanks
Comment 6 Jérôme Vieilledent CLA 2010-09-08 11:54:16 EDT
FYI, I upgraded to Xdebug 2.1.0 via PECL and it results the same :-(
Comment 7 Mark Sullivan CLA 2010-11-11 12:57:28 EST
I have the same problem:

Mac OSX 10.6.5
Eclipse for PHP Developers (64bit)
Version: Helios Service Release 1
Build id: 20100917-0705

php-5.3.3 and xdebug v2.1.0 installed via homebrew
Comment 8 Toshihiro Izumi CLA 2010-11-14 01:57:19 EST
(In reply to comment #7)

Though I don't know Mac OS X at all...
Command-line arguments are available only for CLI.
Can you please ensure you are using CLI executable?
How about 'SAPI Type' in your PHP Executable setting? It must be 'CLI', not 'CGI'.
How about php version on command line such as
>$ /usr/bin/php -v
>PHP 5.2.4 (cli) (built: Sep 23 2007 22:34:35)
>Copyright (c) 1997-2007 The PHP Group
>Zend Engine v2.2.0, Copyright (c) 1998-2007 Zend Technologies
There must be '(cli)', not '(cgi)'.
Comment 9 Mark Sullivan CLA 2010-11-14 23:07:57 EST
I double checked the SAPI type is set to CLI. Here is the php version:


> php -v
PHP 5.3.3 (cli) (built: Nov  9 2010 19:42:04) 
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
    with Xdebug v2.1.0, Copyright (c) 2002-2010, by Derick Rethans
Comment 10 Zhongwei Zhao CLA 2011-05-05 04:10:21 EDT
*** Bug 331312 has been marked as a duplicate of this bug. ***
Comment 11 Roy Ganor CLA 2011-08-30 07:19:05 EDT
I tested it and it seems to be working...
Comment 12 Claus CLA 2011-09-26 12:10:50 EDT
I have the same problem. Even when I enter ${string_prompt:Test} as a script argument, Eclipse is not displaying the prompt to ask for the proper value. My arguments are totaly ignored.

PHP 5.3.2 (cli) (built: Aug 10 2011 14:15:30)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
    with the ionCube PHP Loader v4.0.7, Copyright (c) 2002-2011, by ionCube Ltd., and
    with Xdebug v2.1.2, Copyright (c) 2002-2011, by Derick Rethans

My platform is Windows 7 with Eclipse SDK 3.6.2 and PDT 2.2.1.v20101001-23000-...
Comment 13 Claus CLA 2011-09-29 06:38:49 EDT
(In reply to comment #12)
> I have the same problem. Even when I enter ${string_prompt:Test} as a script
> argument, Eclipse is not displaying the prompt to ask for the proper value. My
> arguments are totaly ignored.
> 
> PHP 5.3.2 (cli) (built: Aug 10 2011 14:15:30)
> Copyright (c) 1997-2010 The PHP Group
> Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
>     with the ionCube PHP Loader v4.0.7, Copyright (c) 2002-2011, by ionCube
> Ltd., and
>     with Xdebug v2.1.2, Copyright (c) 2002-2011, by Derick Rethans
> 
> My platform is Windows 7 with Eclipse SDK 3.6.2 and PDT
> 2.2.1.v20101001-23000-...

Sorry, this was my fault. After I enabled "Allocate Console" in the Debug Configuration script arguments are working like expected.
Comment 14 Nicolas D. CLA 2011-10-06 07:13:12 EDT
(In reply to comment #5)
> Hi
> 
> Both $argv and $_SERVER['argv'] only contain path to my PHP script :-(
> Which version of XDebug do you use ? I'm using 2.0.5 installed with Macports.
> Thanks

Try to check the configuration of the xdebug in the php.ini you use.

Take me a while to see that I took a different configuration file... whith the one below that works ...

xdebug.remote_enable = on
xdebug.profiler_enable = on
xdebug.profiler_enable_trigger = on
xdebug.profiler_output_name = cachegrind.out.%t.%p
xdebug.profiler_output_dir = "c:/tmp"
xdebug.remote_handle=dbgp
xdebug.remote_host=localhost
xdebug.remote_port=9000

Good luck
Comment 15 Mark CLA 2011-10-13 08:30:19 EDT
Hi I am having the same issue,..

php 5.3.6
xdebug 5.3.1
Eclipse Indigo
Platform OSX 10.7.1

My php.ini...

zend_extension="/Applications/XAMPP/xamppfiles/lib/php/php-5.3.1/extensions/no-debug-non-zts-20090626/xdebug.so"

xdebug.profiler_output_dir = "/tmp/xdebug/"
xdebug.profiler_enable = On
xdebug.remote_enable=On
xdebug.remote_host="localhost"
xdebug.remote_port=10000
xdebug.remote_handler="dbgp"

I have CLI Set

Any suggestions?
Comment 16 Mark CLA 2011-10-13 19:38:30 EDT
I Ran update for OSX Lion (10.7.2) and rebooted, guess what, args are being passed through now. Not sure why this is?
Mark.
Comment 17 Mark CLA 2011-10-16 22:38:36 EDT
Had to remove xampp and install dev environment nativly on osx lion, and this issue is happening again, i.e. not passing arguments when running a php script through debug configurations.

php 5.3.6
Eclipse Indigo SR1

Would like a workaround if possible.
Comment 18 Meng Xin Zhu CLA 2012-09-01 05:27:35 EDT
I met this one as well.

localhost% php -v               
                                                              
PHP 5.3.13 with Suhosin-Patch (cli) (built: Jun 20 2012 17:05:20) 
Copyright (c) 1997-2012 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2012 Zend Technologies
    with Xdebug v2.2.1, Copyright (c) 2002-2012, by Derick Rethans

PHP Development Tools (PDT) SDK Feature	3.0.0.v201201110400-77-184_2BEICRgM_fMVcz0M4Va9O	

Mac 10.8.1
Comment 19 Pollo Frito CLA 2012-11-17 04:32:28 EST
I also have this problem. 

Eclipse:
Version: 3.7.2
Build id: M20120208-0800

php -v:
PHP 5.3.9-ZS5.6.0 (cli) (built: Dec 22 2011 12:28:41) 
Copyright (c) 1997-2011 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2011 Zend Technologies
    with Xdebug v2.1.2, Copyright (c) 2002-2011, by Derick Rethans
    with Zend Extension Manager v5.1, Copyright (c) 2003-2010, by Zend Technologies
    - with Zend Data Cache v4.0, Copyright (c) 2004-2010, by Zend Technologies [loaded] [licensed] [disabled]
    - with Zend Job Queue v4.0, Copyright (c) 2004-2010, by Zend Technologies [loaded] [not licensed] [disabled]
    - with Zend Utils v1.0, Copyright (c) 2004-2010, by Zend Technologies [loaded] [licensed] [enabled]
    - with Zend Code Tracing v1.0, Copyright (c) 2009-2010, by Zend Technologies [loaded] [not licensed] [disabled]
    - with Zend Page Cache v4.0, Copyright (c) 2004-2010, by Zend Technologies [loaded] [licensed] [disabled]

I have followed the steps as described by the OP

1. Defined a new debug script configuration
2. Defined the php path
3. Defined a PHP script argument in dedicated tab
4. Check 'break on first line'
5. Inspect $_SERVER['argv'] on the first break - the name of my script is present but none of my script arguments are appended.

The fact that this is still a bug 2 years after first being reported is a bit of an issue don't you think?
Comment 20 Pollo Frito CLA 2012-11-17 04:33:17 EST
Sorry - should have mentioned, platform is Mac OS X 10.7.5

(In reply to comment #19)
> I also have this problem. 
> 
> Eclipse:
> Version: 3.7.2
> Build id: M20120208-0800
> 
> php -v:
> PHP 5.3.9-ZS5.6.0 (cli) (built: Dec 22 2011 12:28:41) 
> Copyright (c) 1997-2011 The PHP Group
> Zend Engine v2.3.0, Copyright (c) 1998-2011 Zend Technologies
>     with Xdebug v2.1.2, Copyright (c) 2002-2011, by Derick Rethans
>     with Zend Extension Manager v5.1, Copyright (c) 2003-2010, by Zend
> Technologies
>     - with Zend Data Cache v4.0, Copyright (c) 2004-2010, by Zend
> Technologies [loaded] [licensed] [disabled]
>     - with Zend Job Queue v4.0, Copyright (c) 2004-2010, by Zend
> Technologies [loaded] [not licensed] [disabled]
>     - with Zend Utils v1.0, Copyright (c) 2004-2010, by Zend Technologies
> [loaded] [licensed] [enabled]
>     - with Zend Code Tracing v1.0, Copyright (c) 2009-2010, by Zend
> Technologies [loaded] [not licensed] [disabled]
>     - with Zend Page Cache v4.0, Copyright (c) 2004-2010, by Zend
> Technologies [loaded] [licensed] [disabled]
> 
> I have followed the steps as described by the OP
> 
> 1. Defined a new debug script configuration
> 2. Defined the php path
> 3. Defined a PHP script argument in dedicated tab
> 4. Check 'break on first line'
> 5. Inspect $_SERVER['argv'] on the first break - the name of my script is
> present but none of my script arguments are appended.
> 
> The fact that this is still a bug 2 years after first being reported is a
> bit of an issue don't you think?
Comment 21 Claude Duvergier CLA 2013-01-18 08:50:37 EST
Same issue but with both "Debug Configurations" and "Run Configurations" on my plateform:
* Windows 7 Pro 64-bits
* Eclipse SDK 3.7.2.M20120208-0800 (64-bits)
* PHP Development Tools (PDT) SDK Feature 3.1.1.201209101312
* PDT Extensions Feature 1.0.12
* PHP 5.3.19 (32-bits)

----------8<----------
> php -v
PHP 5.3.19 (cli) (built: Nov 21 2012 21:48:06)
opyright (c) 1997-2012 The PHP Group
end Engine v2.3.0, Copyright (c) 1998-2012 Zend Technologies
    with Xdebug v2.2.1, Copyright (c) 2002-2012, by Derick Rethans
----------8<----------

Disabling Xdebug doesn't change anything.

Reproducible: Always

PHP Code to reproduce (file "/myproject/run.php"):
----------8<----------
<?php
var_dump($_SERVER['argv']);
----------8<----------

Steps to Reproduce:
1. Define a new Debug or Run configuration of type "PHP CLI Application"
   "PHP Script" tab:
     Runtime PHP: Project default PHP: in my case: "PHP (Xdebug 5.3.19 CLI)"
     PHP file: "/myproject/run.php"
   "PHP Script Arguments" tab:
     Script Arguments:
       --option1=value
   "Common" tab:
     Standard Input and Output:
       Allocate console (necesarry for input): ticked ([X])
2. Apply & Run/Debug configuration

Outputs (in Eclipse Console):
----------8<----------
array(1) {
 [0]=>
 string(26) "/path/to/myproject/run.php"
}
----------8<----------

Expected outputs, what is actually outputed when script is runned from system shell (`php /path/to/myproject/run.php --option1=value`):
----------8<----------
array(1) {
 [0]=>
 string(26) "/path/to/myproject/run.php"
 [1]=>
 string(15) "--option1=value"
}
----------8<----------

Tryed Claus's advice (comment #12) to place a "${string_prompt:Test}" in Script Arguments field: no prompt.
Using a file as "Standard Input and Output" (instead of a console) doesn't resolves anything (same script output).
Comment 22 Toshihiro Izumi CLA 2013-01-18 22:10:46 EST
Wow, thanks Claude.

PDT uses the code such as "sapiType == PHPexeItem.SAPI_CLI" in many places(e.g. org.eclipse.php.internal.debug.core.launching.PHPExecutableLaunchDelegate.launch()). This should be "PHPexeItem.SAPI_CLI.equals(sapiType)" since it is String type. PHPexeItem.SAPI_CGI as well.
Comment 23 Mark Boudreau CLA 2013-04-08 14:00:29 EDT
PHP 5.3.23 (cli)
OSX 10.8
Eclipse (4.2 - Juno)
PDT 

I had the same problem as all of the posters, but was able to fix the problem.  Even though you may have a CLI build of PHP, you need to register the $argc and $argv variables to get them to show up in Eclipse.

Check your php.ini file for "register_argc_argv".  Mine was set to Off.  Setting it to On fixed the problem.
Comment 24 Sadek Baroudi CLA 2013-11-08 21:10:33 EST
Created attachment 237326 [details]
Image reproducing Bug 323931
Comment 25 Wojciech Galanciak CLA 2014-03-26 07:46:42 EDT
Merged by Jacek.
Comment 26 Wojciech Galanciak CLA 2014-03-26 07:51:22 EDT
It was fixed by a patch for Bug 402829.
Comment 27 Sylvia Tancheva CLA 2015-06-04 09:37:12 EDT
I do not see any complains for a long time.
I tested on Luna with current PDT 3.5 / PHP 5.5.12/ xDebug.
Passing arguments worked OK.
Therefore I'll close this bug.
If anyone still have a similar problem please reopen with more information/steps to reproduce (or open a new issue if you prefer).