I'm trying to write a RESTful API for my Android app. I am trying to write the server in PHP, and I'm trying to host it on a WAMP server. I want to be able to GET, PULL, PUT,
and DELETE
. In class, our professor showed us an example of how he configured his server, but he used MAMP (for Macintosh), which seems to have a different file hierarchy than WAMP. He showed us that our index.php
server file goes into this folder, and I'll use an api
folder for the example:
MAMP -> htdocs -> api -> index
When I access the URL localhost:8080/api/
, it should execute a particular GET
request.
He also noted that we needed to enable aliasing
. So in the MAMP -> conf -> httpd.conf
, we added Alias /quotes "/Applications/MAMP/htdocs/api/index.php"
.
But, I'm unable to get this work with my WAMP server. I noticed that it is a bit different in file heirarchy. To access the htdocs
and conf
folder I have to do the following:
WAMP->bin->apache->Apache2.4.4->htdocs
WAMP->bin->apache->Apache2.4.4->conf
and I modified my conf
file as such: Alias /quotes "/WAMP/bin/apache/Apache2.4.4/htdocs/api/index.php"
So do I configure the WAMP differently? Do I need to move the conf
and htdocs
folders into the root WAMP
folder? I tried putting my api into the WAMP->www
directory, but it wouldn't work for the following GET
request.
//GET /api/2 Gets someone based on primary key
I tried looking at many tutorials, and I found many that were great in explaining API's and how to code an API that handles requests, but I was unable to find one that shows how to configure the server and get that working.
Any help, explanations, links to resources would be helpful and very appreciated. Thank you
I found the solution:
I needed to put my api
folder in the c:/wamp/www
folder.
My httpd.conf
was in the right spot. (/bin/apache/Apache2.4.4/conf
), but my line for aliasing was incorrect, it should have been:
Alias /quotes "c:/wamp/www/api/index.php"
The URL i needed to navigate was:
http://localhost:8080/quotes
(Because I aliased it.)
And of course, I needed to restart my WAMP server once I modified the httpd.conf
file.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments