<?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>philpalmieri &#187; php</title>
	<atom:link href="http://philpalmieri.com/category/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://philpalmieri.com</link>
	<description>php, codeigniter, mysql, jquery, as3 &#38; flex</description>
	<lastBuildDate>Sat, 03 Apr 2010 04:51:38 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Codeigniter Simpletest Modular Extensions Suite</title>
		<link>http://philpalmieri.com/2010/01/codeigniter-simpletest-matchbox-suite/</link>
		<comments>http://philpalmieri.com/2010/01/codeigniter-simpletest-matchbox-suite/#comments</comments>
		<pubDate>Thu, 21 Jan 2010 03:04:45 +0000</pubDate>
		<dc:creator>Phil</dc:creator>
				<category><![CDATA[codeigniter]]></category>
		<category><![CDATA[matchbox & modular extensions]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://philpalmieri.com/?p=192</guid>
		<description><![CDATA[Update&#8230; I am still having issues with MB  - and apparently others are too view thread.  So, I am once again switching back to HMVC / Modular Extensions.. With that switch I am also converting the Simpletest module as well as my Tag and Template libraries over as well.. I&#8217;ll release them soon (this month&#8230;. really) &#8212;- [...]]]></description>
			<content:encoded><![CDATA[<p>Update&#8230;</p>
<p>I am still having issues with MB  - and apparently others are too <a href="http://codeigniter.com/forums/viewthread/144164/" target="_blank">view thread</a>.  So, I am once again switching back to HMVC / Modular Extensions.. With that switch I am also converting the Simpletest module as well as my Tag and Template libraries over as well..</p>
<p>I&#8217;ll release them soon (this month&#8230;. really)</p>
<p>&#8212;-</p>
<p>So, I am primarily writing this pre-post as incentive for myself to have a deadline and accountability.</p>
<p>After reading Jaime Rumbelow&#8217;s post on <a href="http://jamieonsoftware.com/P10/" target="_blank">Codeigniter and Simpletest</a> I realized I needed a way to do TDD in my Matchbox modules without having to set everything up each time.</p>
<p>I have an almost ready matchbox simpletest module that scans other modules for tests and auto runs them.   Each module you want to build with TDD only needs to contain its tests (which can  run on their own by loading the simpletest lib from the simpletest module) or can be auto loaded in batch from the main simpletest module.</p>
<p>If you are interested in helping me beta test, let me know &#8211; i plan to release a beta somewhere around Feb 1.</p>
]]></content:encoded>
			<wfw:commentRss>http://philpalmieri.com/2010/01/codeigniter-simpletest-matchbox-suite/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>CodeIgniter Textmate Bundle</title>
		<link>http://philpalmieri.com/2009/10/codeigniter-textmate-bundle/</link>
		<comments>http://philpalmieri.com/2009/10/codeigniter-textmate-bundle/#comments</comments>
		<pubDate>Fri, 16 Oct 2009 11:26:09 +0000</pubDate>
		<dc:creator>Phil</dc:creator>
				<category><![CDATA[codeigniter]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[textmate]]></category>

		<guid isPermaLink="false">http://philpalmieri.com/?p=176</guid>
		<description><![CDATA[I Know this is a few days old already, but its just too good of a tool to not post in as many places as possible. There is now a CodeIgniter Textmate bundle avaialable! If you are like me, you have a bunch of snippets already available for common CodeIgniter code. Well, David Ferguson wrote [...]]]></description>
			<content:encoded><![CDATA[<p>I Know this is a few days old already, but its just too good of a tool to not post in as many places as possible.</p>
<p>There is now a CodeIgniter Textmate bundle avaialable!  If you are like me, you have a bunch of snippets already available for common CodeIgniter code.    Well, <a href="http://sourceforge.net/users/jdfwarrior" target="_blank">David Ferguson</a> wrote a <a href="http://sourceforge.net/projects/cibundle/" target="_blank">CodeIgniter Textmate bundle</a> that has snippets and shortcuts for every helper and class available in 1.7.2</p>
]]></content:encoded>
			<wfw:commentRss>http://philpalmieri.com/2009/10/codeigniter-textmate-bundle/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Matchbox is Back! So Long Modular Extensions&#8230;</title>
		<link>http://philpalmieri.com/2009/09/matchbox-is-back-so-long-modular-extensions/</link>
		<comments>http://philpalmieri.com/2009/09/matchbox-is-back-so-long-modular-extensions/#comments</comments>
		<pubDate>Thu, 10 Sep 2009 01:32:50 +0000</pubDate>
		<dc:creator>Phil</dc:creator>
				<category><![CDATA[codeigniter]]></category>
		<category><![CDATA[matchbox & modular extensions]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://philpalmieri.com/?p=151</guid>
		<description><![CDATA[So, for once, my procrastination has paid off! A while back i was complaining, in the most polite way of course, about the lack of development of matchbox. A few days ago Zacharias released Matchbox RC1.  He completely re-wrote it from the ground up and has made it 100% compatible with the latest Codeigniter release. [...]]]></description>
			<content:encoded><![CDATA[<p>So, for once, my procrastination has paid off!  A while back i was complaining, in the most polite way of course, about the lack of development of matchbox. A few days ago Zacharias released Matchbox RC1.  He completely re-wrote it from the ground up and has made it 100% compatible with the latest Codeigniter release.</p>
<p>I downloaded the release candidate from <a href="http://codeigniter.com/wiki/Matchbox/">http://codeigniter.com/wiki/Matchbox/</a>, dropped it into a new branch of some projects that use the old version, and was off and running.</p>
<p>As i play with it more i plan to release some of our code like the <a title="AMFPHP Codeigniter" href="http://philpalmieri.com/2009/04/codeigniter-amfphp-library/">AMFPHP library</a> as self contained modules that can be dropped into an application.</p>
<p>Thanks again to Zacharias for all your hard work.</p>
<p>Phil</p>
]]></content:encoded>
			<wfw:commentRss>http://philpalmieri.com/2009/09/matchbox-is-back-so-long-modular-extensions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Snow Leopard / MAMP Pro mySQL woes</title>
		<link>http://philpalmieri.com/2009/09/snow-leopard-mamp-pro-mysql-woes/</link>
		<comments>http://philpalmieri.com/2009/09/snow-leopard-mamp-pro-mysql-woes/#comments</comments>
		<pubDate>Tue, 08 Sep 2009 03:23:46 +0000</pubDate>
		<dc:creator>Phil</dc:creator>
				<category><![CDATA[codeigniter]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[mamp]]></category>

		<guid isPermaLink="false">http://philpalmieri.com/?p=144</guid>
		<description><![CDATA[After wiping my computer and installing 10.6 from scratch, my local php/mysql would not work at all.  The biggest problem was that I was receiving an error when trying to connect to mySQL &#8220;Lost connection to MySQL server at &#8216;reading initial communication packet&#8217;, system error: 61&#8243;. It turns our that in MAMP Pro 1.8, they [...]]]></description>
			<content:encoded><![CDATA[<p>After wiping my computer and installing 10.6 from scratch, my local php/mysql would not work at all.  The biggest problem was that I was receiving an error when trying to connect to mySQL &#8220;Lost connection to MySQL server at &#8216;reading initial communication packet&#8217;, system error: 61&#8243;.</p>
<p>It turns our that in MAMP Pro 1.8, they left out the local bind-address declaration, which for some reason freaks out the default PHP/Apache setup.</p>
<p>So, if you are running Snow Leopard and MAMP Pro and can&#8217;t connect to your mySQL, it&#8217;s an easy fix.  In MAMP Pro edit your my.cnf template (File &gt; Edit Template) .  Add this line somewhere after the &#8220;[mysqld]&#8221; declaration (and reload) &#8211; Everything should be good.</p>
<blockquote><p>bind-address = 127.0.0.1</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://philpalmieri.com/2009/09/snow-leopard-mamp-pro-mysql-woes/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Codeigniter Image Cache &amp; Auto Size on Demand&#8221;</title>
		<link>http://philpalmieri.com/2009/06/codeigniter-image-cache-auto-size-on-demand/</link>
		<comments>http://philpalmieri.com/2009/06/codeigniter-image-cache-auto-size-on-demand/#comments</comments>
		<pubDate>Fri, 26 Jun 2009 02:25:11 +0000</pubDate>
		<dc:creator>Phil</dc:creator>
				<category><![CDATA[codeigniter]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[cache]]></category>
		<category><![CDATA[gd2]]></category>
		<category><![CDATA[images]]></category>
		<category><![CDATA[resize]]></category>

		<guid isPermaLink="false">http://philpalmieri.com/?p=55</guid>
		<description><![CDATA[What This &#8216;library&#8217; for lack of a better description allows  designers to use libraries of high-res images anywhere in the site, at any size, without having to pre-define or pre-scale your images.  It can also be used on the fly with user uploaded photos in a gallery setting. Why Other alternatives I have found in [...]]]></description>
			<content:encoded><![CDATA[<h3>What</h3>
<p>This &#8216;library&#8217; for lack of a better description allows  designers to use libraries of high-res images anywhere in the site, at any size, without having to pre-define or pre-scale your images.  It can also be used on the fly with user uploaded photos in a gallery setting.</p>
<h3>Why</h3>
<p>Other alternatives I have found in both codeigniter and other frameworks/cms&#8217;s like Drupal, EE, and WordPress require the administrators to pre-define set image sizes like thumbnail, medium, large.  While this makes sense for a new site, it can be an issue if you want to redesing and start using a different size for thumbnails, previews etc.</p>
<h3>Basic Usage Overview</h3>
<p>To use the &#8216;library&#8217;,  all you need to do is set your img tag source to point to the controller with a few pre-defined uri segments.</p>
<p style="text-align: center;">Image Tag: &lt;img src=&#8221;/img/size/<span style="color: #000000;"><strong>o</strong></span>/<span style="color: #ff6600;">folders_your_image_is_in</span>-<span style="color: #008000;">your_image.jpg</span>/<strong>w</strong>/240/<strong>h</strong>/160/<strong>m</strong>/<span style="color: #0000ff;">auto</span>&#8221; /&gt;</p>
<p style="text-align: left;">* If you arn&#8217;t using .htaccess to mask your index.php.. change the path to index.php/img/size&#8230;..</p>
<p style="text-align: left;">Sample site using library: <a href="http://www.synlawn.com/gallery" target="_blank">http://www.synlawn.com/gallery</a></p>
<h3 style="text-align: left;">Features</h3>
<ul>
<li>Fully customizable with little work</li>
<li>Can support any directory depth in any location (does not need to be web accessible)</li>
<li>Automatically caches called images in their original directory at called size so it only processes once</li>
<li>Can be dropped into any CI installation &#8211; It was even originally written as a Matchbox module</li>
<li>Maintains your image heirarchy and file name in source (for SEO) and keeps images available for external reference.</li>
<li>Uses default codeigniter img_library, nothing else to install (unless you do not have imagemagick, netpbm, gd, or gd2)</li>
<li>Uses a default &#8216;error/not-found&#8217; image so you can stick a site logo on a high res image to use anywhere in case of an error (no image-not-found issues)</li>
</ul>
<p><span id="more-55"></span></p>
<h3>Still working on</h3>
<ul>
<li>Auto re-cache images if full-size date is newer than cached files date</li>
<li>Does not support directories or images with a &#8216;-&#8217; in the name (will replace with less common charactor eventually)</li>
<li>Add additional flag to render full html doc with self-generated img tag (so you can do ajax call to script for full size images)</li>
<li>If you have errors turned on images will not resize and you will get a blank rendering.</li>
<li>other things i haven&#8217;t found/thought of yet&#8230;  please add comments</li>
</ul>
<h3>Installation</h3>
<p>Drop the img.php controller into your controllers folder and drop the img_model.php into your models folder. Also, make sure all of your images directories are writable by script user.</p>
<h3>Usage &amp; Instructions</h3>
<p><strong>Setup your default image and base path<br />
</strong></p>
<ul>
<li>In the construct of the img_model, set the &#8216;path&#8217; property to the base directory all your resizable images will be in</li>
<li>set the &#8216;default&#8217; property in the img_model to the location of your default &#8216;not-found&#8217; image. This path is relative to your &#8216;path&#8217; you set in the last bullet.</li>
</ul>
<p>The image src path needs 4 key value pairs that get parsed.  They are:</p>
<p><strong>O: </strong><em>Origional</em><strong><br />
</strong>This is where you define the path to your image relative to $img_model-&gt;path; Your $img_model-&gt;path property can be anywhere you script has permission to access (ie: below web accesible www directory).  The directories are seperated by &#8216;-&#8217;s so if your origional image is in &#8216;product_photos/shirts/mens_t.jpg&#8217; your path will look like &#8216;product_photos-shirts-mens_t.jpg&#8217;</p>
<p><strong>W:</strong> <em>Width<br />
</em>This is your target width of the generated image in pixels</p>
<p><strong>H: </strong><em>Height<br />
</em>This is your target height of the generated image in pixels</p>
<p><strong>M: </strong><em>Master Dimension<br />
</em>This is your master dimension (defaults to auto).  This is where you can require your image be at least the <strong>width</strong> or <strong>height</strong>.  An example would be on a listing page, you want all of your thumbnails to be the same width or height so your design isn&#8217;t screwed up.</p>
<h3>Ok, so where are the files?</h3>
<p>Download thie zip file: <a href="http://philpalmieri.com/wp-content/uploads/2009/06/img_cache.zip">img_cache.zip</a></p>
<p>Please enjoy, and let me know if there are any issues or ideas.</p>
<p style="text-align: left;">
]]></content:encoded>
			<wfw:commentRss>http://philpalmieri.com/2009/06/codeigniter-image-cache-auto-size-on-demand/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Codeigniter AMFPHP library &#8211; updated</title>
		<link>http://philpalmieri.com/2009/04/codeigniter-amfphp-library/</link>
		<comments>http://philpalmieri.com/2009/04/codeigniter-amfphp-library/#comments</comments>
		<pubDate>Sat, 25 Apr 2009 00:47:30 +0000</pubDate>
		<dc:creator>Phil</dc:creator>
				<category><![CDATA[codeigniter]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[amfphp]]></category>

		<guid isPermaLink="false">http://philpalmieri.com/?p=10</guid>
		<description><![CDATA[Update 11/24/09: In order to load other libraries/models into your models with AMFPHP, change the BASEPATH declaration in index.php to define&#40;'BASEPATH', realpath&#40;dirname&#40;__FILE__&#41;&#41;.'/'.$system_folder.'/'&#41;; This is more of a repost of my wiki page on Codeigniter&#8217;s site, but i needed filler content for my first few postings on my site. At first glance there is a lot [...]]]></description>
			<content:encoded><![CDATA[<blockquote><p><strong>Update 11/24/09</strong>: In order to load other libraries/models into your models with AMFPHP, change the BASEPATH declaration in index.php to</p></blockquote>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #990000;">define</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'BASEPATH'</span><span style="color: #339933;">,</span> <span style="color: #990000;">realpath</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">dirname</span><span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">__FILE__</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'/'</span><span style="color: #339933;">.</span><span style="color: #000088;">$system_folder</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'/'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>This is more of a repost of my wiki page on Codeigniter&#8217;s site, but i needed filler content for my first few postings on my site.</p>
<p>At first glance there is a lot to digest, but it is actually a pretty simple installation and is basically just replacing the gateway file with a Codeigniter controller</p>
<h3>What it does</h3>
<p>This AMF library will give you full access to your Codeigniter Models, as well as any libraries. In other words, it was written to work with Codeigniter, as Codeigniter was intended to be used &#8211; and you can drop this into your existing setup.</p>
<h3>How??</h3>
<p>Instead of trying to bootstrap Codeigniter, or use models outside of your app.  We create a Codeigniter controller, and a Codeigniter AMFPHP library that uses AMFPHP as packaged. &#8211; Then you create an AMFPHP Services in the services folder that just extends your Codeigniter models, and gives you full access</p>
<h3>Full Working Example</h3>
<p>We have packaged up the entire working sample that includes a fresh Codeigniter 1.7.1, AMF 1.9 and 2 flash samples modified from the Open Source Flash Development book chapter by (<a href="http://www.wadearnold.com/blog">Wade Arnold</a>) and a sample product mysql table.</p>
<p>All of the sample code assumes you ARE NOT using a .htaccess file, and also assumes you are using the default everything.  If you have moved your app and system path outside your webroot (as you should) it should still work fine too.</p>
<p><a href="http://www.philpalmieri.com/public/clean-ci-amfphp.zip">Dowload the files</a></p>
<h3>And away we go: Instructions / Explanation of whats going on</h3>
<ul>
<li>Download Codeigniter and AMFPHP (or pull apart the link above)</li>
<li>Make sure Codeigniter works as expected before moving forward</li>
<li>Put the unzipped amfphp package into your libraries folder</li>
<li>Create your amf_gateway.php in &#8216;controllers&#8217;</li>
</ul>
<blockquote><p>This file replaces the need for gateway.php<br />
setup netConnection to &#8216;/index.php/amf_gateway&#8217;</p></blockquote>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">class</span> Amf_gateway <span style="color: #000000; font-weight: bold;">extends</span> Controller
<span style="color: #009900;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> __construct<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
  <span style="color: #009900;">&#123;</span>
    parent<span style="color: #339933;">::</span><span style="color: #004000;">Controller</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #666666; font-style: italic;">//Start our library (keep reading the tutorial)</span>
    <span style="color: #000088;">$this</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>load<span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>library<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'amfci'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #666666; font-style: italic;">//Set new include path for services</span>
    <span style="color: #990000;">ini_set</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'include_path'</span><span style="color: #339933;">,</span> <span style="color: #990000;">ini_get</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'include_path'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> PATH_SEPARATOR <span style="color: #339933;">.</span> AMFSERVICES<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//startup the amf gateway service</span>
 <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> index<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
 <span style="color: #009900;">&#123;</span>
  <span style="color: #000088;">$this</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>amfci<span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>service<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<ul>
<li>Create a standard Codeigniter model or use an existing one</li>
<li>Drop in the amfci_db.php file provided into &#8216;libraries/amfphp/services/amfci_db.php&#8217;</li>
<li>Create AMFPHP Service in &#8216;libraries/amfphp/services&#8217; folder using the template provided</li>
</ul>
<blockquote><p>This file is a service for AMFPHP &#8211; called from flash<br />
This extends your existing model to give flash access to all its methods</p></blockquote>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">//Load CI DB Instance since we are not coming through index.php</span>
<span style="color: #b1b100;">require_once</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'amfci_db.php'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Use this path if you are using a module (ie, MatchBox)</span>
<span style="color: #666666; font-style: italic;">// require_once(AMFSERVICES.'/../../../modules/test_shop/models/product_model.php');</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Use this path if you are using standard install</span>
<span style="color: #b1b100;">require_once</span><span style="color: #009900;">&#40;</span>AMFSERVICES<span style="color: #339933;">.</span><span style="color: #0000ff;">'/../../../models/your_model.php'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">class</span> your_model_service <span style="color: #000000; font-weight: bold;">extends</span> your_model
<span style="color: #009900;">&#123;</span>
  <span style="color: #666666; font-style: italic;">//Since extending your_model, all existing methods are available</span>
  <span style="color: #666666; font-style: italic;">//New Methods</span>
  <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> yourNewMethod<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
  <span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$something</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//Create array to send to flash</span>
    <span style="color: #b1b100;">return</span> <span style="color: #000088;">$something</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Add the amfci.php library to your library folder <em>The amfci library is used by amf_gateway controller that replaces the default gateway.php file, by creating an instance of the gateway as $this-&gt;gateway, and settign the needed options</em></p>
<blockquote><p>This file is the new amfphp library for CI<br />
It it loaded from the amf_gateway controller, and binds all of it together</p></blockquote>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">class</span> Amfci
<span style="color: #009900;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000088;">$gateway</span><span style="color: #339933;">;</span>
  <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000088;">$CI</span><span style="color: #339933;">;</span>
  <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> __construct<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
  <span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$this</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>CI <span style="color: #339933;">=</span> get_instance<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">require</span> <span style="color: #990000;">realpath</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">dirname</span><span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">__FILE__</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;/amfphp/globals.php&quot;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">require</span> <span style="color: #990000;">realpath</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">dirname</span><span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">__FILE__</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;/amfphp/core/amf/app/Gateway.php&quot;</span><span style="color: #339933;">;</span>
    <span style="color: #990000;">define</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'AMFSERVICES'</span><span style="color: #339933;">,</span> <span style="color: #990000;">realpath</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">dirname</span><span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">__FILE__</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;/amfphp/services&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000088;">$this</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>gateway <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Gateway<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$this</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>gateway<span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>setCharsetHandler<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;utf8_decode&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;ISO-8859-1&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;ISO-8859-1&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$this</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>gateway<span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>setLooseMode<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$this</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>gateway<span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>setErrorHandling<span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">E_ALL</span> ^ <span style="color: #009900; font-weight: bold;">E_NOTICE</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$this</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>gateway<span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>setClassMappingsPath<span style="color: #009900;">&#40;</span>AMFSERVICES<span style="color: #339933;">.</span><span style="color: #0000ff;">'/vo'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$this</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>gateway<span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>setClassPath<span style="color: #009900;">&#40;</span>AMFSERVICES<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span>PRODUCTION_SERVER<span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
      <span style="color: #666666; font-style: italic;">//Disable profiling, remote tracing, and service browser</span>
      <span style="color: #000088;">$this</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>gateway<span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>disableDebug<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
  <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> service<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
  <span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$this</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>gateway<span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>service<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<h3>Connect and call from flash</h3>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #9900cc; font-weight: bold;">package</span> com.page12.hello_world
<span style="color: #000000;">&#123;</span>
  <span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.display</span>.<span style="color: #004993;">MovieClip</span>;
  <span style="color: #0033ff; font-weight: bold;">import</span> fl.events.<span style="color: #000000; font-weight: bold;">*</span>;
  <span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.events</span>.<span style="color: #000000; font-weight: bold;">*</span>;
  <span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.net</span>.<span style="color: #004993;">NetConnection</span>;
  <span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.net</span>.<span style="color: #004993;">Responder</span>;
  <span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.net</span>.<span style="color: #004993;">ObjectEncoding</span>;
&nbsp;
  <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> Main extends <span style="color: #004993;">MovieClip</span> <span style="color: #000000;">&#123;</span>
    <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> gateway<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">String</span> = <span style="color: #990000;">&quot;/index.php/amf_gateway&quot;</span>;
    <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> connection<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">NetConnection</span>;
    <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> responder<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Responder</span>;
&nbsp;
    <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> Main<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
    <span style="color: #000000;">&#123;</span>
      send_btn.<span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">MouseEvent</span>.<span style="color: #004993;">CLICK</span>, sendData<span style="color: #000000;">&#41;</span>;
      responder = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Responder</span><span style="color: #000000;">&#40;</span>onResult, onFault<span style="color: #000000;">&#41;</span>;
      connection = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">NetConnection</span>;
      <span style="color: #009900;">//connection.objectEncoding = ObjectEncoding.AMF3;</span>
      connection.<span style="color: #004993;">connect</span><span style="color: #000000;">&#40;</span>gateway<span style="color: #000000;">&#41;</span>;
    <span style="color: #000000;">&#125;</span>
&nbsp;
    <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> sendData<span style="color: #000000;">&#40;</span>e<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">MouseEvent</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span>
    <span style="color: #000000;">&#123;</span>
      <span style="color: #6699cc; font-weight: bold;">var</span> params = server_txt.<span style="color: #004993;">text</span>;
      response_txt.<span style="color: #004993;">text</span> = <span style="color: #990000;">'Send '</span><span style="color: #000000; font-weight: bold;">+</span>server_txt.<span style="color: #004993;">text</span><span style="color: #000000; font-weight: bold;">+</span><span style="color: #990000;">' to server'</span>;
      connection.<span style="color: #004993;">call</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;hello_world_service.say&quot;</span>, responder, params<span style="color: #000000;">&#41;</span>;
    <span style="color: #000000;">&#125;</span>
&nbsp;
    <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> onResult<span style="color: #000000;">&#40;</span>result<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Object</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span>
    <span style="color: #000000;">&#123;</span>
      response_txt.<span style="color: #004993;">text</span> = <span style="color: #004993;">String</span><span style="color: #000000;">&#40;</span>result<span style="color: #000000;">&#41;</span>;
    <span style="color: #000000;">&#125;</span>
&nbsp;
    <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> onFault<span style="color: #000000;">&#40;</span>fault<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Object</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span>
    <span style="color: #000000;">&#123;</span>
      response_txt.<span style="color: #004993;">text</span> = <span style="color: #004993;">String</span><span style="color: #000000;">&#40;</span>fault.<span style="color: #004993;">description</span><span style="color: #000000;">&#41;</span>;
    <span style="color: #000000;">&#125;</span>
  <span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://philpalmieri.com/2009/04/codeigniter-amfphp-library/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
	</channel>
</rss>
