問題描述
我先說我是一個蹩腳的程序員,我確信我想做的事情可以在 10 行 node 或 Rails 或其他東西中完成,但 PHP 是我可用的.
I'll preface this with saying that I'm a crappy programmer, I'm sure that what I want to do could be done in 10 lines of node or Rails or something else, but PHP is what I have available.
所以,我希望找到一個簡單的 PHP 庫,它將數據庫調用封裝在一個類似于 RESTful 模型的 API 中.
So, I'm hoping to find a simple PHP library which wraps the database calls in an API that looks similar to the RESTful model.
我在嘗試找到這樣的東西時收效甚微——搜索 PHP CRUD
或 PHP REST
會出現無數個頁面,我不知道如何過濾它們.
I've had little success trying to find such a thing -- searching for PHP CRUD
or PHP REST
turns up several zillion pages, and I've no idea how to filter through them.
我真的想在這里保持簡單,我不想要像 Zend 之類的大框架.我在 Backbone 中處理的模型非常簡單.我只想將 GET
s 發送到 /notes/3
或 POST
s 到 /notes
,等等,并讓 PHP 對數據庫做正確的事情.
I'm really trying to keep things simple here, I don't want a big framework like Zend or something. The models I'm dealing with in Backbone are really simple. I just want to send GET
s to, say, /notes/3
or POST
s to /notes
, etc, and have PHP do the right thing to a database.
也許我的要求太多了,但在我看來,這正是 Rails 等其他框架所提供的.有什么建議?TIA...
Perhaps I'm asking too much, but it seems to me that this is what other frameworks like Rails provide. Any suggestions? TIA...
推薦答案
EDIT Nov 2018: 雖然我不會敲 CodeIgniter,但現在 Laravel(目前是5.5)是我使用的框架.
EDIT Nov 2018: Although I wouldn't knock CodeIgniter, nowadays Laravel (currently 5.5) is the framework I use.
這是一篇好文章總結總結我使用 Laravel 的原因.
Here is a good article that sums up the reasons I use Laravel.
要快速入門,我建議使用 Laracasts.這是一個訂閱視頻教程服務,深入介紹如何使用 Laravel(以及其他與 Web 開發相關的內容).
To get jump started, I recommend Laracasts. It's a subscription video tutorial service that goes in depth on how to use Laravel (and other web dev related things).
原始答案:
Codeigniter 對我來說,是最簡單的類 Rails 框架.它很簡單,您可以輕松地從頭開始構建 CRUD 應用.
Codeigniter, to me, is the easiest of the Rails-like frameworks. It's bare bones, and you can build a CRUD app from scratch easily.
推出自己的應用的最大問題是安全性.Codeigniter 可以通過保護您免受許多常見的安全風險(例如直接使用 $_POST 數組,而不是正確過濾您的數據)來幫助您構建一個不易被黑客入侵的站點.更不用說它提供的許多幫助類,例如表單驗證.
The biggest issue with rolling your own app is security. Codeigniter can help you build a less hackable site by shielding you from many of the common security risks, such as using $_POST arrays directly, and not properly filtering your data. Not to mention the many helper classes it offers such as form validation.
您可以在他們的網站上查看文檔.只要您記住導航隱藏在每個頁面的頂部,它就非常易于使用.:D
You can view the documentation on their website. It's very easy to use as long as you remember the navigation is hidden at the top of each page. :D
這篇關于一個 RESTful 持久性解決方案,可用于 Backbone.js... 在 PHP 中?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!