I'm making a Laravel 5.8 API (PHP 7.3.6) and the GET, POST and DELETE functions are all acting normally but I cannot get the PUT to behave as it should. When I use Postman and do a PUT request to "sites" it behaves like a GET request. The GET, POST and DELETE methods behave as I'd expect, i.e. go to the correct routes.
It was behaving like this on IIS but now I am using Docker with Apache and PHP 7.3.6 and it has the same behaviour.
It feels like it must be to do with Laravel, or maybe I am just using Postman wrong. Any ideas?
This is my api.php...
Route::get('sites', 'SelectSites@index');
Route::get('sites/{id}', 'SelectSites@show');
Route::put('sites', 'SelectSites@create');
Route::post('sites/{id}', 'SelectSites@update');
Route::delete('sites/{id}', 'SelectSites@delete');
This is the create method...
public function create(){
$sites = "CREATE";
return $sites;
}
This is the docker-compose.xml...
version: '3'
services:
app:
build:
context: .
dockerfile: .docker/Dockerfile
image: laravel-docker
ports:
- 8086:80
This is the VirtualHost file...
<VirtualHost *:80>
DocumentRoot /srv/app/public
<Directory "/srv/app/public">
AllowOverride all
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<Limit GET POST PUT DELETE>
Order allow,deny Allow from all
</Limit>
</VirtualHost>
UPDATE
This is working locally in IIS, I just had to restart my local machine. It also works perfectly in the PHP webserver php -S 0.0.0.0:8080
. I have never used PUT before, is there something I need to do to configure Docker to use PUT?