在变得有点疏远开源,并花了几年时间在ASP.NET中开发 Web 应用程序之后,我将开始做大量的 PHP / MySQL 开发。
我已经非常轻松地安装了WampServer以在我的 Windows 机器上启动并运行开发环境,但我的目标平台很可能是 Linux。我是否可能会因为在 Windows 上开发而以 Linux 为目标而遇到问题?是否建议投资获得用于开发 LAMP 应用程序的 Linux 环境设置?
在变得有点疏远开源,并花了几年时间在ASP.NET中开发 Web 应用程序之后,我将开始做大量的 PHP / MySQL 开发。
我已经非常轻松地安装了WampServer以在我的 Windows 机器上启动并运行开发环境,但我的目标平台很可能是 Linux。我是否可能会因为在 Windows 上开发而以 Linux 为目标而遇到问题?是否建议投资获得用于开发 LAMP 应用程序的 Linux 环境设置?
If you can, I'd invest in some kind of Linux, or at least *nix, development environment. For simple applications and websites, your setup is fine, but you will eventually run into subtle differences when you deploy.
Here are some things off the top of my head you'll want to watch out for if you stick with your Windows environment.
File paths. A lot of PHP functions take file paths as arguments. Do not use the Windows backslash (\) separator. Even though you're on Windows, PHP will let you use a forward slash separator. Ideally abstract this away with your own file path class.
Apache Modules, PECL Extensions. Apache Windows and Apache Unix often come with a different set of Apache Modules installed by default. Also, the same version of a module may run differently on a different platform. If your application relies on any Apache module, make sure it's available for both platforms. The same goes for PHP custom extensions (PECL).
Process Forking. Using exec, `, etc. in a web application is a bad idea to begin with, but if you're using these functions they're going to behave differently between Windows and *nix
File writing, locking, etc. works different
Email is handled differently on both platforms
The PHP group's code word for Windows is "some platforms". You can research more on your own if you'd like
In general, the closer your development environment matches your production environment, the fewer environment/deployment related issues you'll have.
在过去的几年里,我一直在这样做,还没有遇到任何问题——如果有的话,它可以通过强迫你编写更多可移植的代码来给你带来优势。
Permissions and the fact that on Windows filenames aren't case-sensitive are the two things I can think of that have been a pain to me. But they are
不,在 WAMP 上开发并在 LAMP 上运行应该没问题,但至少在 LAMP 上运行。
我已经两种方式都没有遇到很多问题(好吧,过去在 WAMP 上部署企业站点时会遇到很多问题(不要尝试使用 PHP ISAPI 过滤器),但现在它们是可以解决的(FastCGI))。
只要您不添加任何声明它们在 Windows 上不受支持的 PECL 模块,您就不会有任何问题。此外(由于您说您使用的是 WAMP,我假设您使用的是 MySQL),SQL Server和 PHP 有很多问题(它需要的古老驱动程序严重限制了查询的长度)。
理论上,PHP 和 MySQL 应该是完全平台无关的。
在实践中,如果您要拥有一个真正的生产应用程序,我建议您拥有一个镜像生产环境的测试环境,以避免意外。
是的,我建议在尽可能接近生产环境的环境中进行开发。
There are differences between how PHP works on Windows as compared to Linux. And other differences like how Linux handles file permissions as compared to Windows. I run the free VMware server with a Linux virtual machine.
I have a Samba share on the Linux VM that I mount as a networked drive in Windows. Then I use Eclipse on Windows as my code editor.
It's worth having a LAMP sandbox so you can get to know where to find - and how to edit - configuration files, get comfortable with restarting services, handling scheduled jobs, etc. if you are going to have to deal with these tasks in production.
No.
VirtualBox + shared folders should be useful if you have about 6-8 hours free on one weekend to get all VirtualBox basics clear and settings worked out.
If you're switching to Linux, the process may take up to a month and you will be highly unproductive in that time, in terms of production code.
It is a good idea to keep practicing Linux on VirtualBox for Windows, in advance before switching, using one of PCLinuxOS, CentOS, openSUSE, or Ubuntu. I prefer CentOS and PCLinuxOS.
There's a gem called SLAMPP and another beauty called XAMPP <-- works on Linux and Windows.
IMO, as a rough guesstimate, if you expect to code 2000-3000 lines of code (that you write/add) per project, for six months to one year, stick to Windows and master Linux meanwhile using VirtualBox.
If above that, or if you plan to make a cool new LAMP website, I think you should switch to Linux first. Take a month more to get used to Linux. You can still shuffle around with dual boot or VirtualBox for as long as you like, starting as early as you can - learning Linux enough to debug a LAMP application does take time.
Paths, beware of paths. You can build a whole CMS and it would mess up because of paths.