使用PHP和Visual Studio开发本地的最佳方法是什么?

时间:2023-01-13 01:30:44

I am taking my first foray into PHP programming and need to configure the environment for the first time. Can I use PHP with the built in VS web server or do I need to (and I hope not) use IIS locally?

我正在第一次涉足PHP编程,需要首次配置环境。我可以将PHP与内置的VS Web服务器一起使用,还是我需要(我希望不是)在本地使用IIS?

In addition, any pointers on pitfalls to be avoided would be great.

此外,任何有关陷阱的指针都应该是很好的。

Many thanks.

Update: I should have made the question more explicit. I am developing a ASP.Net MVC application.

更新:我应该更明确地提出这个问题。我正在开发一个ASP.Net MVC应用程序。

Update 2: It's become clear that I haven't asked the question as cleanly as I would have liked. Here is what I am doing. I have an existing ASP.net MVC application that I am adding an e-mail form to. While researching, I came across this page: Ajax Forms with jQuery and I liked the interface he presented and thought I would try and adapt it. Calls are made to PHP functions and hence my question.

更新2:很明显,我没有像我希望的那样干净地问这个问题。这就是我在做的事情。我有一个现有的ASP.net MVC应用程序,我正在添加一个电子邮件表单。在研究的过程中,我遇到了这个页面:使用jQuery的Ajax Forms,我喜欢他提出的界面,并认为我会尝试和调整它。调用PHP函数,因此我的问题。

It is also clear that the confusion also could come from the fact that there is a better approach entirely. So, what is the way out of the maze, Alice?

同样清楚的是,混淆也可能来自完全有更好的方法这一事实。那么,爱丽丝走出迷宫的方式是什么?

3 个解决方案

#1


1  

For what you're doing, you really shouldn't be using the PHP scripts from that example.

对于你正在做的事情,你真的不应该使用该示例中的PHP脚本。

Instead, you should be pulling data from the Form variables posted to the server on your own self-made pages. I don't know the "proper" way to do this using the MVC framework. With the ASP Forms framework, you'd do something like this to handle the POSTed data (example of the sendmail.php file)

相反,您应该从您自己的自制页面上发布到服务器的Form变量中提取数据。我不知道使用MVC框架执行此操作的“正确”方法。使用ASP Forms框架,你可以做这样的事情来处理POSTed数据(sendmail.php文件的例子)

string mailTo = Request.Form["emailTo"];
string mailFrom = Request.Form["emailFrom"];
string subject = Request.Form["subject"];
string message = Request.Form["message"];

// Send mail here using variables above
// You'll need an SMTP server and some mail 
// sending code which I'm drawing a blank as
//  to what the name of the classes are at the moment

There is probably a better way to handle this code in the MVC framework, but I haven't worked with it enough to tell you what it is.

在MVC框架中可能有一种更好的方法来处理这段代码,但我没有用它来告诉你它是什么。

Basically, you can't use PHP code at all for an ASP.NET app.

基本上,您根本不能使用PHP代码来使用ASP.NET应用程序。

#2


0  

PHP on IIS is a bit of a pitfall in itself, you can find some reference here: What do I need to run PHP applications on IIS?

IIS上的PHP本身就是一个陷阱,你可以在这里找到一些参考:在IIS上运行PHP应用程序需要什么?

I would sugest using WAMP from here: http://www.apachefriends.org/en/xampp-windows.html

我会从这里使用WAMP:http://www.apachefriends.org/en/xampp-windows.html

#3


0  

I'm using XAMPP on Windows. Works well.

我在Windows上使用XAMPP。效果很好。

#1


1  

For what you're doing, you really shouldn't be using the PHP scripts from that example.

对于你正在做的事情,你真的不应该使用该示例中的PHP脚本。

Instead, you should be pulling data from the Form variables posted to the server on your own self-made pages. I don't know the "proper" way to do this using the MVC framework. With the ASP Forms framework, you'd do something like this to handle the POSTed data (example of the sendmail.php file)

相反,您应该从您自己的自制页面上发布到服务器的Form变量中提取数据。我不知道使用MVC框架执行此操作的“正确”方法。使用ASP Forms框架,你可以做这样的事情来处理POSTed数据(sendmail.php文件的例子)

string mailTo = Request.Form["emailTo"];
string mailFrom = Request.Form["emailFrom"];
string subject = Request.Form["subject"];
string message = Request.Form["message"];

// Send mail here using variables above
// You'll need an SMTP server and some mail 
// sending code which I'm drawing a blank as
//  to what the name of the classes are at the moment

There is probably a better way to handle this code in the MVC framework, but I haven't worked with it enough to tell you what it is.

在MVC框架中可能有一种更好的方法来处理这段代码,但我没有用它来告诉你它是什么。

Basically, you can't use PHP code at all for an ASP.NET app.

基本上,您根本不能使用PHP代码来使用ASP.NET应用程序。

#2


0  

PHP on IIS is a bit of a pitfall in itself, you can find some reference here: What do I need to run PHP applications on IIS?

IIS上的PHP本身就是一个陷阱,你可以在这里找到一些参考:在IIS上运行PHP应用程序需要什么?

I would sugest using WAMP from here: http://www.apachefriends.org/en/xampp-windows.html

我会从这里使用WAMP:http://www.apachefriends.org/en/xampp-windows.html

#3


0  

I'm using XAMPP on Windows. Works well.

我在Windows上使用XAMPP。效果很好。