我正在制作 Laravel 5.8 API (PHP 7.3.6),GET、POST 和 DELETE 函数都正常运行,但我无法让 PUT 正常运行。当我使用Postman并向“站点”发出 PUT 请求时,它的行为类似于 GET 请求。GET、POST 和 DELETE 方法的行为与我预期的一样,即转到正确的路线。
它在 IIS 上表现得像这样,但现在我将 Docker 与 Apache 和 PHP 7.3.6 一起使用,它具有相同的行为。
感觉一定和 Laravel 有关系,或者我只是用错了 Postman。有任何想法吗?
这是我的 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');
这是创建方法...
public function create(){
$sites = "CREATE";
return $sites;
}
这是 docker-compose.xml ......
version: '3'
services:
app:
build:
context: .
dockerfile: .docker/Dockerfile
image: laravel-docker
ports:
- 8086:80
这是虚拟主机文件...
<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>
更新
这在 IIS 中本地工作,我只需要重新启动本地计算机。它也可以在 PHP 网络服务器中完美运行php -S 0.0.0.0:8080
。我以前从未使用过 PUT,我需要做些什么来配置 Docker 以使用 PUT?