I'm using the PHP Slim Framework for my RESTful project.
I was wondering if its possible to get a list of all the callback registered with Slim somehow so as to have a list of all the REST resources that are available for the app?
I assume this will involve some sort of pre-compile but I'm not sure how to do it.
I haven't used the Slim Framework yet (looks quite exciting, thanks for the pointer), but my best guess would be using PHPDocumentor to generate documentation about your rest endpoints.
You can find it at the phpdocumentor website
Related
I'm using some open source code to launch a game. The game is old, around 11yrs. It is a tick based web based game. It's written in php and using MySQL. Basically I want to port this game to ios, instead of using uiwebview I want to build native controls.
I know that it's bad practice to communicate directly with MySQL from an ios app. So what I want to do is add a RESTful API. I'm new to this and have scoured google for answers, does anyone have any pointers of where to start when adding an API to an existing site? It's quite a complex structure.
Thanks.
Paul.
My suggestion is using a framework that is guided towards building an API. I use Slim Framework for my API back end and it's pretty easy to use. If you create a separate URL for this API or include directly into the PHP project as a class it could work.
Some tutorials to get you started are
Say Hello World with Slim
RESTful services with jQuery, PHP and the Slim Framework
Writing a RESTful Web Service with Slim
Hope this helps,
Wes
I want to build an app using ExtJS 4 and PHP.
I will follow the MVC pattern with ExtJS 4.
However, I want to use RESTful webservices with PHP.
Yet I am not sure how to proceed.
How can I call for Web Services that are PHP functions?
How am I going to give the directory like structure to my links?
You can obviously use Ext.Ajax.request() to craft any RESTful URls that you want. However, be sure to check out the REST proxy that's built into Ext JS's data package. By connecting this to your store/model, you can dynamically generate RESTful URLs which can be used for the vast majority of your generic CRUD operations.
RE: the PHP side, that's a big question. Fortunately, there are literally a billion turtorials on creating RESTful services in PHP, so I'd dust off your Google-fu and start there. Here's a very simple introduction that just happens to use PHP: http://code.tutsplus.com/tutorials/a-beginners-guide-to-http-and-rest--net-16340
You are most likely looking for Ext.Ajax.request.
There are some examples of Ext.Ajax.request from this stack overflow article.
I created a RESTful API in Zend Framework 2.1 but I still don't know what is the best approach to make versioning for this API. I also use the doctrine as a model part of my app. I'd like to have links like that:
api.name-of-my-project.com/v1/products
api.name-of-my-project.com/v1/products/123
where v1 describes the version of API.
So far I already created API without versioning and I also have some ideas about how to create versioning but first I'd like to know your opinions about this problem. What should I do to separate controllers and maybe other classes from different versions and how to manage the routing? By the way I think that I am not really interested about creating another module because I already have module like API.
The final app should be able to work with "many" versions of API. I'd like to also inherit some functionality from older version of API in my new one.
You can do this with zf2 routing array in your module config
Map routes with v1 to versiononecontroller and v2 to versiontwocontroller
I have never used a PHP framework before and am considering using Symfony for my next one. However, I have already built an API which has all my main classes. I will therefore connect to this API using CURL. Can anyone advise on where to start with such a project. I am working through a Symfony tutorial but none of it seems to apply to what I need to do as I do not need to create database connections or classes as I will be building this project on my existing API.
If you don't need a lot of what you see in the Symfony tutorials you might be able to get away with Silex. Silex is a mini-framework with alot of the core aspects of Symfony, but without the extra stuff.
http://silex.sensiolabs.org/
We are looking to build a PHP web application to manage data that is available only through a 3rd party REST like interface.
We would like to use an existing PHP framework to do this, we're considering cakephp and codeigniter, but are open to other options.
We expect the biggest problem will be creating models that utilise the REST API as a data source instead of a local database.
I've written a base ReST datasource plugin for CakePHP and am using it in lots of other plugins that interact with ReSTful APIs. Plugins I've released so far are YahooGeoPlanet and bit.ly and I'm also currently working on ones for Google Apis (YouTube and Analytics), Twitter, Twitpic and Facebook. They use the CakePHP's excellent HttpSocket class that deceze mentions.
Have a look at those CakePHP plugins and you should be able to see how simple but powerful they are.
You might look at Zend_Rest_Client, which I've never used, but appears worth a look.
Failing that, Zend_Http_Client is pretty solid for abstracting away all the curl ugliness.
Either one can be used independently of the rest of the Zend Framework stuff, and should interoperate just fine with other frameworks.
You can implement it as a Datasource in Cake, which to the Model and therefore to the rest of the application behaves exactly as a database would. Internally the Datasource can dynamically fetch the data using cURL or the Cake HttpSocket. Have a look at the Twitter API example.