How to change Web.Config to allow PHP handling in VS 2013

Discussion about the open-source Phalanger [?] project.

How to change Web.Config to allow PHP handling in VS 2013

Postby profnimrod » March 17th, 2014, 9:23 pm

I am working on editing the WordPress 3.8.1 code in Visual Studio 2013 with Update 1. Over time I want to be able to write C#.NET plugins for WordPress. I have "PHP Tools for Visual Studio" installed. My current web.config file contents is:

Code: Select all
  <?xml version="1.0"?>
  <configuration>
    <system.web>
      <compilation debug="true" targetFramework="4.0"/>
    </system.web>
  </configuration>


When I run the website and navigate to the index.php I get an error relating to the fact that .php files are not being handled.

HTTP Error 404.3 - Not Found

The page you are requesting cannot be served because of the extension configuration. If the page is a script, add a handler. If the file should be downloaded, add a MIME map.


What do I need to add the web.config file such that the .php files are handled properly and yet still be able to run in debug mode using the PHP Tools for Visual Studio? Or is there some other setting I need to change?

(Also posted to SO - http://stackoverflow.com/questions/2246 ... tudio-2013)
profnimrod
 
Posts: 12
Joined: January 2nd, 2014, 6:12 pm

Re: How to change Web.Config to allow PHP handling in VS 201

Postby Jakub Misek » March 18th, 2014, 8:26 am

Hi,

With PHP, you don't need web.config file (unless you are configuring your own PHP server on Microsoft IIS)

Writing plugins for WordPress in C# is possible using opensource project Phalanger - in this way, all your PHP web has to run as a Phalanger Web Site. Please see e.g. http://www.php-compiler.net/blog/2012/w ... langer-3-0 for more details.

Thanks,
Jakub Misek │ DEVSENSE s.r.o. | @misekjakubjakub@devsense.com
User avatar
Jakub Misek
 
Posts: 2092
Joined: January 4th, 2012, 2:42 pm
Location: Prague

Re: How to change Web.Config to allow PHP handling in VS 201

Postby profnimrod » March 18th, 2014, 2:12 pm

Thanks for the link. This was actually the place I started, but in the end installed the Brandoo version of WordPress (http://www.microsoft.com/web/gallery/br ... mssql.aspx), and used the link you provided to integrate Phalanger 3.0 (basically adding the appropriate Web.config and Bin folder with Phalanger).

When I run the site in just a browser (without the Web.config and outside of Visual Studio 2013) it works just fine. Also outside of VS2013, but with the Web.config (and therefore Phalanger) I get 3 compilation errors. When I fix the compilation errors, I get a database error which is so vague I can't figure it out.

To help troubleshoot, I want to be able to run the site (without Phalanger installed) in debug mode. This is why I installed PHP Tools for VS. So I guess my question should be: How do I run a PHP website in Visual Studio with debugging?

If I was running in IIS I would have to make sure there was a handler for the PHP mime type.
profnimrod
 
Posts: 12
Joined: January 2nd, 2014, 6:12 pm

Re: How to change Web.Config to allow PHP handling in VS 201

Postby profnimrod » March 18th, 2014, 2:25 pm

I am one step further along. When running in VS2013 IIS Express is used and this was not configured to handle PHP files. The following commands were sent from the command line to fix that:

Code: Select all
"C:\Program Files (x86)\IIS Express\appcmd.exe" set config /section:system.webServer/fastCGI /+[fullPath='"C:\Program Files (x86)\PHP\v5.4\php-cgi.exe"']

"C:\Program Files (x86)\IIS Express\appcmd.exe" set config /section:system.webServer/handlers /+[name='PHP_via_FastCGI',path='*.php',verb='*',modules='FastCgiModule',scriptProcessor='"C:\Program Files (x86)\PHP\v5.4\php-cgi.exe"',resourceType='Unspecified']


You'd have to check the paths for your own installation.
profnimrod
 
Posts: 12
Joined: January 2nd, 2014, 6:12 pm

Re: How to change Web.Config to allow PHP handling in VS 201

Postby Jakub Misek » March 18th, 2014, 2:33 pm

I would like to note again, PHP != Phalanger. Mentioning php-cgi.exe means, this is not clear. If you wish to experiment with Phalanger, you don't need any PHP on your server.
Jakub Misek │ DEVSENSE s.r.o. | @misekjakubjakub@devsense.com
User avatar
Jakub Misek
 
Posts: 2092
Joined: January 4th, 2012, 2:42 pm
Location: Prague

Re: How to change Web.Config to allow PHP handling in VS 201

Postby profnimrod » March 18th, 2014, 2:34 pm

Although I have the PHP files handled correctly now in VS2013, when I add breakpoints they are ignored. Shouldn't the PHP files be handled by some part of the "PHP Tools for Visual Studio" installation? If so, I'm back to my original question, what changes do I need to make to the web.config file so that "PHP Tools for Visual Studio" handles the PHP files, and allows me to run in debug mode?
profnimrod
 
Posts: 12
Joined: January 2nd, 2014, 6:12 pm

Re: How to change Web.Config to allow PHP handling in VS 201

Postby profnimrod » March 18th, 2014, 2:37 pm

I realize PHP != Phalanger. At this point I do not want to compile the code with Phalanger. I just want to be able to run a PHP-based website in Visual Studio 2013 in debug mode (which is why I installed "PHP Tools for Visual Studio 2013" hoping this would allow that). This will help me troubleshoot my database access problem, but also allow me to follow the PHP code along so that I can learn more about how PHP works. When I have everything working the way I want, then I can integrate Phalanger, compile the code, and all will be good with the world ;-)
profnimrod
 
Posts: 12
Joined: January 2nd, 2014, 6:12 pm

Re: How to change Web.Config to allow PHP handling in VS 201

Postby Jakub Misek » March 18th, 2014, 2:45 pm

Ok. PHP Tools configure IIS Express automatically; you don't need web.config file there.

You just have to ensure, in Tools | Options | PHP Tools | Interpreters, you have PHP with no configuration issues.

Then create PHP Web Project, go to its properties, select IIS Express and type URL for the project.

Note, when WordPress is started/configured for the first time, it saves used URL into database, and it won't be possible to change it later (in a recommended way).
Jakub Misek │ DEVSENSE s.r.o. | @misekjakubjakub@devsense.com
User avatar
Jakub Misek
 
Posts: 2092
Joined: January 4th, 2012, 2:42 pm
Location: Prague

Re: How to change Web.Config to allow PHP handling in VS 201

Postby profnimrod » March 18th, 2014, 2:54 pm

Many thanks Jakub... Just as you wrote I also found a screencast at: http://www.youtube.com/watch?v=otfHuSzx ... 9cAqT85cmA which gives a greate walkthrough of how to work with WordPress in VS using PHP Tools... Hooray! Looks like I was just creating the project the wrong way to start with.
profnimrod
 
Posts: 12
Joined: January 2nd, 2014, 6:12 pm

Re: How to change Web.Config to allow PHP handling in VS 201

Postby Jakub Misek » March 18th, 2014, 4:02 pm

Please give me know if you would find any other issue. We'll try to make it more clear in future.

Thanks!
Jakub Misek │ DEVSENSE s.r.o. | @misekjakubjakub@devsense.com
User avatar
Jakub Misek
 
Posts: 2092
Joined: January 4th, 2012, 2:42 pm
Location: Prague

Next

Return to Phalanger project

Who is online

Users browsing this forum: No registered users and 21 guests

cron

User Control Panel

Login

Who is online

In total there are 21 users online :: 0 registered, 0 hidden and 21 guests (based on users active over the past 5 minutes)
Most users ever online was 227 on March 28th, 2024, 9:13 am

Users browsing this forum: No registered users and 21 guests