<?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>CaChi &#187; PHP</title>
	<atom:link href="http://cachi.temiga.org/tag/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://cachi.temiga.org</link>
	<description>[ TEMIGA ]</description>
	<lastBuildDate>Mon, 19 Jul 2010 14:10:08 +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>KumbiaPHP Tips: Añadir titulo (title) a nuestras páginas&#8230;</title>
		<link>http://cachi.temiga.org/2010/06/14/kumbiaphp-tips-anadir-titulo-title-a-nuestras-paginas/</link>
		<comments>http://cachi.temiga.org/2010/06/14/kumbiaphp-tips-anadir-titulo-title-a-nuestras-paginas/#comments</comments>
		<pubDate>Tue, 15 Jun 2010 01:59:19 +0000</pubDate>
		<dc:creator>CaChi</dc:creator>
				<category><![CDATA[KumbiaPHP]]></category>
		<category><![CDATA[Buenas Prácticas]]></category>
		<category><![CDATA[comunidad]]></category>
		<category><![CDATA[Hacking]]></category>
		<category><![CDATA[KumbiaPHP Tips]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[POO]]></category>
		<category><![CDATA[Programing]]></category>
		<category><![CDATA[SEO]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://cachi.temiga.org/?p=659</guid>
		<description><![CDATA[Una de las cosas que siempre es importante tomar en cuenta es la de agregar un titulo a la página (title) donde se esta navegando, esto por múltiples factores que van desde SEO, usabilidad, navegación, etc. en este post les quiero dejar un KumbiaPHP Tips (asi los bautice) que les permitirá de forma simple agregar]]></description>
			<content:encoded><![CDATA[<p><a href="http://cachi.temiga.org/wp-content/uploads/helpful_tips_image.jpg"><img class="alignleft" title="Tips and Tricks" src="http://cachi.temiga.org/wp-content/uploads/helpful_tips_image.jpg" alt="Tips and Tricks" width="180" height="182" /></a>Una de las cosas que siempre es importante tomar en cuenta es la de agregar un titulo a la página (<a href="http://www.w3schools.com/tags/tag_title.asp">title</a>) donde se esta navegando, esto por múltiples factores que van desde <a href="http://es.wikipedia.org/wiki/Posicionamiento_en_buscadores" title="Posicionamiento en buscadores (SEO)">SEO</a>, usabilidad, navegación, etc. en este post les quiero dejar un <a href="http://cachi.temiga.org/tag/kumbiaphp-tips/">KumbiaPHP Tips</a> (asi los bautice) que les permitirá de forma simple agregar títulos a las páginas de forma dinámica.</p>
<p>Lo que siempre hay que recordar es que <a title="KumbiaPHP Framework" href="http://kumbiaphp.com">KumbiaPHP</a> es un framework MVC y POO (Programación Orientado a Objetos) si aprendemos a utilizar la arquitectura y el paradigma juntos seremos muy productivo, ademas de los beneficios adicionales que la aplicación de estas conlleva.</p>
<p>Bien, vamos al ejemplo lo primero es saber que <a title="KumbiaPHP Framework" href="http://kumbiaphp.com">KumbiaPHP</a> implementa algo llamado <em>variables de instancia</em>, esto quiere decir que los atributos que son declarado con <a title="Visibilidad POO" href="http://www.php.net/manual/en/language.oop5.visibility.php" target="_blank">modificador acceso</a> público (public) en el controlador serán enviados a la vista, en el <a href="http://wiki.kumbiaphp.com/Hola_Mundo_KumbiaPHP_Framework#Agregando_m.C3.A1s_Contenido" target="_blank">ejemplo de hola mundo</a> puedes apreciarlo. Partiendo de esta premisa jugaremos con eso y vamos a definir un atributo <strong>$pageTitle</strong> con modificador de acceso <em>public</em> en el controlador base, me refiero al <strong><a title="ApplicationController | Controlador Padre" href="http://wiki.kumbiaphp.com/KumbiaPHP_Framework_Versi%C3%B3n_1.0_Spirit#application.php" target="_blank">application.php</a></strong>.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #009933; font-style: italic;">/**
 * Todas las controladores heredan de esta clase en un nivel superior
 * por lo tanto los metodos aqui definidos estan disponibles para
 * cualquier controlador.
 *
 * @category Kumbia
 * @package Controller
 **/</span>
<span style="color: #000000; font-weight: bold;">class</span> ApplicationController <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: #000088;">$pageTitle</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'Mi Titulo'</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Con esto ya tenemos en las vistas <strong>$pageTitle</strong>, ahora tenemos que colocar esa variable a cumplir su función y tomando el ejemplo de <a title="KumbiaPHP + Ajax + jQuery" href="http://cachi.temiga.org/2010/06/10/kumbiaphp-ajax-jquery/">KumbiaPHP + Ajax + jQuery</a> este tiene como <a href="http://www.w3schools.com/tags/tag_title.asp">title</a> de la página <strong>&#8220;KumbiaPHP web &amp; app Framework&#8221;</strong>, vamos a editar el <a href="http://wiki.kumbiaphp.com/KumbiaPHP_Framework_Versi%C3%B3n_1.0_Spirit#views.2Ftemplates.2F">Template</a> <strong>app/views/templates/default.phtml</strong> y agregamos en el tag <a href="http://www.w3schools.com/tags/tag_title.asp">title</a> la variable <strong>$pageTitle</strong> como se muestra en el siguiente código.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Strict//EN&quot; 
                   &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
 &lt;head&gt;
  &lt;meta http-equiv='Content-type' content='text/html; charset=<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> APP_CHARSET <span style="color: #000000; font-weight: bold;">?&gt;</span>' /&gt;
  &lt;title&gt;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$pageTitle</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
    //CONTENIDO BODY
&lt;/body&gt;
&lt;/html&gt;</pre></div></div>

<p>Lo importante notar en el template es que se agrego la variable <strong>$pageTitle</strong>, con esto todos las páginas tendrán un titulo por defecto, ahora la idea es cambiarlo de acuerdo a donde se encuentre la navegación, siguiendo el ejemplo <a title="KumbiaPHP + Ajax + jQuery" href="http://cachi.temiga.org/2010/06/10/kumbiaphp-ajax-jquery/">KumbiaPHP + Ajax + jQuery</a> en la acción <strong>acortar()</strong> le vamos agregar un titulo personalizado como se muestra en el siguiente código.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">   <span style="color: #339933;">...</span> DEFINICIÓN DEL CONTROLLER<span style="color: #339933;">...</span>
   <span style="color: #009933; font-style: italic;">/**
     * Form que se comunica con el API de SigueMiLink
     * para acortar el enlace
     *
     */</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> acortar<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;">-&gt;</span><span style="color: #004000;">pageTitle</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'Crea tu enlace Corto con SigueMiLink'</span><span style="color: #339933;">;</span>
        <span style="color: #666666; font-style: italic;">//RESTO DEL CÓDIGO</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #339933;">...</span> DEFINICIÓN DEL CONTROLLER<span style="color: #339933;">...</span></pre></div></div>

<p>Para finalizar al ir al enlace <a href="http://localhost/kumbiaphp/api/acortar/">http://localhost/kumbiaphp/api/acortar/</a> debe mostrar el siguiente titulo <strong>&#8220;Crea tu enlace Corto con SigueMiLink&#8221;</strong>.</p>
<p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fcachi.temiga.org%2F2010%2F06%2F14%2Fkumbiaphp-tips-anadir-titulo-title-a-nuestras-paginas%2F&amp;linkname=KumbiaPHP%20Tips%3A%20A%C3%B1adir%20titulo%20%28title%29%20a%20nuestras%20p%C3%A1ginas%26%238230%3B"><img src="http://cachi.temiga.org/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a> </p>]]></content:encoded>
			<wfw:commentRss>http://cachi.temiga.org/2010/06/14/kumbiaphp-tips-anadir-titulo-title-a-nuestras-paginas/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>KumbiaPHP + Ajax + jQuery</title>
		<link>http://cachi.temiga.org/2010/06/10/kumbiaphp-ajax-jquery/</link>
		<comments>http://cachi.temiga.org/2010/06/10/kumbiaphp-ajax-jquery/#comments</comments>
		<pubDate>Thu, 10 Jun 2010 16:04:07 +0000</pubDate>
		<dc:creator>CaChi</dc:creator>
				<category><![CDATA[KumbiaPHP]]></category>
		<category><![CDATA[Programación]]></category>
		<category><![CDATA[AJAX]]></category>
		<category><![CDATA[Buenas Prácticas]]></category>
		<category><![CDATA[comunidad]]></category>
		<category><![CDATA[framework]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[KumbiaPHP Tips]]></category>
		<category><![CDATA[MVC]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[php framework]]></category>
		<category><![CDATA[Programing]]></category>
		<category><![CDATA[service]]></category>
		<category><![CDATA[ShortUrl]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://cachi.temiga.org/?p=641</guid>
		<description><![CDATA[Actualizado 11 de Junio 2010 En este tutorial explcaré el comportamiento de KumbiaPHP cuando hacemos aplicaciones ricas en JavaScript, me basare en utilizar jQuery como framework de JavaScript y no daré una explicación muy amplia de que son peticiones asíncronas ni como funcionan estas esto porque hay suficiente información en la red para quienes deseen]]></description>
			<content:encoded><![CDATA[<blockquote><p>Actualizado 11 de Junio 2010</p></blockquote>
<p>En este tutorial explcaré el comportamiento de <a href="http://www.kumbiaphp.com" title="KumbiaPHP Framework">KumbiaPHP</a> cuando hacemos aplicaciones ricas en JavaScript, me basare en utilizar jQuery como framework de JavaScript  y no daré una explicación muy amplia de que son peticiones asíncronas ni como funcionan estas esto porque hay suficiente información en la red para quienes deseen indagar un poco mas, simplemente nos dedicaremos hacer peticiones asíncronas dentro de <a href="http://www.kumbiaphp.com" title="KumbiaPHP Framework">KumbiaPHP</a>.</p>
<p>Como todo ejemplo lo ideal es basarlo en hechos reales y cotidianos en este sentido haremos un cliente que acorte URL utilizando el <a href="http://www.siguemilink.com/api">API</a> del servicio <a href="http://www.siguemilink.com/" title="SigueMiLink » Acorta tus enlaces!">SigueMiLink</a> el cual fue desarrollado con KumbiaPHP :).</p>
<h3>Requisitos</h3>
<p>Antes de continuar hay que verificar lo que necesitamos para llevar acabo el tutorial.</p>
<ul>
<li>Tener funcionando KumbiaPHP <a href="http://www.kumbiaphp.com/blog/manuales-y-descargas/">Beta1</a> (<a href="http://wiki.kumbiaphp.com/Instalar_Kumbia">Instalar KumbiaPHP</a>)</li>
<li><a href="http://code.jquery.com/jquery-1.4.2.min.js">Descargar jQuery</a> y colocarlo en el directorio <strong>app/public/javascript/jquery/jquery-1.4.2.min.js</strong>.</li>
<li>Por lo menos haber hecho el ejemplo <a href="http://wiki.kumbiaphp.com/Hola_Mundo_KumbiaPHP_Framework">Hola Mundo de KumbiaPHP</a> para entender este tutorial.</li>
<li>Leer un poco el <a href="http://www.siguemilink.com/api">API</a> del servicio <a href="http://www.siguemilink.com/" title="SigueMiLink » Acorta tus enlaces!">SigueMiLink</a></li>
<li>Ver funcionamiento básico de <a href="http://wiki.kumbiaphp.com/AJAX">KumbiaPHP con AJAX</a></li>
</ul>
<h3>Empezamos</h3>
<p>Lo primero es crear el controlador para efecto de este tutorial lo llame <strong>api</strong> mirar las <a href="http://wiki.kumbiaphp.com/Preguntas_Frecuentes#.C2.BFCu.C3.A1l_es_la_convenci.C3.B3n_para_nombrar_los_archivos_y_clases_de_modelos_y_controladores.3F">convenciones de nombres de controladores</a> si se te ocurre otro nombre mejor usalo, pero piensa que a lo largo del tutorial haré mención al <strong>controller api</strong>.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #009933; font-style: italic;">/**
 * Controller para utilizar el API de SigueMiLink
 * @author Deivinson Tejeda &lt;deivinsontejeda@kumbiaphp.com&gt;
 */</span>
<span style="color: #000000; font-weight: bold;">class</span> ApiController <span style="color: #000000; font-weight: bold;">extends</span> ApplicationController
<span style="color: #009900;">&#123;</span>
    <span style="color: #009933; font-style: italic;">/**
     * URL del API de SigueMiLink
     */</span>
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000088;">$_urlAPI</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'http://www.siguemilink.com/api/%s/?destination=%s'</span><span style="color: #339933;">;</span>
    <span style="color: #009933; font-style: italic;">/**
     * Callback Before que verifica si la petición es Asíncrona...
     */</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> before_filter<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">is_ajax</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
            <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">set_response</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'view'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #009933; font-style: italic;">/**
     * Form que se comunica con el API de SigueMiLink
     * para acortar el enlace
     *
     */</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> acortar<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">has_post</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'url'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
            <span style="color: #666666; font-style: italic;">//Reemplazo de valores en la URL del API.</span>
            <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_urlAPI <span style="color: #339933;">=</span> <span style="color: #990000;">sprintf</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_urlAPI<span style="color: #339933;">,</span> <span style="color: #0000ff;">'create'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">post</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'url'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">response1</span> <span style="color: #339933;">=</span> <span style="color: #990000;">json_decode</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">file_get_contents</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_urlAPI<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">render</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'response'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Ahora se crea la vista <strong>app/views/api/acortar.phtml</strong> que tiene un formulario que envia la URL al controller que será enviada al API de SigueMiLink.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">&lt;div style=&quot;margin: auto&quot;&gt;
    <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> form_tag<span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'api/acortar/'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'class'</span><span style="color: #339933;">=&gt;</span><span style="color: #0000ff;">'form-remote'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
        &lt;label&gt;Acorte tu enlace&lt;/label&gt;
        <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> text_field_tag<span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'url'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
        <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> submit_tag<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Enviar'</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
    <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> end_form_tag<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;br /&gt;
    &lt;div id=&quot;update&quot; style=&quot;margin: auto;&quot;&gt;&lt;/div&gt;
&lt;/div&gt;
&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> javascript_include_tag<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'jquery/jquery-1.4.2.min'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
&lt;script type=&quot;text/javascript&quot;&gt;
    &lt;!--//--&gt;&lt;![CDATA[//&gt;&lt;!--
        $(function() {
            $(&quot;.form-remote&quot;).live('submit', function(event){
                event.preventDefault();
			    self = $(this);
			    var button = $('[type=submit]', self);
			    button.attr('disabled', 'disabled');
			    var url = self.attr('action');
			    //var div = self.attr('data-div');
			    $.post(url, self.serialize(), function(data, status){
				    var capa = $('#update');
				    capa.html(data);
				    capa.hide();
				    capa.show('slow');
				    button.attr('disabled', null);
			    });
            });
        });
    //--&gt;&lt;!]]&gt;
&lt;/script&gt;</pre></div></div>

<p>Creamos la vista que tiene la respuesta enviado desde el servicio que acorta la URL <strong>app/views/api/response.phtml</strong></p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$response1</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">code</span> <span style="color: #339933;">==</span> <span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">:</span><span style="color: #000000; font-weight: bold;">?&gt;</span>
    &lt;a href=&quot;http://smlk.es/<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$response1</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">link</span><span style="color: #000000; font-weight: bold;">?&gt;</span>/&quot;&gt;http://smlk.es/<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$response1</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">link</span><span style="color: #000000; font-weight: bold;">?&gt;</span>/&lt;/a&gt;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">else</span><span style="color: #339933;">:</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
    &lt;strong&gt;No se pudo acortar el enlace&lt;/strong&gt;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">endif</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>Lo genial de este ejemplo es que funciona con o sin javascript para promover la <a href="http://cachi.temiga.org/2009/10/27/accesibilidad-web/">accesibilidad web</a>. Ahora explico un poco lo que hace el <strong>controller api</strong>, el método <strong>before_filter()</strong> es un filtro que se ejecuta antes de la acción en este caso verificamos si la petición es asíncrona y de serlo damos respuesta asíncrona, útil para centralizar y si la aplicación es muy rica en javascript no se tendra que tener esta validación en cada action del controller ;).</p>
<p>La action <strong>acortar()</strong> muestra el form y envia la petición (cuando se hace el submit) al servicio <a href="http://www.siguemilink.com/" title="SigueMiLink » Acorta tus enlaces!">SigueMiLink</a> para acortar la URL, con el método <a href="http://wiki.kumbiaphp.com/KumbiaPHP_Framework_Versi%C3%B3n_1.0_Spirit#Utilizando_el_m.C3.A9todo_render.28.24view.2C_.5B.24template.5D.29">render()</a> cambiamos de vista a <strong>renpose</strong> y como la petición se ha hecho asíncrona ya saben lo demas :).</p>
<p>En la vista <strong>acortar.phtml</strong> tenemos el formulario y con un JavaScript para enviar la petición asíncrona, en la <a href="http://api.jquery.com/">documentación de jQuery</a> se explican los métodos usados en este ejemplo en los cuales no me enfocare. </p>
<p>Es importante indicar el elemento del <a href="http://en.wikipedia.org/wiki/Document_Object_Model">DOM</a> que se actualizará luego de la petición, en este caso es un div con un identificador (id) <strong>update</strong>.</p>
<p>Es de notar que en la vista <strong>response</strong> no se analizan todos los códigos de error que devuelve el API de SigueMiLink, como tarea pueden hacer esto y dar respuesta al usuario de acuerdo al error retornado del servicio.</p>
<h3>Importante</h3>
<ul>
<li>Si no indicas que la respuesta será asíncrona <a href="http://www.kumbiaphp.com">KumbiaPHP</a> cargará todo el template y por ende habran elementos de la vista que veras repetidos, así que no olvides el <strong>$this->set_response(&#8216;view&#8217;)</strong>.</li>
<li>Saber que elemento del DOM se va actualizar</li>
</ul>
<h3>A probar lo hecho</h3>
<p>Así es, nos queda probar lo que se hizo y mirar que todo ande como lo planeado, es decir un formulario con un campo de texto donde se coloca la URL que deseamos acortar al dar click en el submit si todo estuvo bien nos retorna una URL acortada para compartirla en nuestras redes sociales&#8230;</p>
<p>Asumiendo que tienes una instalación local deberías ver el ejemplo pinchando una URL como esta http://localhost/kumbiaphp/api/acortar/ es importante entender las <a href="http://wiki.kumbiaphp.com/Hola_Mundo_KumbiaPHP_Framework#KumbiaPHP_URLs" title="URL de KumbiaPHP">URL de KumbiaPHP</a></p>
<p>En la <a href="http://wiki.kumbiaphp.com/">Wiki de KumbiaPHP</a> hay un ejemplo mas simple de como <a href="http://wiki.kumbiaphp.com/Integrar_KumbiaPHP_Spirit_con_jQuery">integrar jQuery en KumbiaPHP</a> y puede quedar mucho mejor este tutorial por ejemplo tener un modelo que se consuma todo el web service del API de SigueMiLink, pero ya esto es tarea de lo mas curiosos les dejo un post que escribí sobre los <a href="http://cachi.temiga.org/2009/12/29/que-es-un-modelo-mvc/">modelo dentro del MVC</a></p>
<p>¿dudas? ¿sugerencias? deja tu comentario y ayuda a mejorar este ejemplo&#8230;</p>
<p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fcachi.temiga.org%2F2010%2F06%2F10%2Fkumbiaphp-ajax-jquery%2F&amp;linkname=KumbiaPHP%20%2B%20Ajax%20%2B%20jQuery"><img src="http://cachi.temiga.org/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a> </p>]]></content:encoded>
			<wfw:commentRss>http://cachi.temiga.org/2010/06/10/kumbiaphp-ajax-jquery/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Razones para usar KumbiaPHP Framework</title>
		<link>http://cachi.temiga.org/2010/02/27/razones-para-usar-kumbiaphp-framework/</link>
		<comments>http://cachi.temiga.org/2010/02/27/razones-para-usar-kumbiaphp-framework/#comments</comments>
		<pubDate>Sat, 27 Feb 2010 18:27:25 +0000</pubDate>
		<dc:creator>CaChi</dc:creator>
				<category><![CDATA[KumbiaPHP]]></category>
		<category><![CDATA[comunidad]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programing]]></category>

		<guid isPermaLink="false">http://cachi.temiga.org/?p=452</guid>
		<description><![CDATA[Hoy me dedique a actualizar un viejo Post que fue escrito por allá en Junio del 2007 donde se mencionan algunas razones por las cuales utilizar KumbiaPHP. Esta actualización fue producto de que estoy trabajando con @HenryStivens en la creación de unos podcast sobre KumbiaPHP, en otro post daré detalle sobre estos podcast.]]></description>
			<content:encoded><![CDATA[<p>Hoy me dedique a actualizar un viejo Post que fue escrito por allá en <a href="http://cachi.temiga.org/2007/06/">Junio del 2007</a> donde se mencionan <a href="http://cachi.temiga.org/2007/06/04/kumbia/" title="razones por las cuales utilizar KumbiaPHP">algunas razones por las cuales utilizar KumbiaPHP</a>.</p>
<p>Esta actualización fue producto de que estoy trabajando con <a href="http://twitter.com/henrystivens/" title="Twitter de Henry Stivens">@HenryStivens</a> en la creación de unos podcast sobre <a href="http://kumbiaphp.com" title="KumbiaPHP Framework">KumbiaPHP</a>, en otro post daré detalle sobre estos podcast.</p>
<p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fcachi.temiga.org%2F2010%2F02%2F27%2Frazones-para-usar-kumbiaphp-framework%2F&amp;linkname=Razones%20para%20usar%20KumbiaPHP%20Framework"><img src="http://cachi.temiga.org/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a> </p>]]></content:encoded>
			<wfw:commentRss>http://cachi.temiga.org/2010/02/27/razones-para-usar-kumbiaphp-framework/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>KumbiaPHP Tips: aprovecha el método initialize()</title>
		<link>http://cachi.temiga.org/2010/01/31/kumbiaphp-tips-aprovecha-el-metodo-initialize/</link>
		<comments>http://cachi.temiga.org/2010/01/31/kumbiaphp-tips-aprovecha-el-metodo-initialize/#comments</comments>
		<pubDate>Mon, 01 Feb 2010 01:33:40 +0000</pubDate>
		<dc:creator>CaChi</dc:creator>
				<category><![CDATA[KumbiaPHP]]></category>
		<category><![CDATA[Programación]]></category>
		<category><![CDATA[Buenas Prácticas]]></category>
		<category><![CDATA[KumbiaPHP Tips]]></category>
		<category><![CDATA[MVC]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[POO]]></category>
		<category><![CDATA[Programing]]></category>

		<guid isPermaLink="false">http://cachi.temiga.org/?p=410</guid>
		<description><![CDATA[Desde hace días he estado por escribir pequeñas notas donde se pueda obtener el mayor provecho al momento de utilizar KumbiaPHP, en este primer post mencionaré como aprovechar uno de los callback de los que dispone KumbiaPHP en su versión 1.0 Codename Spirit y que he notado que muy pocos usuarios suelen aprovecharlo y/o utilizarlo.]]></description>
			<content:encoded><![CDATA[<p><a href="http://cachi.temiga.org/wp-content/uploads/helpful_tips_image.jpg"><img class="alignleft" style="padding: 10px;" title="Tips and Tricks" src="http://cachi.temiga.org/wp-content/uploads/helpful_tips_image.jpg" alt="" width="180" height="182" /></a>Desde hace días he estado por escribir pequeñas notas donde se pueda obtener el mayor provecho al momento de utilizar <a title="KumbiaPHP Framework" href="http://www.kumbiaphp.com">KumbiaPHP</a>, en este primer post mencionaré como aprovechar uno de los <em>callback</em> de los que dispone KumbiaPHP en su <a href="http://wiki.kumbiaphp.com/KumbiaPHP_Framework_Versi%C3%B3n_1.0_Spirit">versión 1.0 Codename Spirit</a> y que he notado que muy pocos usuarios suelen aprovecharlo y/o utilizarlo.</p>
<p>Me refiero al método <strong>initialize()</strong> el cual actúa como un filtro y es ejecutado antes de cualquier Controlador que hayamos definido. Esto no es por casualidad recordemos que <a title="KumbiaPHP Framework" href="http://www.kumbiaphp.com/">KumbiaPHP</a> es un Framework <a title="POO" href="http://es.wikipedia.org/wiki/Programaci%C3%B3n_orientada_a_objetos" target="_blank">Orientado a Objetos (POO)</a>, en pocas palabras el método <strong><em>initialize()</em></strong> esta definido en la class <em><strong>Controller</strong></em>, nosotros como desarrolladores solo debemos darle el comportamiento que queramos.</p>
<p>Para tener una idea mas clara imaginemos que tenemos un módulo (admin) y queremos que dicho módulo tenga un <a title="Template en KumbiaPHP" href="http://wiki.kumbiaphp.com/KumbiaPHP_Framework_Versi%C3%B3n_1.0_Spirit#views.2Ftemplates.2F">Template</a> distinto al que hemos definido por defecto en toda la aplicación.</p>
<p>En el archivo [app]/application.php es donde debemos darle comportamiento al método initialize().</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">class</span> ApplicationController <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> initialize<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #666666; font-style: italic;">//verificamos que exista un módulo con nombre &quot;admin&quot;</span>
        <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span>Router<span style="color: #339933;">::</span><span style="color: #004000;">get</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'module'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'admin'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
            <span style="color: #666666; font-style: italic;">//cambiamos el valor por defecto del template en caso que exista ese módulo</span>
            <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">template</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'template_admin'</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>En el código anterior no hay nada <em>esotérico</em> y con esto hemos cambiado el comportamiento de todos nuestros controladores sin necesidad de ir de uno en uno y como esta podemos aplicar otras validaciones en ese punto de ejecución de nuestra aplicación</p>
<p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fcachi.temiga.org%2F2010%2F01%2F31%2Fkumbiaphp-tips-aprovecha-el-metodo-initialize%2F&amp;linkname=KumbiaPHP%20Tips%3A%20aprovecha%20el%20m%C3%A9todo%20initialize%28%29"><img src="http://cachi.temiga.org/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a> </p>]]></content:encoded>
			<wfw:commentRss>http://cachi.temiga.org/2010/01/31/kumbiaphp-tips-aprovecha-el-metodo-initialize/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>¿Que es un Modelo? &#8211; MVC</title>
		<link>http://cachi.temiga.org/2009/12/29/que-es-un-modelo-mvc/</link>
		<comments>http://cachi.temiga.org/2009/12/29/que-es-un-modelo-mvc/#comments</comments>
		<pubDate>Tue, 29 Dec 2009 23:41:14 +0000</pubDate>
		<dc:creator>CaChi</dc:creator>
				<category><![CDATA[Programación]]></category>
		<category><![CDATA[Buenas Prácticas]]></category>
		<category><![CDATA[framework]]></category>
		<category><![CDATA[KumbiaPHP]]></category>
		<category><![CDATA[MVC]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[POO]]></category>
		<category><![CDATA[Programing]]></category>

		<guid isPermaLink="false">http://cachi.temiga.org/?p=378</guid>
		<description><![CDATA[Una de las cosas que se aprecia constantemente entre las comunidades de desarrolladores, es la vaga idea que suele existir sobre el manejo del MVC donde solo se tiene en mente el concepto de wikipedia y demas sitios donde se conceptualiza sobre el tema. Resulta bastante difícil, de acuerdo a mi experiencia y el roce]]></description>
			<content:encoded><![CDATA[<p>Una de las cosas que se aprecia constantemente entre las comunidades de desarrolladores, es la vaga idea que suele existir sobre el manejo del <a title="MVC Wikipedia" href="http://es.wikipedia.org/wiki/Modelo_Vista_Controlador" target="_blank">MVC</a> donde solo se tiene en mente el concepto de wikipedia y demas sitios donde se conceptualiza sobre el tema.</p>
<p>Resulta bastante difícil, de acuerdo a mi experiencia y el roce que he tenido con personas del área, ir de la teoría a la implementacion del concepto de lo que es <a title="MVC Wikipedia" href="http://es.wikipedia.org/wiki/Modelo_Vista_Controlador" target="_blank">MVC</a> parece ser una camino ofuscado en el que muchos se pierden. La gran mayoría suele decir <em>&#8220;estoy claro en lo es MVC&#8230;&#8221;</em>, pero cuando se ve la aplicabilidad se termina dando cuenta que lo que dijó <em>&#8220;estoy claro&#8230;&#8221;</em> es inversamente proporcional.</p>
<h2>Filosofía de un Modelo</h2>
<p>Estos son &#8220;Lógica de Negocio&#8221; y son parte fundamental para el momento que se desarrolla una aplicación, un buen uso de estos nos permiten un gran poder al momento que se necesita escalar, mantener y rehusar código en una aplicación.; es un concepto muy simple, pero la complicacion esta en comprender lo que significa &#8220;Logica de Negocio&#8221; ya que muchos piensan que la única forma de tener &#8220;Lógica de Negocio&#8221; va estrecha y únicamente relacionada con una conexión de <a title="WikiPedia Base de Datos" href="http://es.wikipedia.org/wiki/Base_de_datoshttp://es.wikipedia.org/wiki/Base_de_datos" target="_blank">Base de Datos</a> y esto no es asi!</p>
<p>La práctica mas común (en todos los niveles, no solo me refiero a usuarios novatos) es que dejan la lógica en los <a title="MVC Wikipedia" href="http://es.wikipedia.org/wiki/Modelo_Vista_Controlador#Descripci.C3.B3n_del_patr.C3.B3nhttp://es.wikipedia.org/wiki/Modelo_Vista_Controlador#Descripci.C3.B3n_del_patr.C3.B3n" target="_blank">controladores</a>, a medida que se deja código de la <em>lógica de negocio</em> en un controlador trae consecuencias garrafales a largo plazo siendo imposible su reutilizacion, traduciendoce en una mala implementacion (<strong>código espaguetti</strong>). Lo antes expuesto no es precisamente lo que fomenta MVC y <a title="Programación Orientada a Objetos" href="http://es.wikipedia.org/wiki/POO" target="_self">POO</a> donde la idea fundamental es el orden y reutilización del código.</p>
<p>Veamos un par de ejemplos para contextualizar.</p>
<p>El primero es un Modelo donde su <em>lógica de negocio</em> esta en una Base de Datos y por ende necesitamos una conexion a motor para trabajar con esa fuente de datos.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">class</span> Articulos <span style="color: #000000; font-weight: bold;">extends</span> ActiveRecord <span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> ver<span style="color: #009900;">&#40;</span><span style="color: #000088;">$page</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span><span style="color: #000088;">$ppage</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">10</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">return</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>paginate<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'order: creat_at desc'</span><span style="color: #339933;">,</span>
					<span style="color: #0000ff;">&quot;page: <span style="color: #006699; font-weight: bold;">$page</span>&quot;</span><span style="color: #339933;">,</span>
					<span style="color: #0000ff;">&quot;per_page: <span style="color: #006699; font-weight: bold;">$ppage</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> ultimos<span style="color: #009900;">&#40;</span><span style="color: #000088;">$limit</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">10</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$today</span> <span style="color: #339933;">=</span> <span style="color: #990000;">date</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'now'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">return</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>find<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'order: creat_at desc'</span><span style="color: #339933;">,</span>
				   <span style="color: #0000ff;">&quot;conditions: data &amp;gt;= <span style="color: #006699; font-weight: bold;">$today</span>&quot;</span><span style="color: #339933;">,</span>
                                    <span style="color: #0000ff;">&quot;limit: <span style="color: #006699; font-weight: bold;">$limit</span>&quot;</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>

<p>Lo que mencionamos arriba sobre la re-utilización de código y característica fundamental de la <a title="Programación Orientada a Objetos" href="http://es.wikipedia.org/wiki/POO" target="_blank">POO</a>, si vemos el método <strong><em>ultimos()</em></strong> del modelo Articulos nos sirve para crear un RSS, widget (Partial en KumbiaPHP) con los artículos recientes, etc. es decir donde se necesite los últimos artículos.</p>
<p>El segundo es un Modelo para el manejo de fotos y su la <em>lógica de negocio</em> <strong>no esta ligada a una BD</strong>.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #009933; font-style: italic;">/**
* Carga la libreria upload
**/</span>
Load<span style="color: #339933;">::</span><span style="color: #004000;">lib</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'upload'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009933; font-style: italic;">/**
* Carga la libreria wideimage
**/</span>
<span style="color: #666666; font-style: italic;">//Load::lib('wideimage');</span>
<span style="color: #009933; font-style: italic;">/**
* Modelo para manipular las fotos de las personas
*
**/</span>
<span style="color: #000000; font-weight: bold;">class</span> Foto
<span style="color: #009900;">&#123;</span>
    <span style="color: #009933; font-style: italic;">/**
* Guarda la foto de una persona
*
* @param string $id id de la foto al guardar
* @param string $file nombre de la foto
* @return boolean
**/</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> save <span style="color: #009900;">&#40;</span><span style="color: #000088;">$id</span><span style="color: #339933;">,</span> <span style="color: #000088;">$file</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$_FILES</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$file</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'error'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            Flash<span style="color: #339933;">::</span><span style="color: #004000;">error</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Error: No se ha logrado subir el archivo'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span> <span style="color: #990000;">in_array</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_FILES</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$file</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'type'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'image/jpeg'</span> <span style="color: #339933;">,</span> <span style="color: #0000ff;">'image/pjpeg'</span> <span style="color: #339933;">,</span> <span style="color: #0000ff;">'image/gif'</span> <span style="color: #339933;">,</span> <span style="color: #0000ff;">'image/png'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            Flash<span style="color: #339933;">::</span><span style="color: #004000;">error</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Error: Solo se admiten imagenes JPEG, PNG y GIF'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$_FILES</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$file</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'size'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">600</span> <span style="color: #339933;">*</span> <span style="color: #cc66cc;">1024</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            Flash<span style="color: #339933;">::</span><span style="color: #004000;">error</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Error: No se admiten imagenes superiores a 600KB'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>Upload<span style="color: #339933;">::</span><span style="color: #004000;">image</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$file</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;<span style="color: #006699; font-weight: bold;">$id</span>.jpg&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000088;">$file_path</span> <span style="color: #339933;">=</span> APP_PATH <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;public/img/upload/<span style="color: #006699; font-weight: bold;">$id</span>.jpg&quot;</span><span style="color: #339933;">;</span>
            <span style="color: #666666; font-style: italic;">// con marca de agua</span>
            <span style="color: #666666; font-style: italic;">// $watermark = wiImage::load(APP_PATH . &quot;public/img/logo.png&quot;);</span>
            <span style="color: #666666; font-style: italic;">// wiImage::load($file_path)-&gt;resize(160, 213, 'fill')-&gt;merge($watermark, 40, 175)-&gt;saveToFile($file_path);</span>
            wiImage<span style="color: #339933;">::</span><span style="color: #004000;">load</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$file_path</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">resize</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">160</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">213</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'fill'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">saveToFile</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$file_path</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #990000;">chmod</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$file_path</span><span style="color: #339933;">,</span> <span style="color: #208080;">0777</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
        <span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #009933; font-style: italic;">/**
* Busca la foto y en caso de que exista retorna la ruta relativa respecto al directorio de imagenes
*
* @return string $id
* @return string
**/</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> get <span style="color: #009900;">&#40;</span><span style="color: #000088;">$id</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">is_file</span><span style="color: #009900;">&#40;</span>APP_PATH <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;public/img/upload/<span style="color: #006699; font-weight: bold;">$id</span>.jpg&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #b1b100;">return</span> <span style="color: #0000ff;">&quot;upload/<span style="color: #006699; font-weight: bold;">$id</span>.jpg&quot;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
        <span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">null</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #009933; font-style: italic;">/**
* ELimina la foto del usuario
*
* @return string $id
* @return string
**/</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> delete <span style="color: #009900;">&#40;</span><span style="color: #000088;">$id</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$filepath</span> <span style="color: #339933;">=</span> APP_PATH <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;public/img/upload/<span style="color: #006699; font-weight: bold;">$id</span>.jpg&quot;</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">is_file</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$filepath</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #b1b100;">return</span> <span style="color: #990000;">unlink</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$filepath</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
        <span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Como se aprecia en este segundo modelo no existe ninguna conexión a una BD y sigue teniendo <em>lógica de negocio</em> para la aplicación, esta historia también se puede repetir para un modelo de sessión, o como me comento el amigo Jesus Lara (<a title="Phenobarbital con Soda" href="http://phenobarbital.wordpress.com/">Phenobarbital</a>) tiene modelos que gestionan todas las operaciones de un servidor SAMBA.</p>
<p><a title="Como Usar los Modelos en KumbiaPHP" href="http://wiki.kumbiaphp.com/Como_Usar_los_Modelos_en_KumbiaPHP">Como Usar los Modelos en KumbiaPHP</a></p>
<p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fcachi.temiga.org%2F2009%2F12%2F29%2Fque-es-un-modelo-mvc%2F&amp;linkname=%C2%BFQue%20es%20un%20Modelo%3F%20%26%238211%3B%20MVC"><img src="http://cachi.temiga.org/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a> </p>]]></content:encoded>
			<wfw:commentRss>http://cachi.temiga.org/2009/12/29/que-es-un-modelo-mvc/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>Presentación 1er encuentro Kumbieros maracay venezuela</title>
		<link>http://cachi.temiga.org/2009/12/12/presentacion-1er-encuentro-kumbieros-maracay-venezuela/</link>
		<comments>http://cachi.temiga.org/2009/12/12/presentacion-1er-encuentro-kumbieros-maracay-venezuela/#comments</comments>
		<pubDate>Sat, 12 Dec 2009 15:23:06 +0000</pubDate>
		<dc:creator>CaChi</dc:creator>
				<category><![CDATA[KumbiaPHP]]></category>
		<category><![CDATA[Planeta Linux]]></category>
		<category><![CDATA[comunidad]]></category>
		<category><![CDATA[Eventos]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://cachi.temiga.org/?p=367</guid>
		<description><![CDATA[Publicó la presentación que realice para el 1er encuentro kumbieros maracay &#8211; venezuela, el cual fue muy ¡exitoso! KumbiaPHP un framework con ñ View more documents from cachi. No colge en este mi blog imagenes porque todas las he colocado en el sitio de KumbiaPHP y mi Flickr]]></description>
			<content:encoded><![CDATA[<p>Publicó la presentación que realice para el <a href="http://www.kumbiaphp.com/blog/2009/10/07/1er-encuentro-de-kumbieros-maracay-venezuela/">1er encuentro kumbieros maracay &#8211; venezuela</a>, el cual fue muy <a href="http://www.kumbiaphp.com/blog/2009/12/07/exitoso-1er-encuentro-de-kumbiaphp-maracay-venezuela/">¡exitoso!</a></p>
<div style="width:425px;text-align:left" id="__ss_2704842"><a style="font:14px Helvetica,Arial,Sans-serif;display:block;margin:12px 0 3px 0;text-decoration:underline;" href="http://www.slideshare.net/cachi/kumbiaphp-un-framework-con" title="KumbiaPHP un framework con ñ">KumbiaPHP un framework con ñ</a><object style="margin:0px" width="425" height="355"><param name="movie" value="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=presentacion-091212083548-phpapp02&#038;stripped_title=kumbiaphp-un-framework-con" /><param name="allowFullScreen" value="true"/><param name="allowScriptAccess" value="always"/><embed src="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=presentacion-091212083548-phpapp02&#038;stripped_title=kumbiaphp-un-framework-con" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="355"></embed></object>
<div style="font-size:11px;font-family:tahoma,arial;height:26px;padding-top:2px;">View more <a style="text-decoration:underline;" href="http://www.slideshare.net/">documents</a> from <a style="text-decoration:underline;" href="http://www.slideshare.net/cachi">cachi</a>.</div>
</div>
<p>No colge en este mi blog imagenes porque todas las he colocado en el sitio de <a href="http://www.kumbiaphp.com">KumbiaPHP</a> y mi <a href="http://www.flickr.com/photos/deivinsontejeda/sets/72157622943932570/" title="Flickr">Flickr</a></p>
<p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fcachi.temiga.org%2F2009%2F12%2F12%2Fpresentacion-1er-encuentro-kumbieros-maracay-venezuela%2F&amp;linkname=Presentaci%C3%B3n%201er%20encuentro%20Kumbieros%20maracay%20venezuela"><img src="http://cachi.temiga.org/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a> </p>]]></content:encoded>
			<wfw:commentRss>http://cachi.temiga.org/2009/12/12/presentacion-1er-encuentro-kumbieros-maracay-venezuela/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>1er Encuentro de Kumbieros Maracay &#8211; Venezuela</title>
		<link>http://cachi.temiga.org/2009/10/07/1er-encuentro-de-kumbieros-maracay-venezuela/</link>
		<comments>http://cachi.temiga.org/2009/10/07/1er-encuentro-de-kumbieros-maracay-venezuela/#comments</comments>
		<pubDate>Wed, 07 Oct 2009 18:28:52 +0000</pubDate>
		<dc:creator>CaChi</dc:creator>
				<category><![CDATA[KumbiaPHP]]></category>
		<category><![CDATA[Planeta Linux]]></category>
		<category><![CDATA[anuncios]]></category>
		<category><![CDATA[Eventos]]></category>
		<category><![CDATA[framework]]></category>
		<category><![CDATA[Noticias]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://cachi.temiga.org/?p=343</guid>
		<description><![CDATA[Ya es un hecho KumbiaPHP llega a su 1er Encuentro de Kumbieros en Maracay &#8211; Venezuela, esto nace producto de la misma comunidad en querer encontrarnos y compartir experiencias sobre el proyecto. Esta iniciativa que nació como KumbiaPHP Party &#38; Beers y ya a estas alturas se ha convertido en un evento. Para ese día]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.kumbiaphp.com/blog/wp-content/uploads/1er-encuentro-kumbieros-maracay-venezuela.jpg"><img class=" alignleft" style="padding: 10px" title="1er Encuentro Kumbieros Maracay - Venezuela 05 Dic 2009" src="http://www.kumbiaphp.com/blog/wp-content/uploads/1er-encuentro-kumbieros-maracay-venezuela.jpg" alt="1er Encuentro Kumbieros Maracay - Venezuela 05 Dic 2009" width="274" height="150" /></a></p>
<p>Ya es un hecho <em>KumbiaPHP</em> llega a su <em><strong>1er Encuentro de Kumbieros en Maracay &#8211; Venezuela</strong></em>, esto nace producto de la misma comunidad en querer encontrarnos y compartir experiencias sobre el proyecto. Esta iniciativa que nació como <em><strong>KumbiaPHP Party &amp; Beers</strong></em> y ya a estas alturas se ha convertido en un evento.</p>
<p>Para ese día tenemos planeado dictar talleres introductorios sobre <em>KumbiaPHP</em>, de la mano de los desarrolladores del Framework y miembros de la comunidad (Próximamente publicaremos el temario de las charlas y/o talleres).</p>
<p><strong>La cita es el Sábado 05 de Diciembre del 2009 a partir de las 09:00 a.m. en Calle Sucre, Complejo Cultural Santos Michelena, Edificio Bibliotecas Virtuales de Aragua, Maracay Edo. Aragua</strong></p>
<p>Como la idea inicial fue un <em>Beers</em> no la hemos dejado de lado, así que al final del evento habrá un <em>Beers</em> (cervezada) que aun no hemos elegido un sitio pero están invitados los que así lo deseen.</p>
<p>Desde KumbiaPHP queremos dar un agradecimiento especial al amigo Hector Rodriguez (acá Al3jandro) por su valiosa colaboración en la organización del evento y encontrar los espacios que dispondremos para esa fecha.</p>
<p>Fuente&#8230; <a title="1er Encuentro de Kumbieros Maracay - Venezuela" href="http://www.kumbiaphp.com/blog/2009/10/07/1er-encuentro-de-kumbieros-maracay-venezuela/" target="_self">KumbiaPHP</a></p>
<p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fcachi.temiga.org%2F2009%2F10%2F07%2F1er-encuentro-de-kumbieros-maracay-venezuela%2F&amp;linkname=1er%20Encuentro%20de%20Kumbieros%20Maracay%20%26%238211%3B%20Venezuela"><img src="http://cachi.temiga.org/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a> </p>]]></content:encoded>
			<wfw:commentRss>http://cachi.temiga.org/2009/10/07/1er-encuentro-de-kumbieros-maracay-venezuela/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>No te confies de todo lo que dice el manual de PHP</title>
		<link>http://cachi.temiga.org/2009/05/17/no_te_confies_de_todo_lo_que_dice_el_manual_de_php/</link>
		<comments>http://cachi.temiga.org/2009/05/17/no_te_confies_de_todo_lo_que_dice_el_manual_de_php/#comments</comments>
		<pubDate>Mon, 18 May 2009 00:37:30 +0000</pubDate>
		<dc:creator>CaChi</dc:creator>
				<category><![CDATA[PHP5]]></category>
		<category><![CDATA[Planeta Linux]]></category>
		<category><![CDATA[Programación]]></category>
		<category><![CDATA[Buenas Prácticas]]></category>
		<category><![CDATA[debug]]></category>
		<category><![CDATA[framework]]></category>
		<category><![CDATA[KumbiaPHP]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[profiler]]></category>

		<guid isPermaLink="false">http://cachi.temiga.org/?p=301</guid>
		<description><![CDATA[Hace unos días haciendo unos benchmark a kumbiaphp framework en comparación con la vieja estructura de directorios de alguna para ver si la nueva estructura directorio genero efectos de rendimientos sobre el framework que seria lo ideal. Bien lo cierto es que cuando se corrió el benchmark los #request/seg no cuadraban y no era lógico]]></description>
			<content:encoded><![CDATA[<p>Hace unos días haciendo unos <a title="benchamrk" href="http://en.wikipedia.org/wiki/Benchmark_(computing)">benchmark</a> a <a title="Sitio web de kumbiaphp framework" href="http://www.kumbiaphp.com">kumbiaphp framework</a> en comparación con la <span style="text-decoration: line-through;">vieja estructura</span> de directorios de alguna para ver si la <a title="KumbiaPHP Avances version 1.0" href="http://www.kumbiaphp.com/blog/2009/04/30/avances_de_kumbiaphp_framework/" target="_blank">nueva estructura directorio</a> genero efectos de rendimientos sobre el framework que seria lo ideal.</p>
<p>Bien lo cierto es que cuando se corrió el benchmark los <strong>#request/seg</strong> no cuadraban y no era lógico ya que la nueva estructura se depuraron ciertas cosas que sobraban, en el benchmark los números obtenidos eran tan locos que la vieja estructura tenia unos 10 #req/seg por encima :-S no era nada normal esto, nos toco recurrir a las <strong><em>buenas prácticas de desarrollo</em></strong> y que ya es una constante dentro del <a title="Equipo de Desarrollo de KumbiaPHP framework" href="http://wiki.kumbiaphp.com/Team_Development_KumbiaPHP_Framework#KumbiaPHP_Team_Developers" target="_blank">Equipo de Desarrollo de kumbiaphp</a> hacer <a title="debug y profiler con xdebug" href="http://cachi.temiga.org/2008/04/08/instalando-xdebug-en-debian-lenny/">debug y profiler con xdebug</a> :-), esto para detectar donde estaban los &#8220;cuellos de botellas&#8221; que nos hacían mas lento que la versión anterior.</p>
<p>El detalle estaba en una función de <a title="PHP" href="http://en.wikipedia.org/wiki/PHP">PHP</a> llamada <a title="php function extract" href="http://es.php.net/manual/es/function.extract.php" target="_blank">extract,</a> dentro de <a title="KumbiaPHP web &amp; app Framework" href="http://www.kumbiaphp.com">kumbiaphp framework</a> se utiliza esta dicha función en el core ya que el framework implementa las <strong><em>variables de instancia</em></strong> (algo muy parecido de <a title="Rails" href="http://en.wikipedia.org/wiki/Ruby_on_Rails">Rails</a>), es decir todo lo que llame en mi controlador <strong><em>$this-&gt;var</em></strong> o sean atributos públicos, en la vista los tengo disponible como <strong><em>$var</em></strong>, volviendo al punto esta funcion nos permite hacer lo antes dicho pero recibe ciertos parámetros uno es unas constantes entre ellas <span class="term"><strong><em>EXTR_OVERWRITE</em></strong> (</span><span class="simpara">Si hay colisión, sobrescribe la variable existente</span><span class="term">) nosotros decidimos sacar la constante porque en la documentación Oficial de PHP dice claro lo siguiente:</span></p>
<blockquote><p><em>Si no se especifica </em><em><tt class="parameter">tipo_extraccion</tt> , se asume que      vale EXTR_OVERWRITE.</em></p></blockquote>
<p>Bien como sabemos el xdebug nos da mucha información y la misma nos decía que el &#8220;cuello de botella&#8221; estaba allí ya que tomamos un profiler de la versión anterior y los tiempos eran totalmente distintos en ese punto. viendo en detalle la función <em><strong>extract </strong></em>decidí olvidar lo que dice el manual de PHP y pasar de forma implícita el tipo de extracción en este caso <span class="term"><strong><em>EXTR_OVERWRITE, </em></strong>una vez hecho el cambio vuelvo a correr el benchmark y como por arte de magia ahora obtengo los resultados esperados la nueva estructura ha causado efecto en velocidad y esta ~10 #req/seg por encima respecto a la <span style="text-decoration: line-through;">vieja estructura</span>.<br />
</span></p>
<p><strong><span class="term">Conclusión.</span></strong></p>
<p><span class="term">Tal como dice el titulo del post no hay que confiarse de lo que dicen algunos manual, ya que pueden ocurrir excepciones como la que comente aqui. En el caso descrito fue detectado este detalle porque se hizo uso de las <em>buenas prácticas</em> de desarrollo y de las herramientas disponibles y el turno fue para una que muchos obvian <a title="Xdebug " href="http://www.xdebug.org">(xdebug)</a>, que si le damos el uso correcto podemos ganar mucho en nuestros desarrollos.</span></p>
<p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fcachi.temiga.org%2F2009%2F05%2F17%2Fno_te_confies_de_todo_lo_que_dice_el_manual_de_php%2F&amp;linkname=No%20te%20confies%20de%20todo%20lo%20que%20dice%20el%20manual%20de%20PHP"><img src="http://cachi.temiga.org/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a> </p>]]></content:encoded>
			<wfw:commentRss>http://cachi.temiga.org/2009/05/17/no_te_confies_de_todo_lo_que_dice_el_manual_de_php/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Filter un misterio de PHP.</title>
		<link>http://cachi.temiga.org/2009/02/16/filter-un-misterio-de-php/</link>
		<comments>http://cachi.temiga.org/2009/02/16/filter-un-misterio-de-php/#comments</comments>
		<pubDate>Tue, 17 Feb 2009 02:58:32 +0000</pubDate>
		<dc:creator>CaChi</dc:creator>
				<category><![CDATA[PHP5]]></category>
		<category><![CDATA[Planeta Linux]]></category>
		<category><![CDATA[Programación]]></category>
		<category><![CDATA[Buenas Prácticas]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programing]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://cachi.temiga.org/?p=253</guid>
		<description><![CDATA[Todas las aplicaciones (Web, Escritorio, Consola) dependen que datos externos para crear una salida o iniciar un proceso, estos datos pueden venir desde un usuario u otra aplicación (WebService, formulario, etc&#8230;) por eso la premisa #1 de todo desarrollador debe: Filtrar todos los datos externos El filtrado de datos es una de las piedras angulares]]></description>
			<content:encoded><![CDATA[<p><a href="http://cachi.temiga.org/wp-content/uploads/filter.gif"><img class="alignleft" title="Filter" src="http://cachi.temiga.org/wp-content/uploads/filter.gif" alt="" width="115" height="186" /></a>Todas las aplicaciones (Web, Escritorio, Consola) dependen que datos externos para crear una salida o iniciar un proceso, estos datos pueden venir desde un usuario u otra aplicación (<a href="http://en.wikipedia.org/wiki/Web_service">WebService</a>, formulario, etc&#8230;) por eso la premisa #1 de todo desarrollador debe:</p>
<blockquote><p><em>Filtrar todos los datos externos</em></p></blockquote>
<p>El filtrado de datos es una de las piedras angulares en cualquier aplicación en el tema de seguridad, independientemente del lenguaje donde se trabaje. <a href="http://www.php.net">PHP</a> proporciona una amplia gama de herramientas y funciones para filtrar o validar los datos, pero a diferencia de otros lenguajes, no tiene funciones estándar para filtrar los datos (como cgi de perl).</p>
<p>La extensión <em><a title="Filter" href="http://us3.php.net/manual/hu/ref.filter.php" target="_self">Filter</a></em> llena este vacío y viene a suplir muchas expresiones regulares que son extremadamente lentas para validar formatos y datos de entradas, estas son muchas de las bondades de <em>PHP</em> que muchos desarrolladores no suelen utilizar y que vienen a ser parte de las <strong><em>buenas practicas</em></strong> de desarrollo sobre este lenguaje.</p>
<p>Este componente cuenta con constantes que representan los filtros a ser aplicados y ademas estos se pueden aplicar sobre <a title="Arrays PHP" href="http://ve2.php.net/manual/es/function.array.php" target="_blank">array&#8217;s</a> conocidos (POST, GET, COOKIE, etc) de manera que se vuelve flexible, para este tipo de validaciones y/o sanamiento de los datos de entrada, veamos unos ejemplos.</p>
<p>imaginemos que enviamos por <a title="$_GET" href="http://us3.php.net/manual/hu/reserved.variables.php#reserved.variables.get" target="_self">$_GET</a> un dato que lo hemos llamado &#8216;mode&#8217;</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'mode'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">is_numeric</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'mode'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;'mode' no es un entero&quot;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;'mode' es un entero&quot;</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">return</span> <span style="color: #009900;">&#40;</span>int<span style="color: #009900;">&#41;</span><span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'mode'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Ahora utilizando el <em>Filter</em> <a title="filter_input" href="http://ve2.php.net/manual/es/function.filter-input.php" target="_self">filter_input</a></p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$mode</span> <span style="color: #339933;">=</span> <span style="color: #990000;">filter_input</span><span style="color: #009900;">&#40;</span>INPUT_GET<span style="color: #339933;">,</span> <span style="color: #0000ff;">'mode'</span><span style="color: #339933;">,</span> FILTER_VALIDATE_INT<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #000088;">$mode</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;'mode' no es un entero&quot;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;mode es: <span style="color: #006699; font-weight: bold;">$mode</span>&quot;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">return</span> <span style="color: #000088;">$mode</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Ya podemos apreciar que nuestro código se limpia y si le hacemos un <em><a title="benchmark" href="http://en.wikipedia.org/wiki/Benchmark_(computing)">benchmark</a></em> seguramente también será mas rápido ;-)</p>
<h3>Consideraciones sobre los filtros</h3>
<ul>
<li><em>Santizing(limpieza) filtros</em>, Permitir o denegar los caracteres de una cadena, siempre retorna una cadena</li>
<li><em>Filtros Lógicos</em>, Conoce los formatos devuelve el tipo esperado de éxito.</li>
</ul>
<h3>Un formulario, aplicando filtros lógicos.</h3>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>form action<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;example.php&quot;</span> method<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;post&quot;</span><span style="color: #339933;">&gt;</span>
    Ingrese su Edad<span style="color: #339933;">:</span>
<span style="color: #339933;">&lt;</span>input name<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;age&quot;</span> size<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;2&quot;</span> <span style="color: #339933;">/&gt;</span>
<span style="color: #339933;">&lt;</span>input name<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;submit&quot;</span> type<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;submit&quot;</span> value<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;Ir&quot;</span> <span style="color: #339933;">/&gt;</span>
<span style="color: #339933;">&lt;/</span>form<span style="color: #339933;">&gt;</span></pre></div></div>

<p>Y el script que procesa esta información seria:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">filter_has_var</span><span style="color: #009900;">&#40;</span>INPUT_POST<span style="color: #339933;">,</span> <span style="color: #0000ff;">'submit'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'Se envió el form'</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000088;">$age</span> <span style="color: #339933;">=</span> <span style="color: #990000;">filter_input</span><span style="color: #009900;">&#40;</span>INPUT_POST<span style="color: #339933;">,</span> <span style="color: #0000ff;">'age'</span><span style="color: #339933;">,</span> FILTER_VALIDATE_INT<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">is_null</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$age</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;La 'edad' es un campo requerido!&quot;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">elseif</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$age</span> <span style="color: #339933;">===</span> <span style="color: #009900; font-weight: bold;">FALSE</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'Ingrese una edad valida'</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'Bienvenido.'</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Bien como vemos solo validamos que la <em>edad</em> sea un numero entero, pero existen algunos filtros que soportan <em><strong>options</strong></em> para que las validaciones sean mas precisas. Ahora la <em>edad</em> debe pasar la condición que debe estar entre un rango entre 7 y 77. veamos la utilización con el código anterior.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">filter_has_var</span><span style="color: #009900;">&#40;</span>INPUT_POST<span style="color: #339933;">,</span> <span style="color: #0000ff;">'submit'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'Se envió el form'</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000088;">$age</span> <span style="color: #339933;">=</span> <span style="color: #990000;">filter_input</span><span style="color: #009900;">&#40;</span>INPUT_POST<span style="color: #339933;">,</span> <span style="color: #0000ff;">'age'</span><span style="color: #339933;">,</span> FILTER_VALIDATE_INT<span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'options'</span><span style="color: #339933;">=&amp;</span>gt<span style="color: #339933;">;</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'min_range'</span><span style="color: #339933;">=&amp;</span>gt<span style="color: #339933;">;</span><span style="color: #cc66cc;">7</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'max_range'</span><span style="color: #339933;">=&amp;</span>gt<span style="color: #339933;">;</span><span style="color: #cc66cc;">77</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">is_null</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$age</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;La 'edad' es un campo requerido!&quot;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">elseif</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$age</span> <span style="color: #339933;">===</span> <span style="color: #009900; font-weight: bold;">FALSE</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'Ingrese una edad valida'</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'Bienvenido.'</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<h3>Un formulario, aplicando filtros Santizing.</h3>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>form action<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;example01.php&quot;</span> method<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;post&quot;</span><span style="color: #339933;">&gt;</span>
    Ingrese su Nombre<span style="color: #339933;">:</span>
<span style="color: #339933;">&lt;</span>input name<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;name&quot;</span> size<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;50&quot;</span> <span style="color: #339933;">/&gt;</span>
<span style="color: #339933;">&lt;</span>input name<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;submit&quot;</span> type<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;submit&quot;</span> value<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;Ir&quot;</span> <span style="color: #339933;">/&gt;</span>
<span style="color: #339933;">&lt;/</span>form<span style="color: #339933;">&gt;</span></pre></div></div>

<p>Y script que lo procesa&#8230;</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">filter_has_var</span><span style="color: #009900;">&#40;</span>INPUT_POST<span style="color: #339933;">,</span> <span style="color: #0000ff;">'submit'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'Se envió el form'</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000088;">$name</span> <span style="color: #339933;">=</span> <span style="color: #990000;">filter_input</span><span style="color: #009900;">&#40;</span>INPUT_POST<span style="color: #339933;">,</span> <span style="color: #0000ff;">'name'</span><span style="color: #339933;">,</span> FILTER_SANITIZE_STRING<span style="color: #339933;">,</span> FILTER_FLAG_STRIP_LOW<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">is_null</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$name</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;El 'nombre' es un campo requerido!&quot;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Bienvenido, <span style="color: #006699; font-weight: bold;">$name</span>&quot;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>En PHP 5.x esta extensión viene por defecto.</p>
<p>Por último dejo un post de <a title="PHPPro" href="http://phpro.org/tutorials/Filtering-Data-with-PHP.html" target="_blank">PHPPro</a> donde servirá de guía para muchos, de manera que escalemos nuestras formas de validar datos.</p>
<p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fcachi.temiga.org%2F2009%2F02%2F16%2Ffilter-un-misterio-de-php%2F&amp;linkname=Filter%20un%20misterio%20de%20PHP."><img src="http://cachi.temiga.org/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a> </p>]]></content:encoded>
			<wfw:commentRss>http://cachi.temiga.org/2009/02/16/filter-un-misterio-de-php/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Prof. Charlatan + Buenas Prácticas PHP + Parte I</title>
		<link>http://cachi.temiga.org/2009/02/07/prof-charlatan-buenas-practicas-php-parte-i/</link>
		<comments>http://cachi.temiga.org/2009/02/07/prof-charlatan-buenas-practicas-php-parte-i/#comments</comments>
		<pubDate>Sat, 07 Feb 2009 05:20:43 +0000</pubDate>
		<dc:creator>CaChi</dc:creator>
				<category><![CDATA[PHP5]]></category>
		<category><![CDATA[Programación]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programing]]></category>

		<guid isPermaLink="false">http://cachi.temiga.org/?p=221</guid>
		<description><![CDATA[Este termino comencé a ver una materia que se llama Procesamiento de Datos (Programación PHP) y es triste ver como un profesor le cae a mentira a un grupo de alumnos, que en vez de dedicarse &#8220;enseñar&#8221;, busca &#8220;sorprender&#8221; a un conglomerado, como se que esto dará mucho que hablar hoy comienzo una serie de]]></description>
			<content:encoded><![CDATA[<div class="mceTemp">
<dl class="wp-caption alignleft" style="width: 210px;">
<dt class="wp-caption-dt"><a href="http://cachi.temiga.org/wp-content/uploads/melkor_20061012_pirata.jpg"><img title="Pirata" src="http://cachi.temiga.org/wp-content/uploads/melkor_20061012_pirata.jpg" alt="Pirata" width="200" height="160" /></a></dt>
</dl>
</div>
<p>Este termino comencé a ver una materia que se llama <strong>Procesamiento de Datos</strong> (Programación <a title="PHP" href="http://es.wikipedia.org/wiki/Php" target="_self">PHP</a>) y es triste ver como un profesor le cae a mentira a un grupo de alumnos, que en vez de dedicarse &#8220;enseñar&#8221;, busca &#8220;sorprender&#8221; a un conglomerado, como se que esto dará mucho que hablar hoy comienzo una serie de post donde rescatare las carencia de este profesor, por razones obvias no daré su nombre (Espero lea este post profesor) y que <strong>NO</strong> se consideran como buenas prácticas de desarrollo en <a title="PHP" href="http://es.wikipedia.org/wiki/Php" target="_blank">PHP</a>.</p>
<p>Aclaro que <em>No</em> es un <em>Flame</em> contra este profesor, son simplemente aclaratorias que desde mi modesto punto de vista no puede quedar &#8220;impune&#8221; de la misma forma sirva para incentivar a las personas y/o alumnos(hasta al mismo profesor) a buscar información antes de decirla y/o creerle a cualquiera y mas en el área de la programación debido a que existe mucha información en la web.</p>
<p>Hay cosas de &#8220;ABC&#8221; que cualquier desarrollador de aplicaciones web debería tener claro, en este caso para <a title="PHP" href="http://es.wikipedia.org/wiki/Php" target="_blank">PHP</a> y es que las aplicaciones web de hoy día necesitan ir rápido, y rápido no se traduce es hacer códigos pequeños sino en implementar buenas prácticas.</p>
<h2>En Plena Clase</h2>
<p>El profesor explico como instalar <a title="Apache" href="http://es.wikipedia.org/wiki/Servidor_HTTP_Apache" target="_blank">Apache</a> (En windows XP :-P) pero nunca dijo porque se usaría Apache? y no otro por ejemplo <a href="http://en.wikipedia.org/wiki/Internet_Information_Services">IIS</a>, <a title="Cherokee" href="http://en.wikipedia.org/wiki/Cherokee_HTTP_Server" target="_blank">Cherokee</a>, etc. Ya por aquí considero que empezó mal porque como pedagogo (que no tiene nada) debió explicar esto, no conforme, comienza a dar la explicación de instalar <a title="Zend Studio" href="http://www.zend.com/en/products/studio/" target="_blank">Zend Studio</a> (un <a title="IDE" href="http://en.wikipedia.org/wiki/Integrated_development_environment" target="_blank">IDE</a> privativo)y luego dice como &#8220;<a href="http://en.wikipedia.org/wiki/Crack_(software)" target="_blank">crackearlo</a>&#8221; (profesor tenga ética y no sea &#8220;pisa bandera&#8221;) otro error, esto se puede decir entre amigos pero NO en una clase.</p>
<p>Bien, después del <em>bla bla bla</em>, llega a un punto donde comienza hablar de rutas en los archivos, es decir hacer los <strong>include &#8216;../mi_ruta/archivo.php&#8217;</strong>, y dice que las rutas relativas son mejores (aquí explote) y hago una pregunta, <em>Profesor que es mas optimo rutas Relativas o Absolutas?</em> la barbarie! el profesor contesto Relativas, caigo en un intercambio de palabras donde le dije que era falso y ahora explico porque.</p>
<p><strong>Las rutas absolutas son mas optimas</strong>, como dije en un principio hay que hacer <em>aplicaciones web rápidas</em> y algo tan simple como hacer un <strong>include</strong> de una ruta relativa se paga caro en tiempo de ejecución, porque se perderá <em>mas</em> tiempo resolviendo la ruta, es decir crear el arbol de directorio porque el compilador de <a title="PHP" href="http://es.wikipedia.org/wiki/Php" target="_blank">PHP</a> no es que hará un simple <em>cd ../mi_ruta/archivo.php</em> no no no, el compilador construye la ruta completa del <strong>archivo.php</strong> hará algo como <strong>/var/www/mi_ruta/archivo.php</strong>.</p>
<p>Luego que le comente lo anterior con otras palabras pero la idea sigue siendo la misma, el profesor en cuestión me alega que me imaginase que tuviera muchos archivo dentro del proyecto que desarrollo, por favor con mas razón se debe <strong>utilizar rutas absolutas</strong> por el simple hecho que serán mas archivos los que se procesaran en la ejecución de la aplicación (profe esto es sentido común).<a title="PHP" href="http://es.wikipedia.org/wiki/Php" target="_blank"><br />
</a></p>
<p>Pero no todo es malo el profesor dentro de todo lo que comento en cuatro (04) horas de clases académicas (45min C/U) unas de las pocas que considero que acertó fue en el manejo de las comillas dobles y simple, cuando en <a title="PHP" href="http://es.wikipedia.org/wiki/Php" target="_blank">PHP</a> colocamos comillas dobles el compilador asumirá que existen variable ($var) dentro del string, solo que con comillas simples se ignoran las variables dentro del string pero le falto decir que es mas rápido.</p>
<p>ejemplo:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$tmp</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'aaaaaaaaaaaaaaaaaaaa'</span><span style="color: #339933;">;</span><span style="color: #666666; font-style: italic;">//rápido</span>
<span style="color: #000088;">$tmp</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;aaaaaaaaaaaaaaaaaaaa&quot;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//lento</span></pre></div></div>

<h2>Conclusiones.</h2>
<p>Estas carencias son casi que normales (aunque no deberia ser así) entre los desarrolladores <em>en cualquier lenguaje</em> y es porque muy pocos se preocupan por hacer <a title="Profiler y Debug" href="http://cachi.temiga.org/2008/04/08/instalando-xdebug-en-debian-lenny/" target="_blank">profiler y debug</a> o simples <a title="Benchmark" href="http://es.wikipedia.org/wiki/Benchmark" target="_blank">benchmark</a> para encontrar <span class="serif">bottlenecks (cuellos de botella) dentro de nuestro código, con esto quiero decir que lo que se dice dentro de este post no lo invente yo, la práctica da la razón y utilizar las mejores prácticas nos hace mejor desarrollador(existen deferencias entre desarrollador y programador).</span></p>
<p><span class="serif">Leer: <a title="Regla 20/80" href="http://cachi.temiga.org/2008/08/30/la-regla-2080-buenas-practicas-de-desarrollo-parte-ii/" target="_blank">Regla 20/80</a><br />
</span></p>
<p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fcachi.temiga.org%2F2009%2F02%2F07%2Fprof-charlatan-buenas-practicas-php-parte-i%2F&amp;linkname=Prof.%20Charlatan%20%2B%20Buenas%20Pr%C3%A1cticas%20PHP%20%2B%20Parte%20I"><img src="http://cachi.temiga.org/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a> </p>]]></content:encoded>
			<wfw:commentRss>http://cachi.temiga.org/2009/02/07/prof-charlatan-buenas-practicas-php-parte-i/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
