<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Joey Rivera &#187; rest</title>
	<atom:link href="http://www.joeyrivera.com/tag/rest/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.joeyrivera.com</link>
	<description>Blogging about PHP, Actionscript, MySQL, and other interests.</description>
	<lastBuildDate>Wed, 04 Aug 2010 14:52:07 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>AMF,XMLRPC,JSON,REST Zend Web Services Tutorial</title>
		<link>http://www.joeyrivera.com/2009/amfxmlrpcjsonrest-zend-web-services-tutorial/</link>
		<comments>http://www.joeyrivera.com/2009/amfxmlrpcjsonrest-zend-web-services-tutorial/#comments</comments>
		<pubDate>Thu, 26 Mar 2009 20:17:07 +0000</pubDate>
		<dc:creator>Joey</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[amf]]></category>
		<category><![CDATA[framework]]></category>
		<category><![CDATA[json]]></category>
		<category><![CDATA[rest]]></category>
		<category><![CDATA[web services]]></category>
		<category><![CDATA[xmlrpc]]></category>
		<category><![CDATA[zend]]></category>

		<guid isPermaLink="false">http://www.joeyrivera.com/?p=356</guid>
		<description><![CDATA[I&#8217;ve been using the Zend for the last few months and I&#8217;m loving it. Here at work we were having a discussion about implementing some web services in the future so I decided to see what it takes to create some web services in PHP using Zend. I was pleasantly surprise (well not really surprised) [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been using the Zend for the last few months and I&#8217;m loving it. Here at work we were having a discussion about implementing some web services in the future so I decided to see what it takes to create some web services in PHP using Zend. I was pleasantly surprise (well not really surprised) that it was extremely quick and easy to get things up and running.</p>
<p>In this post, I&#8217;m going to explain how to create web services that can be accessed via AMF, XMLRPC, JSON, and REST using the Zend Framework. Hopefully these should cover most uses out there. I left SOAP out since I don&#8217;t really see myself using it any time soon. I will be communicating with a database as well to make the tutorial more informative. The db will consist of one table with information about courses such as mathematics courses.</p>
<p>I&#8217;m going to show you the final product first, hopefully to catch your attention so you&#8217;ll read the rest <img src='http://www.joeyrivera.com/blog_new/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> . This is what the final product will look like. If you look at the following links in Chrome, do a view source to see the formatted response.</p>
<h5>XMLRPC</h5>
<p>One course:  <a href="http://www.joeyrivera.com/ZendWebServices/xml-rpc/course-info/abbr/math101/">http://www.joeyrivera.com/ZendWebServices/xml-rpc/course-info/abbr/math101/</a><br />
All courses:  <a href="http://www.joeyrivera.com/ZendWebServices/xml-rpc/courses-info/">http://www.joeyrivera.com/ZendWebServices/xml-rpc/courses-info/</a></p>
<h5>JSON</h5>
<p>One course:  <a href="http://www.joeyrivera.com/ZendWebServices/json/course-info/abbr/math101/">http://www.joeyrivera.com/ZendWebServices/json/course-info/abbr/math101/</a><br />
All courses: <a href="http://www.joeyrivera.com/ZendWebServices/json/courses-info/">http://www.joeyrivera.com/ZendWebServices/json/courses-info/</a></p>
<h5>REST</h5>
<p>One course:  <a href="http://www.joeyrivera.com/ZendWebServices/rest/course-info/?method=getCourseInfo&amp;abbr=math102">http://www.joeyrivera.com/ZendWebServices/rest/course-info/?method=getCourseInfo&amp;abbr=math102</a><br />
All courses:  <a href="http://www.joeyrivera.com/ZendWebServices/rest/courses-info/?method=getCoursesInfo">http://www.joeyrivera.com/ZendWebServices/rest/courses-info/?method=getCoursesInfo</a></p>
<h5>AMF</h5>
<p>One course:  <a href="http://www.joeyrivera.com/ZendWebServices/amf/course-info/abbr/math101">http://www.joeyrivera.com/ZendWebServices/amf/course-info/abbr/math101</a><br />
All courses:  <a href="http://www.joeyrivera.com/ZendWebServices/amf/courses-info/">http://www.joeyrivera.com/ZendWebServices/amf/courses-info/</a><span id="more-356"></span></p>
<p>Now let me show you how to make this work. First thing is setting up the database. If you already have a database you can communicate with just use that, there&#8217;s nothing specific to the database I&#8217;ll be using that requires you to create it. But if you want to follow along here are the details. I&#8217;ll be creating a database called &#8217;sample&#8217; with a table called &#8216;course&#8217;.</p>
<div class="dean_ch" style="white-space: wrap;"><span class="kw1">DROP TABLE</span> IF <span class="kw1">EXISTS</span> `sample`.`course`;<br />
<span class="kw1">CREATE TABLE</span>  `sample`.`course` <span class="br0">&#40;</span><br />
`course_id` <span class="kw2">INT</span><span class="br0">&#40;</span><span class="nu0">10</span><span class="br0">&#41;</span> <span class="kw3">UNSIGNED</span> <span class="kw3">NOT NULL</span> <span class="kw3">AUTO_INCREMENT</span>,<br />
`abbr` <span class="kw2">VARCHAR</span><span class="br0">&#40;</span><span class="nu0">10</span><span class="br0">&#41;</span> <span class="kw3">NOT NULL</span>,<br />
`name` <span class="kw2">VARCHAR</span><span class="br0">&#40;</span><span class="nu0">45</span><span class="br0">&#41;</span> <span class="kw3">NOT NULL</span>,<br />
`title` <span class="kw2">VARCHAR</span><span class="br0">&#40;</span><span class="nu0">45</span><span class="br0">&#41;</span> <span class="kw3">NOT NULL</span>,<br />
`credits` <span class="kw2">SMALLINT</span><span class="br0">&#40;</span><span class="nu0">5</span><span class="br0">&#41;</span> <span class="kw3">UNSIGNED</span> <span class="kw3">NOT NULL</span>,<br />
<span class="kw1">PRIMARY KEY</span>  <span class="br0">&#40;</span>`course_id`<span class="br0">&#41;</span><br />
<span class="br0">&#41;</span> ENGINE=<span class="kw1">INNODB</span> <span class="kw3">AUTO_INCREMENT</span>=<span class="nu0">3</span> <span class="kw3">DEFAULT</span> <span class="kw3">CHARSET</span>=utf8;</div>
<p>Now that you have the table created, add some sample data:</p>
<div class="dean_ch" style="white-space: wrap;"><span class="kw1">INSERT</span> <span class="kw1">INTO</span> `course` <span class="kw1">VALUES</span><br />
<span class="br0">&#40;</span><span class="kw3">NULL</span>,<span class="st0">&#8216;math101&#8242;</span>,<span class="st0">&#8216;Math 101&#8242;</span>,<span class="st0">&#8216;Beginner Mathematics&#8217;</span>,<span class="st0">&#8216;3&#8242;</span><span class="br0">&#41;</span>,<br />
<span class="br0">&#40;</span><span class="kw3">NULL</span>,<span class="st0">&#8216;math102&#8242;</span>,<span class="st0">&#8216;Math 102&#8242;</span>,<span class="st0">&#8216;Advanced Mathematics&#8217;</span>,<span class="st0">&#8216;4&#8242;</span><span class="br0">&#41;</span>;</div>
<p>Now the code. I have one Model class called Service. This is the only class that interacts with the database. For each format such as XMLRPC, JSON, etc. I created a Controller to handle that formats needs. All these controllers initialize a Zend server class if needed, call the method needed from the Service class, and return the formatted response to the browser.</p>
<p>This is what the Service class looks like:</p>
<div class="dean_ch" style="white-space: wrap;"><span class="kw2">&lt;?php</span><br />
<span class="coMULTI">/**<br />
* Class with all the calls to the db<br />
* IMPORTANT: The methods needs comments with params and return for XMLRPC to work!!!<br />
*<br />
* @author Joey Rivera<br />
*/</span><br />
<span class="kw2">class</span> Service<br />
<span class="br0">&#123;</span><br />
<span class="coMULTI">/**<br />
* Get all courses<br />
*<br />
* @return array<br />
*/</span><br />
<span class="kw2">public</span> <span class="kw2">function</span> getCoursesInfo<span class="br0">&#40;</span><span class="br0">&#41;</span><br />
<span class="br0">&#123;</span><br />
<span class="kw1">return</span> Zend_Registry::<span class="me2">get</span><span class="br0">&#40;</span><span class="st0">&#8216;db&#8217;</span><span class="br0">&#41;</span>-&gt;<span class="me1">fetchAll</span><span class="br0">&#40;</span><span class="st0">&#8217;select * from course&#8217;</span><span class="br0">&#41;</span>;<br />
<span class="br0">&#125;</span><br />
<span class="coMULTI">/**<br />
* Gets info for a course<br />
*<br />
* @param string $abbr<br />
* @return array<br />
*/</span><br />
<span class="kw2">public</span> <span class="kw2">function</span> getCourseInfo<span class="br0">&#40;</span><span class="re0">$abbr</span><span class="br0">&#41;</span><br />
<span class="br0">&#123;</span><br />
<span class="kw1">return</span> Zend_Registry::<span class="me2">get</span><span class="br0">&#40;</span><span class="st0">&#8216;db&#8217;</span><span class="br0">&#41;</span>-&gt;<span class="me1">fetchRow</span><span class="br0">&#40;</span><span class="st0">&quot;select * from course where abbr = &#8216;$abbr&#8217;&quot;</span><span class="br0">&#41;</span>;<br />
<span class="br0">&#125;</span><br />
<span class="br0">&#125;</span></div>
<p>Two methods make up this class. &#8216;getCoursesInfo&#8217; (plural) gets the information from all the courses in the &#8216;course&#8217; table. &#8216;getCourseInfo&#8217; takes in one parameter &#8216;abbr&#8217; and returns the information for the course who&#8217;s abbreviation matches &#8216;abbr&#8217;. You can create as many methods as you like here and these are the methods your controllers will call. One thing to note, you MUST add comments to the methods for XMLRPC calls to work. It uses the variable declaration and return declaration in your comments to know what data type to expect in and out.</p>
<p>Now lets move on to the first format: <strong>XMLRPC</strong>.</p>
<div class="dean_ch" style="white-space: wrap;"><span class="kw2">&lt;?php</span><br />
<span class="coMULTI">/**<br />
* XmlRpcController<br />
*<br />
* @author Joey Rivera<br />
*/</span><br />
<span class="kw2">class</span> XmlRpcController <span class="kw2">extends</span> Zend_Controller_Action<br />
<span class="br0">&#123;</span><br />
protected <span class="re0">$_server</span> = <span class="kw2">null</span>;<br />
protected <span class="re0">$_request</span> = <span class="kw2">null</span>;<br />
<span class="kw2">public</span> <span class="kw2">function</span> init<span class="br0">&#40;</span><span class="br0">&#41;</span><br />
<span class="br0">&#123;</span><br />
<span class="re0">$this</span>-&gt;_helper-&gt;<span class="me1">layout</span>-&gt;<span class="me1">disableLayout</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;<br />
<span class="re0">$this</span>-&gt;_helper-&gt;<span class="me1">viewRenderer</span>-&gt;<span class="me1">setNoRender</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;<br />
<span class="re0">$this</span>-&gt;_server = <span class="kw2">new</span> Zend_XmlRpc_Server<span class="br0">&#40;</span><span class="br0">&#41;</span>;<br />
<span class="re0">$this</span>-&gt;_server-&gt;<span class="me1">setClass</span><span class="br0">&#40;</span><span class="st0">&#8216;Service&#8217;</span>, <span class="st0">&#8216;Service&#8217;</span><span class="br0">&#41;</span>;<br />
<span class="br0">&#125;</span><br />
<span class="kw2">public</span> <span class="kw2">function</span> postDispatch<span class="br0">&#40;</span><span class="br0">&#41;</span><br />
<span class="br0">&#123;</span><br />
<a href="http://www.php.net/echo"><span class="kw3">echo</span></a> <span class="re0">$this</span>-&gt;_server-&gt;<span class="me1">handle</span><span class="br0">&#40;</span><span class="re0">$this</span>-&gt;_request<span class="br0">&#41;</span>;<br />
<span class="br0">&#125;</span><br />
<span class="kw2">public</span> <span class="kw2">function</span> coursesInfoAction<span class="br0">&#40;</span><span class="br0">&#41;</span><br />
<span class="br0">&#123;</span><br />
<span class="re0">$this</span>-&gt;_request = <span class="kw2">new</span> Zend_XmlRpc_Request<span class="br0">&#40;</span><span class="st0">&#8216;Service.getCoursesInfo&#8217;</span><span class="br0">&#41;</span>;<br />
<span class="br0">&#125;</span><br />
<span class="kw2">public</span> <span class="kw2">function</span> courseInfoAction<span class="br0">&#40;</span><span class="br0">&#41;</span><br />
<span class="br0">&#123;</span><br />
<span class="re0">$abbr</span> = Zend_Filter::<span class="me2">get</span><span class="br0">&#40;</span><span class="re0">$this</span>-&gt;_request-&gt;<span class="me1">getParam</span><span class="br0">&#40;</span><span class="st0">&#8216;abbr&#8217;</span><span class="br0">&#41;</span>, <span class="st0">&#8216;StripTags&#8217;</span><span class="br0">&#41;</span>;<br />
<span class="kw1">if</span><span class="br0">&#40;</span>!<a href="http://www.php.net/isset"><span class="kw3">isset</span></a><span class="br0">&#40;</span><span class="re0">$abbr</span><span class="br0">&#91;</span><span class="nu0">1</span><span class="br0">&#93;</span><span class="br0">&#41;</span><span class="br0">&#41;</span> <a href="http://www.php.net/exit"><span class="kw3">exit</span></a>;<br />
<span class="re0">$this</span>-&gt;_request = <span class="kw2">new</span> Zend_XmlRpc_Request<span class="br0">&#40;</span><span class="st0">&#8216;Service.getCourseInfo&#8217;</span><span class="br0">&#41;</span>;<br />
<span class="re0">$this</span>-&gt;_request-&gt;<span class="me1">setParams</span><span class="br0">&#40;</span><a href="http://www.php.net/array"><span class="kw3">array</span></a><span class="br0">&#40;</span><span class="re0">$abbr</span><span class="br0">&#41;</span><span class="br0">&#41;</span>;<br />
<span class="br0">&#125;</span><br />
<span class="br0">&#125;</span></div>
<p>The init function gets called for any action in the controller. I am turning off the layout and view since I won&#8217;t be using them for these examples. Then I initialize the proper zend server class, in this case the &#8216;Zend_XmlRpc_Server&#8217; class. The next line &#8217;setClass&#8217; tells the server what classes will be handling incoming requests. You can add several classes and/or functions. For this sample, I&#8217;m simply attaching one class &#8216;Service&#8217; which I described earlier. &#8216;postDispatch&#8217; gets called after the action for the controller is done executing. In my &#8216;postDispatch&#8217; I tell the server instance to handle the incoming request.</p>
<p>&#8216;coursesInfoAction&#8217; creates a request object that calls the Service class &#8216;getCoursesInfo&#8217; (plural) method. Likewise, &#8216;courseInfoAction&#8217; does the same calling &#8216;getCourseInfo&#8217; (singular) but makes sure the abbr variable is set. Which ever of these two is called, a server instance gets initialized, the request variable is populated, then the server handle method is called so the request is returned to the browser with the correct format. I&#8217;m doing request objects here so I can easily test and make sure these methods are working correctly by just loading the url.</p>
<p>All the other controller classes look very similar, each initializing a server instance if necessary and then telling the server instance to display the results correctly.</p>
<p>Here&#8217;s the <strong>JSON</strong> controller:</p>
<div class="dean_ch" style="white-space: wrap;"><span class="kw2">&lt;?php</span><br />
<span class="coMULTI">/**<br />
* JsonController<br />
*<br />
* @author Joey Rivera<br />
*/</span><br />
<span class="kw2">class</span> JsonController <span class="kw2">extends</span> Zend_Controller_Action<br />
<span class="br0">&#123;</span><br />
protected <span class="re0">$_return</span> = <span class="kw2">null</span>;<br />
<span class="kw2">public</span> <span class="kw2">function</span> init<span class="br0">&#40;</span><span class="br0">&#41;</span><br />
<span class="br0">&#123;</span><br />
<span class="re0">$this</span>-&gt;_helper-&gt;<span class="me1">layout</span>-&gt;<span class="me1">disableLayout</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;<br />
<span class="re0">$this</span>-&gt;_helper-&gt;<span class="me1">viewRenderer</span>-&gt;<span class="me1">setNoRender</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;<br />
<span class="br0">&#125;</span><br />
<span class="kw2">public</span> <span class="kw2">function</span> postDispatch<span class="br0">&#40;</span><span class="br0">&#41;</span><br />
<span class="br0">&#123;</span><br />
<a href="http://www.php.net/echo"><span class="kw3">echo</span></a> Zend_Json::<span class="me2">encode</span><span class="br0">&#40;</span><span class="re0">$this</span>-&gt;_return<span class="br0">&#41;</span>;<br />
<span class="br0">&#125;</span><br />
<span class="kw2">public</span> <span class="kw2">function</span> coursesInfoAction<span class="br0">&#40;</span><span class="br0">&#41;</span><br />
<span class="br0">&#123;</span><br />
<span class="re0">$request</span> = <span class="kw2">new</span> Service<span class="br0">&#40;</span><span class="br0">&#41;</span>;<br />
<span class="re0">$this</span>-&gt;_return = <span class="re0">$request</span>-&gt;<span class="me1">getCoursesInfo</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;<br />
<span class="br0">&#125;</span><br />
<span class="kw2">public</span> <span class="kw2">function</span> courseInfoAction<span class="br0">&#40;</span><span class="br0">&#41;</span><br />
<span class="br0">&#123;</span><br />
<span class="re0">$abbr</span> = Zend_Filter::<span class="me2">get</span><span class="br0">&#40;</span><span class="re0">$this</span>-&gt;_request-&gt;<span class="me1">getParam</span><span class="br0">&#40;</span><span class="st0">&#8216;abbr&#8217;</span><span class="br0">&#41;</span>, <span class="st0">&#8216;StripTags&#8217;</span><span class="br0">&#41;</span>;<br />
<span class="kw1">if</span><span class="br0">&#40;</span>!<a href="http://www.php.net/isset"><span class="kw3">isset</span></a><span class="br0">&#40;</span><span class="re0">$abbr</span><span class="br0">&#91;</span><span class="nu0">1</span><span class="br0">&#93;</span><span class="br0">&#41;</span><span class="br0">&#41;</span> <a href="http://www.php.net/exit"><span class="kw3">exit</span></a>;<br />
<span class="re0">$request</span> = <span class="kw2">new</span> Service<span class="br0">&#40;</span><span class="br0">&#41;</span>;<br />
<span class="re0">$this</span>-&gt;_return = <span class="re0">$request</span>-&gt;<span class="me1">getCourseInfo</span><span class="br0">&#40;</span><span class="re0">$abbr</span><span class="br0">&#41;</span>;<br />
<span class="br0">&#125;</span><br />
<span class="br0">&#125;</span></div>
<p>You&#8217;ll notice there is no JSON server class. All we are doing here is grabbing the data set from the Service class and calling Zend&#8217;s Zend_Json::encode to convert the data into a properly formatted JSON string and echoing it out.</p>
<p>Here you can see the implementation for <strong>REST</strong>:</p>
<div class="dean_ch" style="white-space: wrap;"><span class="kw2">&lt;?php</span><br />
<span class="coMULTI">/**<br />
* RestController<br />
*<br />
* @author Joey Rivera<br />
*/</span><br />
<span class="kw2">class</span> RestController <span class="kw2">extends</span> Zend_Controller_Action<br />
<span class="br0">&#123;</span><br />
protected <span class="re0">$_server</span> = <span class="kw2">null</span>;<br />
protected <span class="re0">$_request</span> = <span class="kw2">null</span>;<br />
<span class="kw2">public</span> <span class="kw2">function</span> init<span class="br0">&#40;</span><span class="br0">&#41;</span><br />
<span class="br0">&#123;</span><br />
<span class="re0">$this</span>-&gt;_helper-&gt;<span class="me1">layout</span>-&gt;<span class="me1">disableLayout</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;<br />
<span class="re0">$this</span>-&gt;_helper-&gt;<span class="me1">viewRenderer</span>-&gt;<span class="me1">setNoRender</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;<br />
<span class="re0">$this</span>-&gt;_server = <span class="kw2">new</span> Zend_Rest_Server<span class="br0">&#40;</span><span class="br0">&#41;</span>;<br />
<span class="re0">$this</span>-&gt;_server-&gt;<span class="me1">setClass</span><span class="br0">&#40;</span><span class="st0">&#8216;Service&#8217;</span>, <span class="st0">&#8216;Service&#8217;</span><span class="br0">&#41;</span>;<br />
<span class="br0">&#125;</span><br />
<span class="kw2">public</span> <span class="kw2">function</span> postDispatch<span class="br0">&#40;</span><span class="br0">&#41;</span><br />
<span class="br0">&#123;</span><br />
<span class="re0">$this</span>-&gt;_server-&gt;<span class="me1">handle</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;<br />
<span class="br0">&#125;</span><br />
<span class="kw2">public</span> <span class="kw2">function</span> coursesInfoAction<span class="br0">&#40;</span><span class="br0">&#41;</span><br />
<span class="br0">&#123;</span><br />
<span class="br0">&#125;</span><br />
<span class="kw2">public</span> <span class="kw2">function</span> courseInfoAction<span class="br0">&#40;</span><span class="br0">&#41;</span><br />
<span class="br0">&#123;</span><br />
<span class="re0">$abbr</span> = Zend_Filter::<span class="me2">get</span><span class="br0">&#40;</span><span class="re0">$this</span>-&gt;_request-&gt;<span class="me1">getParam</span><span class="br0">&#40;</span><span class="st0">&#8216;abbr&#8217;</span><span class="br0">&#41;</span>, <span class="st0">&#8216;StripTags&#8217;</span><span class="br0">&#41;</span>;<br />
<span class="kw1">if</span><span class="br0">&#40;</span>!<a href="http://www.php.net/isset"><span class="kw3">isset</span></a><span class="br0">&#40;</span><span class="re0">$abbr</span><span class="br0">&#91;</span><span class="nu0">1</span><span class="br0">&#93;</span><span class="br0">&#41;</span><span class="br0">&#41;</span> <a href="http://www.php.net/exit"><span class="kw3">exit</span></a>;<br />
<span class="br0">&#125;</span><br />
<span class="br0">&#125;</span></div>
<p>Starting to look repetitive? Once you figure out how to make one format work, the others are very similar. Part of using REST is passing a method parameter in the query string. The method you pass is the method of the service that will be called. This is why coursesInfo and courseInfo don&#8217;t do anything but validate if necessary.</p>
<p>Finally if you work with Flash or Flex like I do some times, you&#8217;ll want to use AMF if you are working with complex or large data sets. Here&#8217;s the <strong>AMF</strong> example:</p>
<div class="dean_ch" style="white-space: wrap;"><span class="kw2">&lt;?php</span><br />
<span class="coMULTI">/**<br />
* AmfController<br />
*<br />
* @author Joey Rivera<br />
*/</span><br />
<span class="kw2">class</span> AmfController <span class="kw2">extends</span> Zend_Controller_Action<br />
<span class="br0">&#123;</span><br />
protected <span class="re0">$_server</span> = <span class="kw2">null</span>;<br />
protected <span class="re0">$_request</span> = <span class="kw2">null</span>;<br />
<span class="kw2">public</span> <span class="kw2">function</span> init<span class="br0">&#40;</span><span class="br0">&#41;</span><br />
<span class="br0">&#123;</span><br />
<span class="re0">$this</span>-&gt;_helper-&gt;<span class="me1">layout</span>-&gt;<span class="me1">disableLayout</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;<br />
<span class="re0">$this</span>-&gt;_helper-&gt;<span class="me1">viewRenderer</span>-&gt;<span class="me1">setNoRender</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;<br />
<span class="re0">$this</span>-&gt;_server = <span class="kw2">new</span> Zend_Amf_Server<span class="br0">&#40;</span><span class="br0">&#41;</span>;<br />
<span class="re0">$this</span>-&gt;_server-&gt;<span class="me1">setClass</span><span class="br0">&#40;</span><span class="st0">&#8216;Service&#8217;</span><span class="br0">&#41;</span>;<br />
<span class="br0">&#125;</span><br />
<span class="kw2">public</span> <span class="kw2">function</span> postDispatch<span class="br0">&#40;</span><span class="br0">&#41;</span><br />
<span class="br0">&#123;</span><br />
<a href="http://www.php.net/echo"><span class="kw3">echo</span></a> <span class="re0">$this</span>-&gt;_server-&gt;<span class="me1">handle</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;<br />
<span class="br0">&#125;</span><br />
<span class="kw2">public</span> <span class="kw2">function</span> coursesInfoAction<span class="br0">&#40;</span><span class="br0">&#41;</span><br />
<span class="br0">&#123;</span><br />
<span class="br0">&#125;</span><br />
<span class="kw2">public</span> <span class="kw2">function</span> courseInfoAction<span class="br0">&#40;</span><span class="br0">&#41;</span><br />
<span class="br0">&#123;</span><br />
<span class="br0">&#125;</span><br />
<span class="br0">&#125;</span></div>
<p>If you try to access the url for amf in your browser you&#8217;ll be prompted to download a file because AMF is not a text format but a binary format that Flash and Flex read. You&#8217;ll just have to take my word on that it&#8217;s working :p or create a quick Flash/Flex app that calls this service.</p>
<p>This is pretty much all I have for you all today. My next post will be on creating the different format clients to call these services. Thanks for reading. If you have any questions or comments feel free to post.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.joeyrivera.com/2009/amfxmlrpcjsonrest-zend-web-services-tutorial/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Atlanta PHP User Group &#8211; 11/06/2008</title>
		<link>http://www.joeyrivera.com/2008/atlanta-php-user-group-11062008/</link>
		<comments>http://www.joeyrivera.com/2008/atlanta-php-user-group-11062008/#comments</comments>
		<pubDate>Fri, 07 Nov 2008 15:34:42 +0000</pubDate>
		<dc:creator>Joey</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[atlanta php]]></category>
		<category><![CDATA[atlanta startup weekend]]></category>
		<category><![CDATA[AtlantaPHP]]></category>
		<category><![CDATA[php wiki]]></category>
		<category><![CDATA[rest]]></category>
		<category><![CDATA[user group]]></category>

		<guid isPermaLink="false">http://www.joeyrivera.com/?p=150</guid>
		<description><![CDATA[So I attended my first Atlanta PHP user group thanks to Moses nagging me about going :p. I&#8217;m glad I went, I had a great time. I really enjoyed being there listening and even sharing a little. The things I took with me that I&#8217;m going to mention are:
Atlanta Startup Weekend
During the meeting I found [...]]]></description>
			<content:encoded><![CDATA[<p>So I attended my first <a title="Atlanta PHP User Group page" href="http://www.atlantaphp.org/" target="_blank">Atlanta PHP user group</a> thanks to <a title="Moses web site" href="http://www.mospired.com" target="_blank">Moses</a> nagging me about going :p. I&#8217;m glad I went, I had a great time. I really enjoyed being there listening and even sharing a little. The things I took with me that I&#8217;m going to mention are:</p>
<p><strong>Atlanta Startup Weekend</strong><br />
During the meeting I found out about this really neat event. The objective of the <a title="Atlanta Startup Weekend" href="http://atlanta2.startupweekend.com/" target="_blank">Atlanta Startup Weekend</a> is to get a bunch of people together, divide them into groups (developers, marketing people, business people, etc) and in one weekend finalize a product from a concept. Tickets are already sold out so I&#8217;ll have to try for next year. I&#8217;m sure I could learn a lot.</p>
<p><strong>PHP Wiki</strong><br />
I didn&#8217;t know about this page: <a href="http://wiki.php.net/">http://wiki.php.net/</a>. You can get lots of neat information from the PHP group. The rfc (request for comments) section is also very informative. You can see what requests have been made, which request are going to be implemented and which have already been implemented. It&#8217;s a good way to stay ahead of the curve since you would know what&#8217;s coming out before it&#8217;s out.</p>
<p><strong>REST</strong><br />
Don&#8217;t quote me on any of this, this is just bits and pieces that I think I gathered from listening to others talk. If I understand correctly, REST is a standard for creating RESTful url/url/web services that are efficient and scalable&#8230; maybe? I heard REST mentioned a lot during the &lt;head&gt; conference a couple weekends ago and I heard it mentioned a few times last night during this meeting. So, now I need to go do some more research and figure out what this REST thing is all about. Seems like it&#8217;s something worth knowing about and maybe even following? If you have any info or resources you can recommend please do.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.joeyrivera.com/2008/atlanta-php-user-group-11062008/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
