Running php script without web Server
I was used 开发者_开发知识库eclipse as my ide and I have test.php. I want to run and debug that php script in eclipse. How I do it ?
You can run PHP scripts without a web server. PHP doesn't have anything to do with web servers.
You need to download PHP, of course. And then you can configure Eclipse to run your scripts in the command line. See
http://www.php.net/manual/en/features.commandline.usage.php
for command line usage of PHP
You can turn your computer into a webserver very easily with xampp.
http://www.apachefriends.org/en/xampp.html
So, you need to setup local webserver and run it.
for example Denwer (type you name and , mail for download) - this is build of appach server for local develop. (P.S. try to find there on your lang.) By default Denwer setups to the C:\WebServers\ And yor site should be in C:\WebServers\home\sitename.ru\www
Then you should run servise and type in browser smt like sitename.ru And Denwer setup MySql DB on you system
Microsoft Windows 7, Eclipse Mars.2 (4.5.2), PHP 7.0.4 (stand-alone install in C:\php), Eclipse PDT for PHP extension 3.7.0
Current Eclipse documentation is not clear, but newer PHP versions have the PHP -S option, to run a simple web server test environment. I succeeded with the following setup, and note this allows for a top-level/root URL to your project. Eclipse wants to use your Workspace folder as the web root, so if using subfolders in your URL is acceptable, then configuration is easier.
In Eclipse: 1. Run > External Tools Configuration Create a new Program. Location: C:\php\php.exe (your PHP installation) Working Directory: ${workspace_loc:/myproject} (your project folder) Arguments: -S localhost:8080 (change as desired) On the Common tab at the bottom, almost hidden, there is a "Launch in background" option that is checked by default. Unchecking this did not work for me, so remember that Eclipse will launch a PHP processes in the background, so check Windows Task Manager. Run this External Program to start the PHP web server.
In a web browser 2. Verify you can open your projects default page in a web browser. Example: http://localhost:8080/
In Eclipse 3. Run > Run Configurations Create new PHP Web Application. Name configuration, e.g. myproject-config. Create a new Server. Name server, e.g. myproject-server. Base URL: http://localhost:8000 (Match your PHP web server setting) Leave all other Server settings blank. Back on the Configuration, you must select a file, e.g. /index.php. URL: Uncheck Auto Generate URL: Make file name/path match above, and you can add parameters. Apply your changes.
- Test Now you can select Run, or in the PHP Explorer you can select your project or default file and click the Run toolbar button. Note that you will need separate Configurations for each PHP file.
Maybe not the easiest or greatest solution, but it allows you to stay in Eclipse.
精彩评论