开发者

Using Node as REST server alongside PHP [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
开发者_如何学JAVA

Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.

Closed 8 years ago.

Improve this question

I've got a functional site running right now in PHP on apache; PHP and apache are serving the needs of serving the site content quite nicely. I'm looking to convert my existing PHP API server code to a RESTful interface; most of the design issues are worked out on that front. PHP doesn't seem like a good fit for a RESTful interface, though; enter Node.js.

I'd like to run my REST API from a node.js server, while still serving my site content from PHP. Is this a reasonable approach, and are there any potential troubles waiting in the wings? I'm planning on using express to simplify the process of REST API development.


PHP with Apache is enough to serve a proper RESTful interface. Being able to divide all your operations into proper resources and verbs is what REST needs. As REST is a way of designing an interface and now about the actual implementation, there are multiple ways of implementing it in PHP/Apache itself. I have used the Zend Framework for big APIs. For something super simple, a .htaccess with a PHP file should be good. :)

That said, I believe Node.js would give your API a nice performance advantage just after installing it. The actual numbers would depend upon how your backend works.

IMO, if you already have a lot of code in PHP and are not facing any performance issues, you can stick to the PHP+Apache combo than try out node.js.


You can try Zend framework. It will simplify your RESTful API development.


Proxying Node.js through Apache misses a lot of the point of Node.js (no thread per connection)

Proxying Apache through Node.js puts Node.js on the front, and while there are no known security flaws, Node.js simply isn't as battle hardened.

Enter nginx. You can either proxy both through ngnix or replace Apache with nginx.

Other than the need for a proxy I don't see any trouble in the wings.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜