VS Code.

New to this IDE. I have been trying to get Eclipse to work with no luck so I thought I would
check out VS Code see what it's like.

I have a couple of questions about configuration.

How do i set the default document or path to it from the document root in launch.json configuration.

I have just installed VS Code and I'm trying to get a sample website to work.

Here isa configuration cobbled together from some examples already in the launch.json file.

I have no idea what these runtimeArgs mean by the way. It's early days and I can't find a write up.

"configurations": [
{
"name": "Launch Hello PHP",
"type": "php",
"request": "launch",
"runtimeArgs": [
"-S",
"localhost:8081",
"-t",
"."
],
"port": 9003,
"serverReadyAction": {
"action": "openExternally"
}
},

When I run this config I get the following response in the browser.

The url in the browser is "localhost:8081"

The page displays NOT FOUND The resource / was not found on this server.

When I manually change the url in the browser to http://localhost:8081/HelloPHP/index.php the page resolves ok.

But obviously you can't keep doing that every time you run the project.

The PHP $_SERVER["DOCUMENT_ROOT"] produces C:\eclipse-workspace

The getcwd() PHP function produces C:\eclipse-workspace\HelloPHP.

The index.php file is in the C:\eclipse-workspace\HelloPHP folder.

If I change the "localhost:8081" runtimeArg argument to "localhost:8081/HelloPHP/index.php" in the above
configuration the page doesn't resolve.

It says Unable to connect. Firefox can’t establish a connection to the server at localhost:8081.

So obviously that's not a solution.

Hence the questions.

How do i set the default document or path to it from the document root in launch.node js configuration.

In IIS, for example, I would set these values via the site Bindings and Default document.

So what is the equivalent to that in in VS Code is the question.

Thanks and regards
Ray

Weedpacket Thanks for the listing. I will have a poke around with them.
Much appreciated.

Ray

    For the benefit of others.

    Here's a configuration in the launch.json file that works.

    If you are familar with IIS bindings this is their VS Code equivalent:

    The "192.168.1.225:8081" is the equivalent of your Bindings entry.

    The "c:/eclipse-workspace/hellophp/" is the equivalent of your Basic Settings Physical path.

    The "index.php" is the equivalent of your Site Default Document.

    This resolves in the browser when lauched using the built in server.

    Other parameters are :

    "type": "php" is your MIME Type

    "c:/php-7.4.33-nts-Win32-vc15-x64" the absolute path to your PHP system folder.

       "configurations": [
            {
                "name": "Launch Hello PHP",
                "type": "php",
                "request": "launch",
                "runtimeArgs": [
                    "-c",
                    "c:/php-7.4.33-nts-Win32-vc15-x64",
                    "-f",
                    "index.php",
                    "-S",
                    "192.168.1.225:8081",
                    "-t",
                    "c:/eclipse-workspace/hellophp/"
                ],
                "port": 9003,
                "serverReadyAction": {
                "action": "openExternally"
                }
            }
    

    Thanks again to WeedPacket for the elusive Commandline options link
    which is very helpful and worth a look at.

    Cheers

    Ray Pooley

    Thanks for the follow-up. I added [code]...[/code] tags to make the JSON section "pretty"...hope you don't mind. 🙂

    11 days later

    NogDog

    Ok. I wasn't sure that would work.
    While I have your attention, how do I upload local images to a comment.
    The Add an Image button doesn't open a file browser to allow me to select an image.
    I just puts this into the comment ---- > ![](https://)

    Weedpacket
    Maybe they should remove the Add an Image icon.
    I do have an external server that I could upload them to but it's a bit os a faff to be honest.

    Cheers

      Write a Reply...