Examples of building a REST API server using Zend Framework? - php

I'm new to Zend Framework (not to PHP), and I need to create a REST based API using Zend.
I've seen examples using Zend_Rest_Server, however other sources state that that has been deprecated.
I'm unable to find a solid example which shows how I should be building such an API.

Zend_Rest_Server is indeed deprecated since ZF 1.9, you should use Zend_Rest_Controller instead. The following blog posts could be helpful : Building RESTful Services with Zend Framework and Create RESTful Applications Using The Zend Framework.

May be this link would be helpful: Creating a PHP REST API Using the Zend Framework.
This code example support REST data in the format of XML and JSON.
Prerequisites:
PHP version > 5
Zend Framework 1.9.2 (at the minimum)

If you want something a little more in details, you can check the book
Zend Framework 2 Application Development.
The book explains construction of API oriented system in ZF2, through examples.
At the end of book you get:
ZF2 API
ZF2 Client side app.
The book has a lot of syntax errors as well as any book for programming,
but it's only one on the market at this moment.

Related

Implementing a rest api using zf3

I want to build a new REST API for my application on the base of zend framework 3. Because I'm very new in zend two things are a bit misunderstanding for me: I know there's a component named zf-rest and I also know how to include it via composer. But how does zf-rest "knows" that I want to work with ZF3?
And then I found some sample applications using zf-rest and some only using zend-mvc. So I guess that zend already has a rest implementation. What are the differences between zf-rest and zend-mvc and in which situations should I use which framework?

How to add Zend REST API to an existing Concrete5 site?

I was tasked with developing a REST API using zend framework 2 for a web site created with concrete5 cms. I am very new php and have no idea where to start.
Specifically, my question is about installation and routing. How can I install zend framework on my existing concrete5 project. After that, what should I do to route REST requests to Zend controllers.
Thanks
Have a look at Apigility. This is a Zend solution for the use case you suggest (publishing existing code as an API).
https://apigility.org

Getting a list of REST resources from Slim

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

Getting started with Doctrine for Zend

I'm trying to get started with Doctrine for Zend. There doesn't seem to be a lot out there to help me with this. I find the website and documentation a bit useless.
I'm currently looking at this webpage.
There are a few options. I can checkout from subversion or github. Install via PEAR. or download a package.
What should I be doing with the lines of code in the black boxes?
What do I do with a package once I've extracted it?
As an aside
Am I a little out of my depth? Is there anything I should be learning before I start tackling Doctrine?
You really should have a look at the Zend Framework webinars, and more specifically the one called Zend Framework v1 + Doctrine v2. It's got detailed instructions and links to GitHub where you can download the source presented in the webinar.
The presentation slides can be found at http://static.zend.com/topics/Zend-Framework-1-+-Doctrine-2.pdf.
Presentation summary :
Zend Framework (version 1) is an
enterprise grade, full stack MVC
framework and component library.
Doctrine (version 2) is an enterprise
grade, ORM (object-relational mapping)
framework for PHP 5.3. In this
webinar, the ZF and Doctrine teams
join forces to demonstrate how best to
integrate these two frameworks and
produce a ZF powered MVC application
where in which the "M" is powered by
Doctrine2. Familiarity of PHP 5.3
features is suggested. Presenter –
Ralph Schindler, Jonathan Wage and
Guilherme Blanco (87min) Dec 15 2010
You will have to register with Zend though (but that's free, so shouldn't pose any problems I guess).
Actually, there are some resources you could use to integrate Zend Framework and Doctrine. In example, you could follow this screencasts:
ZendCasts - Doctrine
I've followed these screencasts, with a few corrections, and I was able to use Doctrine 1.x with Zend Framework applications. You can also view the generated screencasts' code; this option is available in the most of these screen casts.
You will want to use Doctrine 2, not version 1.2. The two are not compatible. Here is a presentation that explains why:
http://www.slideshare.net/ralphschindler/zend-framework-1-doctrine-2-6177485
Here are example sources for Zend Framework + Doctrine 2 integration:
https://github.com/fierycode/ZendFramework1-Doctrine2
https://github.com/marsbomber/zf1-doctrine2/tree/modular_setup (with modules)
I have already pointed someone in the right direction to integrate Doctrine 1.2 into ZF, my post can be found here.
I hope this helps you out.

Create custom oAuth Server With Zend

is it possible to create a custom oAuth server with the Zend Framework Zend_Oauth? For example i want to create a REST service and have oAuth authentication? Does the zend framework have support for this out of the box?>
Currently, there is no working OAuth server/auth adapter. There are a few of us (including myself) working to meld the existing Zend_Oauth into a Zend_Auth_Adapter.
Find me on twitter #onyxraven and we can discuss. I should have an idea of what needs done before the end of the week.
Have you taken a look at http://oauth.net/code/ ?
There is a community contribution:
http://framework.zend.com/svn/framework/standard/incubator/library/Zend/Oauth/Server.php

Categories