I'm developing a PHP app on windows, and so far I've been using the built-in web server of the php executable (https://www.php.net/manual/en/features.commandline.webserver.php).
However, the application now has grown, and it makes many php requests. On windows, the built-in web server does not allow forking and therefore can only answer one request at a time, which makes it very slow.
I'm looking for something very simple, just serve a local folder with php interpreter. It must be a portable solution, just copy/paste to another computer and it works, and it must run multithreaded in windows.
I've been trying the windows subsystem for linux, and running the server there, but I wanted to ask for an alternative. This requires too much installation, I really wanted something much more portable: just copy/paste the folder and run a .bat to start the server.
Related
I originally started developing PHP via WAMP/MAMP stacks. These work, but there are a lot of painful caveats to deal with.
More recently, I've begun working with other software stacks, like rails, that can run the server from arbitrary directories with a minimum of configuration, muss, or fuss. Just a simple rails -s or python -m SimpleHTTPServer 8000. (OK, the second one might not be simple).
Unfortunately, the rails one is for running a rails server. The python one sets up a very simple HTTP server. Neither one is appropriate for running PHP code.
Are there any alternatives out there to run a PHP based server from an arbitrary directory -- in this case, the development directory of the app I want to work on? I'd strongly prefer Mac OSX, but if there's a windows version available as well, I'd love to hear about it.
As of 5.4, PHP includes a built-in web server that can be used for development.
For example:
php -S localhost:8000 index.php
Documentation: Built-in web server
But keep in mind:
This web server was designed to aid application development. It may also be useful for testing purposes or for application demonstrations that are run in controlled environments. It is not intended to be a full-featured web server. It should not be used on a public network.
What are the advantages of running scripts (generally speaking) locally on a personal computer?
Is it possible to run php files locally?
I can't really say what the advantages are, as it totally depends on what you're doing.
But yes, it's possible to run locally. You just need to set up a server. Some popular ones include xampp and easyphp.
It's difficult to say advantages. Advantages as compared to what? The advantages of running any script or program are that it accomplishes a goal it was designed for to facilitate the life of the user (hopefully). Running one on your local computer is not any different than running one remotely, per se.
As for running php files locally, yes, you can do this very easily. Just install php and there you go. If you are running a linux machine, it's very easy to install and run php scripts as executables to do whatever you want them to do. If you want to run the php scripts through something like mod_php, you must install a server. Apache is small and easy to install. I'm sure there are countless others.
The main advantage is that, in the development & testing phases, if you run the scripts locally, you suffer less lag than running them on a remote server, and you don't have to upload them each time you change them, which in development phases happens very often (ie continuously).
We've been battling this problem for some time now, and can't seem to find a perfect solution that would satisfy all the requirements of making life easier for developers.
Right now we have the following setup:
Linux development server (as everything we produce runs on linux, and it uses some linux-specifix libraries)
Windows desktops (as the office network is on windows)
Every developer has a home folder on the dev server with a virtual host set up to run their code. This folder is shared using Samba.
Zend Studio IDE that is set up to use that location (as a network drive) to work on projects
Remote debugging to be able to run applications on the dev server and be able to step through the code
So the main problem we are having is that everything is slow...
Zend is slow to index the project, as it has quite a bit of files (including externals like full framework) that need to be transferred through SMB.
Remote debugging is slow, as Zend studio needs to fetch the file, then send it back to the server to run it (running "Local if available, else server"; otherwise breakpoints don't work)
Tortoise SVN is slow to get file status for the commit (command line remedies the problem, but it's much less user friendly, especially with more complicated things like conflict resolution while merging)
Branching out to any of the solutions that would have multiple server configurations brings up a problem that there is a chance of having different configurations everywhere, which will introduce additional layer of uncertainty and possibly bugs in production.
Development and debugging under windows is not possible because of linux dependencies in the code (like POSIX functions).
So how do organizations solve these problems? What kinds of set up are you using? What kinds of problems are you facing, and how to you resolve them?
One solution that works in some situations is to :
Have the code on your local disk, on the physical computer running windows
This code is the one you're modifying with your IDE
So, IDE is working as fast as possible : no SMB access for each file.
Also have the code on the Linux server
So Apache runs fast : the code is present on the server
Use some kind of synchronisation mecanism, to push every modification made on a file on the Windows machine to the Linux server, via the SMB share.
Using Eclipse, the FileSync plugin does a good job, over the SMB share.
WinSCP can also be used, to keep a remote and local folder synchronized, over an SSH connexion
Advantages :
All local operations are fast
All server operations are fast
Drawbacks :
You must always use the tool that ensures synchronisation (For instance, with FileSync, everything must be done in Eclipse -- and nothing in any other software)
Note : for SVN, no need to use Tortoise : there are plugins that integrate into Eclipse (Subversive, for example)
Not sure about debugging
Modifications done directly on the Linux machine might not (depending on the solution) get synchronized to the windows desktop.
Still, the best (fastest and most powerful) solution is generally to use only one computer -- that would run Linux, in your case, and not Windows.
Your tools will most likely work under Linux
If needed, you can install Windows in a Virtual Machine, for some software that don't run on Linux
It'll encourage everyone in your team to know Linux better ; which is always useful, when your production environment is not Windows ;-)
I'd like to develop a PHP application that users would download and then could run. The application will have a web service.
I assume they will need Apache, but my main question is what is needed for PHP to run on their machine? Is there something needed like the JVM in Java or the .Net framework in .Net? What is it called and how difficult is it for them to download (size, etc.).
Is anything else required that I did not mention?
Thank you,
They will need a web server with a compatible version of php. That's it.
Are you asking what is required to run a .php file on a windows machine? Do you mean like an executable or a web server script?
If like an executable need the php files:
Download the php installer from http://windows.php.net/download/, and then you can run php.exe script.php
If like a web site:
You need a webserver (like apache) and the php.exe files. I would suggest if testing to download a prebuilt webserver like XAMPP (download from http://www.apachefriends.org/en/xampp-windows.html)
It depends on the application. At a minimum it will need PHP.
Is there something needed like the JVM in Java or the .Net framework in .Net? What is it called and how difficult is it for them to download (size, etc.).
PHP. Presumably as difficult as it is for you, but it depends on the platform. OS X comes with it. Most Linux variants either come with it, or allow it to be installed with one command to the package manager. Windows users will have to download it seperately.
As for other things that might be needed…
If it has a GUI, it might need PHP-GTK.
If it expects to be accessed via HTTP then they will need a webserver which supports PHP. This could be Apache, IIS, or one of numerous other servers.
(It isn't clear if, when you say "The application will have a web service.", you mean "The application will access a web service" or "The application will provide a web service". If the latter, then a web server will be needed).
If you use any non-core modules, then they will be needed as well.
You need to describe your proposed application a bit better. Is there a reason the application must be in PHP? It may be possible, but it's certainly not common to code and distribute a desktop application written in PHP.
There are a few options.
If you are just writing a script (command line, etc) you don't need a webserver. You just need PHP installed to run it (there are even downloadable installers for it).
If you are writing a web-based tool, then you will need your users to have a webserver if they are meant to run it on their physical machines. And you don't need a framework...
just think of it as a Webserver + PHP as a plugin. Some webserver options: Apache, nginx, lighttpd
Try having users install WAMP, MAMP, or Zend Server CE all of which are free and come with both a webserver and PHP.
If you really want a deployable PHP script/tool, maybe look into something like PHPDock, which gives your users a single installable app (embedded server, php). NuSphere PHPDock
Honestly, it's not the greatest language to use for this type of deployment, but it's certainly fun to try to figure out! Sorry for not linking out also, don't have enough rep points for all of the links I had intended to supply.
Actually you can run php script without the need to have a webserver installed.
Just install php and then from command line:
$ php myscript.php
If you really want you can even build GUI application with php even though I would not suggest it.
Cheers Andrea
you could also try to use quercus.
Quercus is Caucho Technology's fast,
open-source, 100% Java implementation
of the PHP language (requires JDK
1.5).
This way you only will need a jvm+quercus. It also is platform independent this way because it runs in the JVM.
We've built a php application that we need to host on a Windows Server 64 bit platform (due to another software being present that we need to access).
However, our php application has been built on a linux environment.
Is there anything we need to be watchful of when running apache and this php application on a Windows environment?
Mostly any PHP script is cross-platform and normally you don't care about platform, but there are some platform-specific things like absolute paths (C:/www | /var/www/) and shell commands. If you don't use them then it will work. If not, it will not take much time for fixing.
There may be some good reading here on the official PHP documentation on running PHP on Windows.