• PHP Help
  • Eclipse PHP IDE. Opening Notepad on Run

No, VSCode doesn't actually start a local server. You'll need to open a terminal window (again, I use Ubuntu via WSL2 - I assume you can use powershell or cmd on Windows base) and run php -S localhost:8001. You can also use the terminal built into VSCode to do this, I think. This will start PHP's built-in dev server, which you'll be able to hit in your browser at http://localhost:8001.

As to the function not found, are you certain you've got the sqlsrv extension installed? Check the output of phpinfo() to make sure it's actually there. You may be able to use PDO intead, but I'm not familiar enough with sqlsrv to speak to that with any level of certainty.

Weedpacket Yes. As I said the sqlsssrv objects are visible to intellisense and I can interrogate the sql database in vscode.

maxxd
I will explore that but if it doesn't work I will just use VSCode as an editor. It's useful for that at least,
I would add a screen dump to show the enabled extensions but the Add Image function doesn;t work,
It just puts link ![](https://) in the comment.
I have no idea what I'm supposed to do with that.
Not something I have seen befiore.
It's certainly unconventional

    Weedpacket
    Understand that the project works fine under IIS.
    Everything about it. The pages render properly. Navigation works and all database transactions.
    Obviously PHP knows about the drivers. Otherwise there would be no communication with the database.
    This isn't about the project not working as it should do.
    It's a question of why it won't run in VSCode using the built iin server for PHP.
    It's VSCode that can't see the drivers.

      But VSCode isn't running your code. PHP is. That's why you have PHP's built-in server (it's not VSCode that has the built-in server, it's PHP). Seems that different configurations are being used in the two cases. Check phpinfo for both and see what they report for "Loaded Configuration File". (Doing this on the internal server is just a matter of having a file phpinfo.php containing <?php phpinfo(); ?> and then requesting that file.) Check, too, for a SQL Server specific section. Might as well also look at the extension_dir and include_path settings while you're there, but that information comes from php.ini so if they're reading the same file those would be the same also.

      Weedpacket
      How do you imagine it would run under IIS if PHP wasn't correctly configured?
      It wouldn't. I know this because it didn't run until I configured PHP properly.
      There is only one PHP installation folder on the machine. PHP 7.4.33 and compatible drivers.
      extension=php_sqlsrv_74_nts_x64.dll
      extension=php_pdo_sqlsrv_74_nts_x64.dll
      There is only one PHP.ini file in the root of the PHP installation folder
      Both IIS and VS Code are pointing to the same PHP installation folder.
      Both IIS and VS Code are pointing to the same workspace folder where the project files are located.
      Both IIS and VS Code are pointing to and connected to the same SQL Server instance and the same database.
      Using the same authentication method and credentials.
      The site runs fine under IIS on localhost.

        The whole point here is that VSCode is just an editor. Nothing more. It won't "run" your site, and it doesn't care where on your system PHP is installed beyond being able to provide hints and definitions as you code. And unless you've installed an SQL plugin, VSCode doesn't care a thing about your database.

        As to the 'Add Image' function, I'm not really sure what that refers to. However, the ![](https://) is pretty standard Markdown, which has been around since about 2004. In fact, this board uses it. Click the link button in the editor and you'll see almost exactly what you posted (the exclamation mark lets the interpreter know you mean an image, not a hyperlink).

        If your site is working on the same machine you're developing on, then it sounds like the confusion has to do with what you expect VSCode to do. If it's working on a different machine, then you need to heed Weedpacket's advice and check the setup on your local machine - something is different between the two systems.

        It sounds like you've gotten used to doing things a specific way, which is very understandable. In the meantime, the world has moved on and you're just now getting shoved into it. I've been at this for ~25 years so I get it but I can tell you it's much better now then it was back then.

        maxxd
        Maybe I am expecting too much from VS Code.
        VS Code is a good PHP editor. No problem with that.
        But it is called an IDE and an IDE is more than just an editor.
        It has run and debug facilities and they do launch the site.
        Bottom line is it can't see the drivers whereas the IIS webserver can.
        It's the runtime and debug that's not working.
        It's not a show stopper. I will still use the editor and run the projects under IIS.
        It would be nice to inderstand why it doesn't work.

        Typical Add Image function, at least in my websites, allows you to Browse local images and upload them.
        It uses a an HTML input type="file" name="filename" tag. This renders a Browse button on the form.
        But I have never seen this ![](https://)
        What am I supposed to do with that link when presented with it?
        What would I have to do with that to link it to and upload a local file?

        I am a .Net developer. Every version from the first in 2000 to the latest 2022 version.
        Been using SQL Server and IIS just as long. Began developing web applications in 1998.
        HTML/Javascript/Perl/CGI first off and the Classic ASP. Picked up .Net in 2000.
        So I am the same vintage as you.

          Weedpacket
          What do you want to know about the phpinfo() report?

          Her are the module loaded in teh php.ini

          C:\php-7.4.33-nts-Win32-vc15-x64>php -m
          [PHP Modules]
          bcmath
          calendar
          Core
          ctype
          date
          dom
          filter
          hash
          iconv
          json
          libxml
          mbstring
          mysqlnd
          odbc
          pcre
          PDO
          pdo_mysql
          PDO_ODBC
          pdo_sqlite
          pdo_sqlsrv
          Phar
          readline
          Reflection
          session
          SimpleXML
          SPL
          sqlsrv
          standard
          tokenizer
          xml
          xmlreader
          xmlwriter
          zip
          zlib

          C:\php-7.4.33-nts-Win32-vc15-x64>

            Well, I said what I wanted to see ...
            And pdo_sqlrv/sqlsrv are listed (I expect there would also be ... but I said that already). Now, what do you see if you try this in an environment (i.e. VSCode) and debugging workflow where it would fail with an unknown function error?

              Not to be pedantic, but VSCode actually doesn't claim to be an IDE - https://code.visualstudio.com/docs/supporting/faq#_what-is-the-difference-between-visual-studio-code-and-visual-studio-ide.

              It does support in-app debugging; in the case of PHP through PHPDebug but that takes a bit of setup and, if I'm not mistaken, a plugin. If that's what you're asking about then there may have been a misunderstanding at the outset - probably mine, to be honest.

              maxxd Then perhaps recommending VSCode over Eclipse, which is an IDE, is not such a greatr idea after all.

              RayPooley Then perhaps recommending VSCode over Eclipse, which is an IDE, is not such a great idea after all.

              Probably true if using an IDE in its fullest definition is important to you -- and I don't mean that to sound like I'm saying that's wrong, mind you. 😉

              In my personal case -- which has never included working in an IIS environment -- I've always depended on local testing via a browser with a local instance of a web server/PHP/database running. Therefore I've never concerned myself with that aspect of any IDE I've used (running/testing the app from within the IDE itself).

              Nowadays, FWIW, I'm usually running things in a Docker container, with my local project file directory mounted by the container so that I can instantly test any changes as I make them.

              And again, I'm not saying either approach is better, just me rambling on a Sunday morning while watching the final stage of le Tour de France. 🙂

              NogDog It's probably fair to say that I have been spoiled as a .Net developer
              working with Visual Studio since the late 1990s. It's a brilliant development environment that works
              seamlessly with it's internal server and IIS straight out of the box. VS 2022 actual has a PHP development
              platform now too. I would rather keep .Net and PHP developmentenvironments seperate.

                Latest update.

                I have gone back to sorting out the original Eclipse problem (above).
                Eclipse now works fine.
                So what was the solution?

                I first reinstalled Eclipse IDE
                Eclipse IDE for PHP Developers (includes Incubating components)
                Version: 2023-06 (4.28.0)
                Build id: 20230608-1333
                OS: Windows 11, v.10.0, x86_64 / win32
                Java vendor: Eclipse Adoptium
                Java runtime version: 17.0.7+7
                Java version: 17.0.7

                In my case I set up a workspace C:\eclipse-workspace and put my PHP project subfolders in that folder.
                I then opened the projects in Eclipse from that folder. They opened up for editting ok.

                When I tried to run them using the built in PHP server a browser session launched. This fixes the original
                problem of it opening a Notepad session. So that;s progress.

                But the problem was that it was looking to the c:\inetpub\wwwroot folder for project folders rather
                than referencing the actual physical path for the projects,
                I have been unable to find a way of changing that default in the system.

                So I have moved all of my PHP project folders from the c:\eclipse-workspace folder to the
                c:\inetpub\wwwroot folder and they launch as they shou;ld in the browser. Even without setting up any
                specific sites for the project in IIS. I find it odd that Eclipse should default to what is effectively the default
                folder for IIS on Windows systems.

                Anyway it's now working now.

                It would be nice to have some answers regarding these behaviours
                but I will leave it there.

                  Write a Reply...