dpz7935 2012-03-17 20:45
浏览 97
已采纳

创建API(使用PHP)[关闭]

I been having this idea spooking around in my head for 2 weeks now. I’ve finally created some cases and plans on where I want to go with this project. I will have to create both a web application (ASP.NET) and a desktop application (Java). Both these applications will need to have sync’d databases.

I’ve been thinking about creating a public API over my database so my front-end and 3rd parties could communicate to the database. But I’ve never really attempted something like this before. I’ve spend my weekend so far on reading up on how I could approach this and I’ve gotten a pretty good idea. I’m having some questions/doubts currently and was hoping perhaps someone could help me.

1) I’m currently still in university and I don’t have a job so my pockets don’t go very deep. I’ve been thinking of writing the API in PHP, I already have possession of an unmetered hosting account and else I would be forced to buy .NET hosting which can turn out to be quite expensive. However my PHP knowledge is quite limited towards parsing user input/security. Would it be wise to search for an (e)book around this topic or would I be fine with online tutorials, do you have any suggestions on where to look? Should I put my time in writing a possible vulnerable PHP API or should I look at other options?

2) So far I’ve never really had the need to look into PHP libraries. I was wondering if I should look into some of these (for example cakePHP) to help me develop the API.

3) I’ve experience with implementing Twitter/Linkedin their API’s so I’ve been thinking to use OAuth (v2) to allow people to use my API. Is implementing OAuth to your API a lot of work? Is it well documented enough for someone with only basic PHP knowledge? If you ever used it on your API, what was your experience with it?

4) If this project would ever kick off, it would be wise to look into hosting It in the cloud. Do I currently need to think about something so future cloud integration is possible?

5) For the web application, would there be a (big) performance difference between using the API or directly connecting to the database?

6) Any recommended lecture or tips are welcome. It’s the first time I will be attempting something this big (both in functionalities & required knowledge).

  • 写回答

1条回答 默认 最新

  • drh96824 2012-03-17 21:11
    关注

    1) Developing a simple API is not that hard with PHP if you have some experience in other languages. Ofcourse, every language has its own way, and when it comes to optimization and stuff like that, you may need some more PHP knowledge.

    2) Using a PHP framework would definitely help with the lots of aspects. I use symfony 2 for all my PHP projects. I really suggest checking it. It's a decoupled framework, and you can use individual components from the framework. It's lightweight and fast, and offers great tools to build what you want. What is symfony? explains the benefits. Also, using ORM (I prefer Doctrine) is an option, but this is a whole another topic.

    3) If you decide to use symfony2, there are bundles (libraries) for it that you can use. It shouldn't be too hard to implement even without a framework, but I don't have any experience in that area.

    4) I don't have any experience in cloud, so can't comment on that.

    5) There will be a performance difference as you are adding another layer to your project, but whether it will be a big or small depends on the API, database etc. But, using an API will mean a standard way to communicate with the database, so even with the performance difference, it might be beneficial in terms of consistency and development time(you won't have to deal with different platforms to do database stuff.).

    6) The usefulness of the API greatly depends on the application and I can't really say if it outweighs the costs without specific information about the project. But having a standardized way to communicate with the data storage is generally a good idea when dealing with multiple platforms and languages IMO. As I don't know how much do you know about PHP, I can't comment on if it will be worth your time. I would go for it if there is enough time, as learning about PHP would add some more tools in your arsenal and this will be a good opportunity to improve yourself as a developer.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 如何用stata画出文献中常见的安慰剂检验图
  • ¥15 c语言链表结构体数据插入
  • ¥40 使用MATLAB解答线性代数问题
  • ¥15 COCOS的问题COCOS的问题
  • ¥15 FPGA-SRIO初始化失败
  • ¥15 MapReduce实现倒排索引失败
  • ¥15 ZABBIX6.0L连接数据库报错,如何解决?(操作系统-centos)
  • ¥15 找一位技术过硬的游戏pj程序员
  • ¥15 matlab生成电测深三层曲线模型代码
  • ¥50 随机森林与房贷信用风险模型