PHP RESTful CRUD 框架

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/19586469/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 19:44:58  来源:igfitidea点击:

PHP RESTful CRUD framework

phprestframeworkscrudsails.js

提问by Dnns

I really like working with SailsJS (http://sailsjs.org). Especially because it automatically generates a RESTful CRUD API. However, working for small clients, I don't always have the opportunity of working in a NodeJS environment. Mostly their webapps run on an Apache (PHP/MySQL) server.

我真的很喜欢使用 SailsJS ( http://sailsjs.org)。特别是因为它会自动生成一个 RESTful CRUD API。然而,为小客户工作,我并不总是有机会在 NodeJS 环境中工作。大多数情况下,他们的 web 应用程序运行在 Apache (PHP/MySQL) 服务器上。

My question: Is there any framework that provides an automatically generated RESTful CRUD API? If not, what is the best approach to write it myself?

我的问题:是否有任何框架可以提供自动生成的 RESTful CRUD API?如果没有,自己编写的最佳方法是什么?

I'm aware of frameworks that handle routing, however I'm looking for something that automatically generates CRUD API (based on blueprints or linked to the database tables).

我知道处理路由的框架,但是我正在寻找自动生成 CRUD API(基于蓝图或链接到数据库表)的东西。

For speeding up the development process and keeping my code clean I also like ORM's. It would be nice if I could link the automatically generated API to the ORM schema/blueprint. So once again, what is the best way to approach this?

为了加快开发过程并保持我的代码干净,我也喜欢 ORM。如果我可以将自动生成的 API 链接到 ORM 模式/蓝图,那就太好了。那么再一次,解决这个问题的最佳方法是什么?

I couldn't find any frameworks that provide this. Hope you guys can help me out.

我找不到任何提供此功能的框架。希望大家能帮帮我。

Thanks in advance!

提前致谢!

Dennis

丹尼斯

回答by gabrielem

In some way the best and easy Php Framework for write API and RESTful application is

在某种程度上,用于编写 API 和 RESTful 应用程序的最佳和简单的 PHP 框架是

Slim Framework

超薄框架

Slim is a PHP micro framework that helps you quickly write simple yet powerful web applications and APIs. slimframework.com

Slim 是一个 PHP 微框架,可帮助您快速编写简单而强大的 Web 应用程序和 API。slimframework.com

hello world:

你好,世界:

<?php
$app = new \Slim\Slim();
$app->get('/hello/:name', function ($name) {
    echo "Hello, $name";
});
$app->run();

回答by Shahin Khani

This is a restful api framework that can get you started pretty fast http://luracast.com/products/restlerI've used it in the past. very fast and lean.

这是一个宁静的 api 框架,可以让您快速入门 http://luracast.com/products/restler我过去使用过它。非常快速和精益。

however developing APIs is fairly easy. some other light frameworks are Slim Php.

但是开发 API 相当容易。其他一些轻量级框架是 Slim Php。

Zend is really heavy.. but you can pretty much extend their zend Rest class and write your own which will be the "easiest".

Zend 真的很重......但是你几乎可以扩展他们的 Zend Rest 类并编写你自己的,这将是“最简单的”。

回答by user138720

If you don't know PHP Take a look at http://davss.com/tech/php-rest-api-frameworks/If you want to learn PHP and write your own, you have a long way to go from JS, but if you're ambitious, read Matt Zandstra - Objects Patterns and Practice, and have a look at PEAR.

如果你不懂 PHP 看看 http://davss.com/tech/php-rest-api-frameworks/如果你想学 PHP 自己写,离 JS 还有很长的路要走,但如果您有雄心,请阅读 Matt Zandstra - Objects Patterns and Practice,并查看 PEAR。

回答by Ant

I did wrote a little script that uses Propel ORM + SLIM.

我确实写了一个使用 Propel ORM + SLIM 的小脚本。

It is based on AngularJS (For the javascript side).

它基于 AngularJS(对于 javascript 端)。

You can adapt it for your needs. If you know well PHP, you might find the code ugly.

您可以根据自己的需要进行调整。如果您非常了解 PHP,您可能会发现代码很难看。

https://github.com/a-lucas/angjs-propel-slim

https://github.com/a-lucas/angjs-propel-slim

回答by BillyBigPotatoes

Take a look at Symfony2 - it is a great framework that has many helpers / generators for what you describe.

看看 Symfony2 - 它是一个很棒的框架,它有许多帮助器/生成器来满足您的描述。

http://symfony.com/

http://symfony.com/

It is also a microframework - so you can take components and factor them into your own framework if you go that route.

它也是一个微框架——所以如果你走那条路,你可以将组件纳入你自己的框架中。

If it is too heavyweight for your needs then Silex - built using symfony components may also be of interest

如果它对您的需求来说太重了,那么 Silex - 使用 symfony 组件构建也可能会感兴趣

http://silex.sensiolabs.org/

http://silex.sensiolabs.org/

回答by user2818265

Here is a poll in sidebar http://davss.com/tech/php-rest-api-frameworks. I confirm that SLIM is very nice and simple

这是侧边栏中的投票http://davss.com/tech/php-rest-api-frameworks。我确认 SLIM 非常好而且简单