Vscode does not open page in browser

Asked

Viewed 4,002 times

0

Next, I installed PHP Debug in VS Code just like this site teaches https://imasters.com.br/back-end/configurando-debugger-php-no-vs-code, however, when running vs does not open the page in the browser. Someone knows why?

Laucher.json (I tested using port 80 which is the q I use in wamp, even so will not).

    {
        "name": "Listen for XDebug",
        "type": "php",
        "request": "launch",
        "port": 9000
    },
    {
        "name": "Launch currently open script",
        "type": "php",
        "request": "launch",
        "program": "${file}",
        "cwd": "${fileDirname}",
        "port": 9000
    }

php.ini (this was added when adding the Debug extension)

   xdebug.remote_enable = off
   xdebug.profiler_enable = off
   xdebug.profiler_enable_trigger = Off
   xdebug.profiler_output_name = cachegrind.out.%t.%p
   xdebug.profiler_output_dir ="c:/wamp64/tmp"
   xdebug.show_local_vars=0
   zend_extension = \php_xdebug-2.6.0-7.2-vc15-x86_64.dll // esse arquivo está na mesma pasta do php.ini
   xdebug.remote_enable = 1
   xdebug.remote_autostart = 1
  • The article is to use Xdebug to debug the script directly on the Vscode console, if understood, open the browser is something complicated, Apache uses virtual and non-physical routes, of course it should be possible to point a file to open "with HTTP", but if it will depend a lot on configuring Apache (Wamp, xampp, easyphp all use apache, which is the http server, PHP is only the script interpreter, despite having a built-in mini server). Example when using a route framework even if Vscode opened the browser would not understand well the routes, as Laravel, because the paths are not physical.

  • If you are just open in the browser you can use some extension type a Live Server that can solve.

  • William, I usually use wamp with netbeans, and it opens, do you think it might be something with Vscode? (I’m wanting to use VS because it’s lighter than netbeans).

4 answers

1


There is a "PHP Server" extension that starts a built-in PHP server, I think by default on port 3000. After installation of the extension, Ctrl+Shift+P, shortcut to the Command Palette, search PHP Server, a 'ps' already brings as a result depending on your extensions, and Enter. You will then open the file in the browser. You can also use the right mouse button and the PHP Server option: Open file in Browser.

Here is a great article showing step by step how to enable this extension and others for the purpose of debbug PHP code:

https://www.linkedin.com/pulse/debuggingo-c%C3%B3digo-php-com-Xdebug-visual-studio-code-Ricardo-Torquato/

0

Hello

It’s simple to squeeze Ctrl+Shift+D shortcut key, will appear Lounch Chrome Against localhost upper left corner, next will have the Launch.json configuration open it

will is with these settings:

{
    https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "type": "chrome",
            "request": "launch",
            "name": "Launch Chrome against localhost",
            "url": "http://localhost:8080",
            "webRoot": "${workspaceFolder}"
        }
    ]
}

url: you change where the file is in the Ex directory:

            "url":"http://localhost/nomeDirA/nomeDirB/nomedoArquivo.php,

Just ready from Start Debugging that will open the file in the Browser.

-1

If you are using from version 5.4 of PHP, you can run the command

 php -S localhost:8000

directly at the terminal/prompt inside your project directory. Then just access the browser through http://localhost:8000

I hope it helped. Hugs

-3

Hello,

Manually do the process with VSCODE. Open the browser and type:

localhost/nomedapastadoseuprojeto

Another point is to check your use of frameworks that may have specific ports defined, for example the Angular that uses the 4200 (at least here on my pc).

Browser other questions tagged

You are not signed in. Login or sign up in order to post.