I know this is a newbie question, but i want to study php. i have phpeclipse and its running well, the problem is when i run a simple html file with the default server the page says cant display this page and thats it. i dont know if i need to install a new server or is there something wrong with the server configurations. ive tried installing tomcat on my computer but i cant see it under windows->preferences->server->runtime enviroments->add. iv also tried under the same page to fetch geronimo v2.2 and 3.0 and the dependencies were wernt satisfied. iv also tried the repository for zend debugger. what do i need to do in order to compile and see php and html pages with php eclipse?
You don't need to compile PHP.
Depending on your operating system and PHP version there are a few options.
As of PHP 5.4+ you can run your application using PHP's built in server, on the command line, if you cd into your website root directory (i.e. where the index file is) and then run the following
php -S localhost:8989
Then if you navigate to http://localhost:8989 in your browser you should see your application.
If you are unable to run the inbuilt web server, you need to look at Apache2. Most PHP websites run inside the Apache 2 web server. You will generally need a *AMP (WAMP/LAMP) environment.
L/W (Linux / Windows)
A pache (Web server)
M ySQL (Database)
P HP
Hope this is enough of a pointer ;)
Related
I am figuring out how to use PHP OpenId
I have cloned the repo to the ~/www directory. There are some examples in the php-open-id/examples directory which I wanted to run.
Specifically, I wanted to render the page php-open-id/examples/consumer/index.php in order to better understand the API. I started a server in the php-open-id/examples directory using
python -m SimpleHTTPServer 8000
and I navigated to localhost://consumer/index.php
But it didn't work. It shows a dialog box to save the file. What is the correct way to render this PHP file?
I have found a solution :
Run the server using
php -S localhost:9000
Mac OS
Just Visit your project folder
open terminal on that folder
and Run php -S localhost:9000
then you can see
PHP 7.3.24-(to be removed in future macOS) Development Server started at Tue Mar 30 11:58:49 2021
Listening on http://localhost:9000
After that you are able to access your application on http://localhost:9000
if your port is not available try to change port
You need to have a php server for serving .php files. The simple python server is not a php server and therefore it is just simply listing the files in the directory for download.
If you are on OSX 10 or above, it comes with apache which has php module present and can be setup to serve php file.
Tutorials can be found here
http://php.net/manual/en/install.macosx.bundled.php and here https://discussions.apple.com/docs/DOC-3083
If you would like to setup a dedicated server instead of using apache, MAMP is a good solution. Google It and see tutorials on how to set it up.
Update November 2022:
Unfortunately, PHP has been removed from MacOS. This is a brief tutorial which explains how to get PHP working in Ventura.
I personally dislike the idea to compensate the lack of PHP with the activities outlined in the tutorial. My solution was to install Docker and to run a proper NGINX+PHP container. I consider it to be cleaner, more flexible and better to maintain rather than faffing about with half-baked on-board stuff. But that's a matter of taste, I guess.
Also, as suggested in one of the answers, using the Python approach is not hassle free in Ventura, since it requires xcode to be installed.
In MacOS 10.x I have also been working with the on-board Python and PHP. Having lost those tools as standard installations is annoying.
I'm looking for something like http://phpfiddle.org/, but completely local. I don't want to commit to installing something as complex as Apache, then PHP on top of that, just to try out code when I'm offline. Is there anything that can run PHP 5.5 on the local machine without installing an entire server underneath it?
There's no need for a server if using PHP 5.5+ - it has a built-in server (http://www.php.net/manual/en/features.commandline.webserver.php)
Just use:
$ cd ~/public_html
$ php -S localhost:8000
As a minimalistic solution, on the command line you can also start php in interactive shell with php -a that will execute the commands you enter line by line. I often use it for testing small snippets of code.
You can download a portable webserver http://www.usbwebserver.net/en/ and use this script under it https://github.com/websiteduck/Run-PHP-Code
You can install either XAMPP or WAMP server locally if you find it complicated to configure PHP for Apache.
You should try phpsh as well. It is a php interactive shell from the facebook developer folks with history, tab completion and quick access to documentation.
The project is maintained on github.
Use psysh which is a wonderful tool for the purpose you described.
If your project is on Laravel, then it's "built in", as tinker, so you can invoke it as php artisan tinker.
I really dont think so. but it isnt so complex as you think.
if you are on windows - just download: http://www.wampserver.com/ - it will install the whole server for you (mysql&phpmyadmin,php5).
on linux - got to google: install lamp to [your-linux] -- and follow the simple instructions
For Windows Users:
Check out the ezPHP GitHub project. Per the project description...
EzPHP is an alternative to Xamp/Wamp. EzPHP is the easiest way to setup a PHP development environment for learning PHP programming on Windows.
The scope of this project is to provide a single .exe file that will get you a PHP developing server.
Link - https://github.com/marcomilon/ezphp
Setting it up was simple. Download the exphp.exe file and drop it in a folder. When you run the exe, it will launch the server and generate a public_html folder and index.php file. Follow the instructions in the command window and navigate to http://localhost:8080. Now you can start developing in the public_html folder and refresh your browser to see your changes.
This is what I do for simple pages:
Download php in zip and extract (PHP 8.0.2 ~25MB)
Then run
> php.exe path\to\your\index.php>path\to\the\output\index.html
Open the result index.html with your favorite browser
You have to find a workaround for your _GETs though.
If you use a development environment, like Aptana Studio, you might as well click on the Run As, and run it in your preferred browser. You need WAMP/XAMPP to be installed and running in order to do so.
I am using OpenGeo package on windows to develop a web mapping application with sdk suite. I would like to create a submit form dialog box with a php script, which saves the data to the database. However, the problem is that it doesn't read 'submit.php' by Jetty server. When I check in firefox, the response shows the whole script only as belown. First, I tested with echo to return true. The created application was debugging on localhost at port 9080 while actual one is localhost:8060 which hosts Opengeo.
I have tried with Php/Java bridge also, however, it is still the same. It works on local host at port 8060/JavaBridge/ and shows the examples. I would really appreciate if you could suggest a way to configure Jetty with php in Opengeo package.
Cheers,
Zar Chi
We finally solved the problem by working with Ubuntu 12.04LTS and we wanted to share the solution in case is useful for someone else.
1- We installed opengeo following this process: link://suite.opengeo.org/docs/latest/installation/ubuntu/install.html
2-Then we found this blog: http://www.thomasknierim.com/140/java/
3- And we installed the apache using the fcgi option applying the configuration suggested in these files:
a) link: 2bits.com/articles/apache-fcgid-acceptable-performance-and-better-resource-utilization.html. It was also similar in these other blogs so I went ahead.
b) link: howtoforge.com/using-php5-fpm-with-apache2-on-ubuntu-12.04-lts
c) link: versatilewebsolutions.com/blog/2012/11/installing-apache-2-with-php-fastcgi-on-ubuntu-12-10.html
4- We followed the instructions here (link: /php-java-bridge.sourceforge.net/pjb/download.php):
Use a graphical packet installer to install PHP. Or download JavaBridge.war, which contains an embedded PHP binary. (I suggest you try again with PHP standalone directly, NOT with JavaBridge.war file)
Download and install Java 6 or above. (/usr/lib/jvm/java-6-openjdk)
Download and install the original tomcat servlet engine. (/var/lib/tomcat6)
There must be JavaBridge.jar, php-servlet.jar and php-script.jar files in your /usr/share/tomcat6/lib
Double-check again /var/lib/tomcat6/conf/web.xml
Retart Tomcat server and check it is working now?
5- If not, the problem could be related with the permissions of the jar.libraries. There should be accessed by tomcat6:tomcat6. Every deployment called these libraries to automatically create a Java folder which contains Java.inc and JavaProxy.php.
I installed a plugin for NB 7.0.1 which enabled CodeIgniter but when I went to create a project using it, I was told I need to specify a PHP interpreter for Netbeans. I tried to do this using the php.exe you get with Xampp but I get a Java null pointer error. I can't seem to fix this but I'm thinking, why do I need an interpreter on Windows when the Linux machine can do that? I have already set this up on the VM.
Any advice from here? Thanks a lot!
I am using NB 7.1.1 and had similar issue with CodeIgniter plugin when creating a new project. NetBeans would complain No PHP Interpreter was defined in Tools->Options->PHP General. It would not enable finish button so a New Project could not be setup.
I just created a dummy batch file called nb_cli.bat and pointed NB to that for the PHP interpreter. I don't plan on executing (or debugging) CodeIgniter CLI code on local machine so that file will likely never get executed.
If you want to debug or run php locally, make sure xammp works OK outside of NetBeans. But if not, this fix should get you by the NetBeans issues.
I have a separate linux server on my local network for development as I don't need apache/php locally when I use multiple machines for dev/testing/etc.
NetBeans should bugfix that by downing that PHP Interpreter message from an Alert preventing project setup to a warning that No PHP interpreter is defined (or found) so CLI testing may not function.
As an alternative, if you have a linux box with NB installed, you can create the New project there and copy the whole folder (including the nbproject folder) to your PC and you should be able to get by having No PHP Interpreter defined.
Hopefully that gets you going with NB and CodeIgniter. If you need additional details, just ask.
I am very new to Web development and wanted to run one of the Github project (https://github.com/remy/html5demos) on my Mac.
I have downloaded the project on my Mac and puzzled how to run it. Need help from all talented people across Stackoverflow.
The demo using php. Unfortunately, the apache installed on OSX (assuming you're on Snow Leopard) has not have php enabled by default and you need some admin-editing to enable it.
So, first move the unpacked folder remy_something into /Library/WebServer/Documents and rename it to easy name, for example "remy". (The final path /Library/WebServer/Documents/remy)
enable Web sharing in System preferences
point your browser to http://localhost/remy/index.php
if you get an rendered page - you're done, and can start playing...
if you get an error - something is terrible ;(
if you get a page where is the 1st line <?php - you're on good way - you need enable php.
For enabling php in OSX's apache, you should read for example: http://www.perfectline.ee/blog/how-to-setup-apache-and-php-on-mac-os-x-snow-leopard or any other guide you can find.
after enabling php and restarting apache (disable/enable Web sharing), you can check again the page...