Run configuration, script parameters

Tell me, please, how to set parameters.
I want to set $_GET['key']='zz' (or ?key=zz)
This forum posting page still bugged, so read from bottom to top.

Comment actions Permalink

When using Php Script configuration, parameters are accessed like from the command line, via $argv, see
If you want to test parameters passed via $_GET, you need to run your script on server (using PHP Web Application Run/Debug configuration where you can specify URL to open with parameters).

Comment actions Permalink

Hello OZ,

You can set necessary values manually.

In such manner, for example.

    $_GET['key'] = 'value';
    $_POST['key'] = 'value';

Thank you for feedback!

Comment actions Permalink

Heh, I can write even easily: $_GET['key']='value'; :) But it's not usable for testing completed scripts.

Comment actions Permalink

As Serge already mentioned, PHP Script run configuration is for running scripts in CLI mode where you cannot pass GET/POST parameters automatically (unless you set them in your code directly).

You can easily pass GET parameters when using PHP Web Application run configuration -- just add them to the script URL (Start URL field). In your example it will be something like:

As for POST parameters ... I guess this is the right ticket to watch:

Comment actions Permalink

I have not enough experience with running php in CL, and now I understand that this idea can not be normaly done, because of CLI restrictions.
Thanks for tips, excuse me for this stupid theme :)

Comment actions Permalink

I know it's almost ten years since last comment in this thread but its still in google first page so I want to share other people the solution I found witch fixed this problem .

So passing arguments to php cli using phpstorm configuration won't fix the problem cause you can't pass a variable value and tell php cli to assign it to variable . At least you can't do it directly . But by using some hacks you can do it really easily.


define("DEBUG", TRUE); // Activate debugging mode
if (
DEBUG === true // Checks if debugging mode is activated
PHP_SAPI === "cli" // Checks if PHP script runs through CLI
parse_str(implode('&', array_slice($argv, 1)), $_GET); // Pass arguments to $_GET

Using debugging mode is not necessary, but it's a best practice at least for situations that I don't want to delete some "debugging specific codes" that I wrote before deployment.

References :


Please sign in to leave a comment.