It ought to be so simple. I have adopted every tutorial and forum I possibly could find, yet I can not get results. I only desire to develop a Peaceful API in PHP on Apache2.

During my VirtualHost directive I only say:

<Directory />
    AllowOverride All
    <Limit GET HEAD POST PUT DELETE OPTIONS>
        Order Allow,Deny
        Allow from all
    </Limit>
</Directory>

Yet every PUT request I make towards the server, I recieve 405 method not supported.

Someone recommended while using Script directive, consider I personally use mod_php, instead of CGI, I do not understand why that will work.

People mention using WebDAV, but in my experience that appears like overkill. In the end, I do not need DAV securing, a DAV filesystem, etc. All I wish to do is pass the request onto a PHP script and take care of everything myself. I simply want to enable PUT and Remove for that clean semantics.

Thanks,

Andreas

You don't have to configure anything. Just make certain the demands map for your PHP file and employ demands with path info. For instance, for those who have within the root personal files named handler.php with this particular content:

<?php

var_dump($_SERVER['REQUEST_METHOD']);
var_dump($_SERVER['REQUEST_URI']);
var_dump($_SERVER['PATH_INFO']);

if (($stream = fopen('php://input', "r")) !== FALSE)
    var_dump(stream_get_contents($stream));

The next HTTP request works:

Established connection with 127.0.0.1 on port 81
PUT /handler.php/bla/foo HTTP/1.1
Host: localhost:81
Content-length: 5
 
boo
HTTP/1.1 200 OK
Date: Sat, 29 May 2010 16:00:20 GMT
Server: Apache/2.2.13 (Win32) PHP/5.3.0
X-Powered-By: PHP/5.3.0
Content-Length: 89
Content-Type: text/html
 
string(3) "PUT"
string(20) "/handler.php/bla/foo"
string(8) "/bla/foo"
string(5) "boo
"
Connection closed remotely.

You are able to hide the "php" extension with MultiViews or make Web addresses completely logical with mod_rewrite.

See even the documentation for that AcceptPathInfo directive which question regarding how to make PHP not parse POST data when enctype is [cde].

The technical restrictions with using PUT and Remove demands doesn't lie with PHP or Apache2 it's rather around the burden from the browser to sent individuals kinds of demands.

Simply putting <form action="" method="PUT"> won't work because you will find no browsers that support that method (and they'd simply default to obtain, dealing with PUT just like it might treat gibberish like FDSFGS). Sadly individuals HTTP verbs are restricted towards the arena of non-desktop application browsers (ie: web service customers).

On linux, /etc/apache2/mods-enabled/php5.conf dans php5.load is available. Otherwise, allows this modules (may need to sudo apt-get install libapache2-mod-php5).