简体   繁体   English

Slim PHP出现405错误,同时将Backbone JS与MAMP一起使用

[英]405 Error From Slim PHP while using Backbone JS with MAMP

I'm new to backbonejs and slim but I'm diving right in. 我是没有什么新主意的人,但是我正在潜水。

my backbone code is fine, and it works when I use localstorage, but I want to use a mysql back end. 我的主干代码很好,当我使用localstorage时它可以工作,但是我想使用mysql后端。 I did some homework and found the SLIM framework. 我做了一些作业,发现了SLIM框架。 Looked pretty cool, RESTful, etc. I've seen that its been used a bunch with backbone. 看起来很酷,RESTful等。我已经看到它与骨干一起使用了。

backbone gets information from the file fine. 主干可以从文件中很好地获取信息。

When backbone requests my file with the PUT, I get: POST http://localhost:8888/lifeconsole/src/server/ 405 (Method Not Allowed). 当骨干网通过PUT请求我的文件时,我得到:POST http:// localhost:8888 / lifeconsole / src / server / 405(不允许使用方法)。

I've seen this question 我看过这个问题

I replaced the suggested section of SLIM code in the answers section. 我在答案部分替换了SLIM代码的建议部分。

I also modified my httpd.conf file to allow .htaccess files in local directories. 我还修改了httpd.conf文件,以允许本地目录中的.htaccess文件。 I ensured that I had the .htaccess file that ships with SLIM in the directory with my SLIM files. 我确保SLIM文件所在的目录中具有SLIM附带的.htaccess文件。 I've been doing a lot of reading about apache configuration and feel a little over my head. 我一直在阅读许多有关Apache配置的文章,并感到有些不解。 Any suggestions would be fantastic! 任何建议都太棒了!

I figured it out! 我想到了! I was confused about a basic feature of REST. 我对REST的基本功能感到困惑。 The PUT method is only used upon update. PUT方法仅在更新时使用。 I had written code for GET and PUT and I should have had something for POST. 我已经为GET和PUT编写了代码,而应该为POST编写了一些代码。 That being said, I'm pretty sure PUT doesn't work on many servers, and you need to flip on http://documentcloud.github.com/backbone/#Sync-emulateHTTP to make backbone work. 话虽这么说,我很确定PUT在许多服务器上都无法运行,并且您需要翻转http://documentcloud.github.com/backbone/#Sync-emulateHTTP来使骨干网正常工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM