<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="wordpress/2.0.5" -->
<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/"
	>

<channel>
	<title>Silici0 :: Blog</title>
	<link>http://www.rafaelcunha.com</link>
	<description>Php, JS, JQuery, Ajax e +++</description>
	<pubDate>Tue, 09 Mar 2010 22:05:03 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.0.5</generator>
	<language>en</language>
			<item>
		<title>Doctrine ORM</title>
		<link>http://www.rafaelcunha.com/2009/08/07/doctrine-orm/</link>
		<comments>http://www.rafaelcunha.com/2009/08/07/doctrine-orm/#comments</comments>
		<pubDate>Fri, 07 Aug 2009 13:56:53 +0000</pubDate>
		<dc:creator>silici0</dc:creator>
		
		<category>Informatica</category>

		<category>php</category>

		<guid isPermaLink="false">http://www.rafaelcunha.com/2009/08/07/doctrine-orm/</guid>
		<description><![CDATA[Agora vou falar da ultima novidade nos meus projetos, o uso do Doctrine como camada de abstração de dados. Ele foi criado com base do Hybernation do Java, assim absorvendo bastante idéias e design patterns, eu não conheço profundamente todos os recursos, mas o pouco que tenho usado ja tem me ajudado muito, vou descrever [...]]]></description>
			<content:encoded><![CDATA[<p>Agora vou falar da ultima novidade nos meus projetos, o uso do Doctrine como camada de abstração de dados. Ele foi criado com base do Hybernation do Java, assim absorvendo bastante idéias e design patterns, eu não conheço profundamente todos os recursos, mas o pouco que tenho usado ja tem me ajudado muito, vou descrever o que ele pode fazer, como tem me ajudado e mais para frente uns tutoriais mais específicos com códigos do Doctrine.</p>
<p>O Doctrine é um object-relational mapper ou ORM (mapeador de objeto-relacional), a idéia fica por conta de acessar todos os seus dados mySQL ou de banco através de objetos PHP, chega de querys complexas e gambiarras com php-mySQL. Ele segue o design pattern criado pelo Martin Fowler de <a href="http://pt.wikipedia.org/wiki/Active_record" onclick="javascript:pageTracker._trackPageview('/outbound/article/http://pt.wikipedia.org/wiki/Active_record');" target="_blank">Active Record</a> (isso mesmo o mesmo criador do MVC), que é a idéia de objeto ser a referência da tabela.</p>
<p>Exemplo:</p>
<div class="igBar"><span id="lphp-4"><a href="#" onclick="javascript:showCodeTxt('php-4'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-4">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF9933; font-style:italic;">// Para salvar algo na tabela usuario</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$User</span> = <span style="color:#000000; font-weight:bold;">new</span> Usuario<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$User</span>-&gt;<span style="color:#006600;">nome</span> = <span style="color:#FF0000;">'nome do usuario'</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$User</span>-&gt;<span style="color:#006600;">usuario</span> = <span style="color:#FF0000;">'usuario'</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$User</span>-&gt;<span style="color:#006600;">senha</span> = <span style="color:#FF0000;">'senha123dificil'</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$User</span>-&gt;<span style="color:#006600;">save</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Agora com essa idéia você pode escrever Query SQL com OO, o dialeto do doctrine é o DQL (Doctrine Query Language), que é possível trazer todos objetos relacionais (tabelas relacionais) de forma bem simples, vejamos um exemplo de DQL e SQL:</p>
<p>DQL:</p>
<div class="igBar"><span id="lphp-5"><a href="#" onclick="javascript:showCodeTxt('php-5'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-5">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$q</span> = Doctrine_Query::<span style="color:#006600;">create</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; -&gt;<span style="color:#006600;">from</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'User u'</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; -&gt;<span style="color:#006600;">leftJoin</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">'u.Phonenumbers p'</span><span style="color:#006600; font-weight:bold;">&#41;</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>SQL:</p>
<div class="igBar"><span id="lphp-6"><a href="#" onclick="javascript:showCodeTxt('php-6'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-6">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">SELECT </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">u.id <span style="color:#616100;">AS</span> u__id, </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">u.is_active <span style="color:#616100;">AS</span> u__is_active, </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">u.is_super_admin <span style="color:#616100;">AS</span> u__is_super_admin, </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">u.first_name <span style="color:#616100;">AS</span> u__first_name, </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">u.last_name <span style="color:#616100;">AS</span> u__last_name, </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">u.username <span style="color:#616100;">AS</span> u__username, </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">u.password <span style="color:#616100;">AS</span> u__password, </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">u.type <span style="color:#616100;">AS</span> u__type, </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">u.created_at <span style="color:#616100;">AS</span> u__created_at, </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">u.updated_at <span style="color:#616100;">AS</span> u__updated_at, </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">p.id <span style="color:#616100;">AS</span> p__id, </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">p.user_id <span style="color:#616100;">AS</span> p__user_id, </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">p.phonenumber <span style="color:#616100;">AS</span> p__phonenumber </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">FROM user u </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">LEFT <a href="http://www.php.net/join" onclick="javascript:pageTracker._trackPageview('/outbound/article/http://www.php.net/join');"><span style="color:#000066;">JOIN</span></a> phonenumber p ON u.id = p.user_id </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Ainda tem muito mais características, vale a pena dar uma olhada no próprio site do <a href="http://www.doctrine-project.org/" onclick="javascript:pageTracker._trackPageview('/outbound/article/http://www.doctrine-project.org/');" target="_blank">Doctrine</a> ou usar o google, mas so com essas definições nos podemos dizer que:</p>
<ul>
<li>Vamos programar mais rápido</li>
<li>Queries ficarão mais simples que o SQL</li>
<li>Não nos preucuparemos mais com nosso Model</li>
<li>Trabalharemos com Objetos e listas de queries</li>
</ul>
<p>Entao apartir da definição do Schema da base de dados o próprio Doctrine cria todos os códigos de Model ai podemos livremente instanciar Objetos relacionais e salvar, deletar e afins.<!--89f56645a608757cf094256ba5ddb23e--><!--2e6da248f4a2faf797796987200fb6db--></p>
]]></content:encoded>
			<wfw:commentRss>http://www.rafaelcunha.com/2009/08/07/doctrine-orm/feed/</wfw:commentRss>
		</item>
		<item>
		<title>IDE php</title>
		<link>http://www.rafaelcunha.com/2009/08/03/ide-php/</link>
		<comments>http://www.rafaelcunha.com/2009/08/03/ide-php/#comments</comments>
		<pubDate>Mon, 03 Aug 2009 13:21:23 +0000</pubDate>
		<dc:creator>silici0</dc:creator>
		
		<category>Informatica</category>

		<category>php</category>

		<guid isPermaLink="false">http://www.rafaelcunha.com/2009/08/03/ide-php/</guid>
		<description><![CDATA[IDE para programadores PHP, que também muitas vezes escrevem códigos Javascript, CSS e xHTML. Essa parece ser uma busca sem fim, quando você começa procurar uma IDE aberta, free e que atenda a necessidade de otimização de tempo na hora de programar, sem falar se pensarmos que muitas vezes é necessário ela ser multi-plataforma para [...]]]></description>
			<content:encoded><![CDATA[<p>IDE para programadores PHP, que também muitas vezes escrevem códigos Javascript, CSS e xHTML. Essa parece ser uma busca sem fim, quando você começa procurar uma IDE aberta, free e que atenda a necessidade de otimização de tempo na hora de programar, sem falar se pensarmos que muitas vezes é necessário ela ser multi-plataforma para que possamos programar em ambientes diferentes com o mesmo rendimento... bom, não vou entrar no mérito para discutir ferramentas totalmente windows como o dreamweaver, onde é tem essas características de view, você é programador, seu objetivo é visualizar somente código, com essa prática acertar sempre no resultado do conteúdo, otimizando cada vez mais o tempo de codificação, para isso esqueça ficar visualizando o resultado na sua ide frequentemente.</p>
<p>Para todos e alguns problemas mais descrito acima nós temos a IDE <a href="http://www.aptana.com" onclick="javascript:pageTracker._trackPageview('/outbound/article/http://www.aptana.com');" target="_blank">Aptana Studio</a> para PHP, o qual tenho usado para programar seja, em windows, linux (uso ubuntu a 3 anos) ou mac (ainda vou ser um futuru usuário), que traz diversas otimizações para programar. Segue a lista de algumas características:</p>
<ul>
<li>Assistente de Código, famoso por autocompletar o código para você, trazer o docs dos parametros dos métodos e funções (isso ocorre com seus próprios objetos, aqueles escritos por você.</li>
<li>Colorização de código, o que ajuda horrores para identificar suas concatenações, funções e toda organização do código, totalmente customizavel.</li>
<li>Refactoring: automatize códigos, você pode customizar tags e códigos para que o Aptana apatir de uma tag escreva um código inteiro para você, exemplo ecre switch/ e ele retorna uma estrutura completa para você.</li>
<li>Geração de código, retornando para você códigos comuns, getters and setters e dentre outros...</li>
<li>Outline do seus objetos, assim você consegue pular para um método ou propriedades sem perder tempo.</li>
<li>PhpDoc generator, gerando toda documentação do seu código.</li>
</ul>
<p><center><img src="http://gueschla.com/labs/green-chaud/php_small.png" alt="Green Chad showcase" /></center></p>
<p>Essas são algumas caracteristicas, ainda existe o <a href="http://www.aptana.tv" onclick="javascript:pageTracker._trackPageview('/outbound/article/http://www.aptana.tv');" target="_blank">aptana.tv</a> onde você pode conferir dicas em video como aumentar seu rendimento, fica a dica de um theme chamado <a href="http://gueschla.com/labs/green-chaud/" onclick="javascript:pageTracker._trackPageview('/outbound/article/http://gueschla.com/labs/green-chaud/');" target="_blank">Green Chaud</a> que eu uso e é bastante agradável.<!--afdfac41dc64f46eb4e51fbff118bbc6--></p>
]]></content:encoded>
			<wfw:commentRss>http://www.rafaelcunha.com/2009/08/03/ide-php/feed/</wfw:commentRss>
		</item>
		<item>
		<title>PHP o básico</title>
		<link>http://www.rafaelcunha.com/2008/12/17/php-o-basico/</link>
		<comments>http://www.rafaelcunha.com/2008/12/17/php-o-basico/#comments</comments>
		<pubDate>Wed, 17 Dec 2008 20:11:28 +0000</pubDate>
		<dc:creator>silici0</dc:creator>
		
		<category>Informatica</category>

		<category>php</category>

		<category>Tutorial</category>

		<guid isPermaLink="false">http://www.rafaelcunha.com/2008/12/17/php-o-basico/</guid>
		<description><![CDATA[Estudando um pouco de PHP, tentarei escrever alguns tutoriais e exemplificar estudos para a Certificação da Zend, començando claro pelo básico...
PHP Tags
Como PHP foi desenhado para ser um processador de textos é necessário tags para identificar o código do PHP, tudo fora destas TAGS será interpretado como saída de texto, vejamos as tags :

Standard Tags
PLAIN [...]]]></description>
			<content:encoded><![CDATA[<p>Estudando um pouco de PHP, tentarei escrever alguns tutoriais e exemplificar estudos para a Certificação da Zend, començando claro pelo básico...</p>
<h3>PHP Tags</h3>
<p>Como PHP foi desenhado para ser um processador de textos é necessário tags para identificar o código do PHP, tudo fora destas TAGS será interpretado como saída de texto, vejamos as tags :</p>
<ul>
<li><strong>Standard Tags</strong>
<div class="igBar"><span id="lcode-14"><a href="#" onclick="javascript:showCodeTxt('code-14'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-14">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;?php ... <span style="">codigo</span> ... ?&gt; </div>
</li>
</ol>
</div>
</div>
</div>
<p></li>
<li><strong>Short Tags</strong>
<div class="igBar"><span id="lcode-15"><a href="#" onclick="javascript:showCodeTxt('code-15'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-15">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;? ... <span style="">codigo</span> ... ?&gt; </div>
</li>
</ol>
</div>
</div>
</div>
<p></li>
<li><strong>Script Tags</strong>
<div class="igBar"><span id="lcode-16"><a href="#" onclick="javascript:showCodeTxt('code-16'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-16">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;script language =<span style="color:#CC0000;">"php'&gt; ... codigo ... &lt;/script&gt; </span></div>
</li>
</ol>
</div>
</div>
</div>
<p></li>
<li><strong>ASP Tags</strong>
<div class="igBar"><span id="lcode-17"><a href="#" onclick="javascript:showCodeTxt('code-17'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-17">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;% ... <span style="">codigo</span> ... %&gt; </div>
</li>
</ol>
</div>
</div>
</div>
<p></li>
</ul>
<p>O padrão é o <strong>Standard Tags</strong> que no caso não é possivel desabilita-las, por isso é a mais recomendada para o uso.</p>
<h3>Data Types (Tipos de dados)</h3>
<ul>
<li>bollean</li>
<li>int</li>
<li>float</li>
<li>string</li>
</ul>
<p>No caso de valores número temos :</p>
<ul>
<li><strong>Decimal </strong><br />
Ex.: 10; -11; 1452;</li>
<li><strong>Octal </strong><br />
Conotação base 8 No php todo número começado com 0 (zero) é um número octal, veja sobre em : <a href="http://pt.wikipedia.org/wiki/Sistema_octal" onclick="javascript:pageTracker._trackPageview('/outbound/article/http://pt.wikipedia.org/wiki/Sistema_octal');">Wikipedia</a>. Ex.: 0660; 0100;</li>
<li><strong>Hexadecimal</strong><br />
Conotação base 16, saiba sobre no <a href="http://pt.wikipedia.org/wiki/Sistema_hexadecimal" onclick="javascript:pageTracker._trackPageview('/outbound/article/http://pt.wikipedia.org/wiki/Sistema_hexadecimal');">Wikipedia</a>. Ex.: 0x123; 0xA;</li>
</ul>
<h3>Variaveis Variaveis</h3>
<p>É este o nome mesmo, é a variavel que o nome é contido em outra variavel, como assim? Veja o exemplo:</p>
<div class="igBar"><span id="lcode-18"><a href="#" onclick="javascript:showCodeTxt('code-18'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-18">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">$name = <span style="color:#CC0000;">'foo'</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">$$name = <span style="color:#CC0000;">'bar'</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">echo $foo;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF9933; font-style:italic;">// imprime 'bar' </span></div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>No caso de uma função:</p>
<div class="igBar"><span id="lcode-19"><a href="#" onclick="javascript:showCodeTxt('code-19'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-19">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">function minhaFunc<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; echo <span style="color:#CC0000;">'minhaFunc'</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">$f = <span style="color:#CC0000;">'minhaFunc'</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">$f<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF9933; font-style:italic;">// chama a função minhaFunc </span></div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<h3>Constantes</h3>
<p>Constantes são variaveis de valores imutaveis e podem ser acessados de quaquer escopo dentro do PHP, uma boa prática é declar-las somente com letras maiúsculas. Veja os exemplos:</p>
<div class="igBar"><span id="lcode-20"><a href="#" onclick="javascript:showCodeTxt('code-20'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-20">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">define<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC0000;">'EMAIL_PADRAO'</span>, <span style="color:#CC0000;">'silici0@gmail.com'</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">echo EMAIL_PADRAO;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF9933; font-style:italic;">// imprime 'silici0@gmail.com'</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">if<span style="color:#006600; font-weight:bold;">&#40;</span> EMAIL_PADRAO == <span style="color:#CC0000;">'silici0@gmail.com'</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;<span style="color:#FF9933; font-style:italic;">// Neste caso entra no if (TRUE)</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>É isso ae, uma parte do básico esta ae, bom estudos para vocês, espero que pessoal aprenda e utilizem, ainda tem mais básico, mas vamos deixar para um próximo post.<!--475e40fbec3c2027acd6345f37fc502b--><!--0f3bb8e180ad4bd83cfd877049c51d7c--><!--650fbffd322cd3f1f5c8c9d6f332cd2a--></p>
]]></content:encoded>
			<wfw:commentRss>http://www.rafaelcunha.com/2008/12/17/php-o-basico/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Layout de diretorios</title>
		<link>http://www.rafaelcunha.com/2008/11/21/layout-de-diretorios/</link>
		<comments>http://www.rafaelcunha.com/2008/11/21/layout-de-diretorios/#comments</comments>
		<pubDate>Fri, 21 Nov 2008 14:02:01 +0000</pubDate>
		<dc:creator>silici0</dc:creator>
		
		<category>Informatica</category>

		<category>php</category>

		<category>Tutorial</category>

		<guid isPermaLink="false">http://www.rafaelcunha.com/2008/11/21/layout-de-diretorios/</guid>
		<description><![CDATA[Bom, eu irei na verdade aqui dar sequencia ao meu modelo de aplicação MVC, se você não conhece pode dar uma lida neste Post, seguindo a ideia vamos agora partir da ideia do layout de diretorios para nossa aplicação, usando Url Amigaveis, primeiro temos que ter em mente que poderemos ter diversos App, ou aplicativos [...]]]></description>
			<content:encoded><![CDATA[<p>Bom, eu irei na verdade aqui dar sequencia ao meu modelo de aplicação MVC, se você não conhece pode dar uma lida neste <a href="http://www.rafaelcunha.com/2008/09/12/mvc-model-view-controller/" >Post</a>, seguindo a ideia vamos agora partir da ideia do layout de diretorios para nossa aplicação, usando Url Amigaveis, primeiro temos que ter em mente que poderemos ter diversos App, ou aplicativos que funcionarão como modulos (ex: Admin, Cliente, Contas, RH e assim vai) e para cada modulo estará o modelo MVC ( ou MVP ).</p>
<p>Iremos separar também nossas libs (Library ou bibliotecas no bom português), para que possamos atualiza-las independente do sistema (modulos) que tivermos.</p>
<p>Iremos também separar uma pasta chamada var que serão as variaves do sistema, são arquivos que irão sendo atualizados mudados conforme o tempo de site (no meu caso os templates do smarty e outros arquivos como xml) e iremos separar os arquivos chamados publicos (que são aqueles arquivos onde as pessoas podem visualizar e roubar de você), no caso são arquivos JS, CSS, Imagens e coisas do genêro.</p>
<p>Então por enquanto teremos :</p>
<div class="igBar"><span id="lcode-27"><a href="#" onclick="javascript:showCodeTxt('code-27'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-27">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">/app</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">/lib</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">/publico</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">/var </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Colocando modulos no app e pensando que teremos o modulo rais teremos em MVC a seguinte estrutura :</p>
<div class="igBar"><span id="lcode-28"><a href="#" onclick="javascript:showCodeTxt('code-28'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-28">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">O acesso a estas pastas será travada no .<span style="">htaccess</span> para maior segurança</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">/app/</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">/app/config</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">/app/controller</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">/app/model</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">/app/view</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">-----&gt; <span style="">Exemplo</span> modulo Admin</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">/app/Admin</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">/app/Admin/config</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">/app/Admin/controller</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">/app/Admin/model</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">/app/Admin/view </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>No caso ainda no view utilizando um sistema de templates para separar codigo de tela, eu tenho mais duas pastas que irão separar mais codigo, em vez de construir inputs, selects, e alguns outros na tela com codigo, dou preferencia para buscar uma classe que possa criar para min e eu retornar o codigo pronto para o template, assim separando o que é um codigo contrutor.</p>
<div class="igBar"><span id="lcode-29"><a href="#" onclick="javascript:showCodeTxt('code-29'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-29">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">/app/view/analizador &lt;- arquivos que somente trazem dados para o view</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#40;</span>arquivos so escritos em php, são contrutores<span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">/app/view/helpers &lt;- arquivos de carater padrão entre telas <span style="color:#006600; font-weight:bold;">&#40;</span> topo.<span style="">tpl</span>,</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">banner.<span style="">tpl</span>, menu.<span style="">tpl</span> +++ <span style="color:#006600; font-weight:bold;">&#41;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Pensando agora no resto da estrutra, as bibliotecas ( /lib )  o que iremos ter ? No meu caso eu terei algumas bibliotecas suporte e principalmente aqui uma biblioteca (camada de persistência - Base de dados), veja como fica:</p>
<div class="igBar"><span id="lcode-30"><a href="#" onclick="javascript:showCodeTxt('code-30'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-30">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">O acesso a estas pastas será travada no .<span style="">htaccess</span> para maior segurança</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">/lib/</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">/lib/commom &lt;-- classes de uso comum durante todo o sistema <span style="color:#006600; font-weight:bold;">&#40;</span>ex. <span style="">classe</span> envioMail<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>, Upload<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>, Conexao<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">/lib/MDB2&nbsp; &lt;--&nbsp; classe camada de persistência</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">/lib/smarty</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">/lib/a j a x </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>O layout da publico é super simples e podemos criar diversas regras no .htaccess para moderamos o uso desta estrutura</p>
<div class="igBar"><span id="lcode-31"><a href="#" onclick="javascript:showCodeTxt('code-31'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-31">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">/publico</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">/publico/images</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">/publico/scripts</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">/publico/styles </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>No meu caso a var que contém os dados de teamplates compilados e cache deles.</p>
<div class="igBar"><span id="lcode-32"><a href="#" onclick="javascript:showCodeTxt('code-32'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-32">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">Estrutura para dados que possam ser alterados, também protegido por htaccess</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">/var </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">/var/tpl_cache</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">/var/tpl_compiled </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>É isso ai pessoal, logo mais vou continuar escrevendo dos htaccess de cada pasta e do index para nos acessarmos tudo isso com um unico arquivo só. Ficaria muito grande esse index e access aqui neste mesmo texto, então ficamos para a próxima.<!--5ff37f95cbe7e8990ca47b91d617b8a9--><!--d1aa63a4ff88e74e202024914bb2c5d4--></p>
]]></content:encoded>
			<wfw:commentRss>http://www.rafaelcunha.com/2008/11/21/layout-de-diretorios/feed/</wfw:commentRss>
		</item>
		<item>
		<title>phpConf 2008</title>
		<link>http://www.rafaelcunha.com/2008/11/18/phpconf-2008/</link>
		<comments>http://www.rafaelcunha.com/2008/11/18/phpconf-2008/#comments</comments>
		<pubDate>Tue, 18 Nov 2008 14:30:20 +0000</pubDate>
		<dc:creator>silici0</dc:creator>
		
		<category>Informatica</category>

		<category>Trabalho</category>

		<category>php</category>

		<category>Tutorial</category>

		<guid isPermaLink="false">http://www.rafaelcunha.com/2008/11/18/phpconf-2008/</guid>
		<description><![CDATA[E lá vamos nós, ou melhor dizendo eu, confirmada minha presença nos 3 dias da php Conference Brasil 2008, vou deixar aqui a programação que pretendo assistir e participar, espero ver vocês lá.

Quinta feira :
No período da manhã vou assitir a palestra/curso sobre SOA com o César Schneider.
No período da tarde irei voltar a trabalhar, [...]]]></description>
			<content:encoded><![CDATA[<p>E lá vamos nós, ou melhor dizendo eu, confirmada minha presença nos 3 dias da php Conference Brasil 2008, vou deixar aqui a programação que pretendo assistir e participar, espero ver vocês lá.</p>
<p><a href="http://www.phpconf.com.br" onclick="javascript:pageTracker._trackPageview('/outbound/article/http://www.phpconf.com.br');"><img src="http://www.phpconf.com.br/includes/templates/padrao/imagens/logo.gif" alt="phpConf" /></a></p>
<p>Quinta feira :</p>
<p>No período da manhã vou assitir a palestra/curso sobre SOA com o César Schneider.<br />
No período da tarde irei voltar a trabalhar, hehehe.</p>
<p>Sexta-feira :</p>
<p>O que eu gostaria de assistir é "Camadas do desenvolvimento Web", "Vulnerabilidades", "OpenSocial", "SPL", "PHP Doc"... é algumas das palestras que me interessam ainda estou incerto do que irá me fazer melhor.</p>
<p>Sábado :</p>
<p>Sábado é um grande mistério se irei aparecer, ainda mais em relação as palestras, veremos até la o que irá aconteçer.<!--45fdd72f880b5716f4a1e1223bfd4c5e--><!--649c77c57bd01cd202b2339a0839c281--></p>
]]></content:encoded>
			<wfw:commentRss>http://www.rafaelcunha.com/2008/11/18/phpconf-2008/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Links</title>
		<link>http://www.rafaelcunha.com/2008/11/14/links/</link>
		<comments>http://www.rafaelcunha.com/2008/11/14/links/#comments</comments>
		<pubDate>Fri, 14 Nov 2008 16:36:27 +0000</pubDate>
		<dc:creator>silici0</dc:creator>
		
		<category>Festas</category>

		<category>Informatica</category>

		<category>Mente</category>

		<category>php</category>

		<guid isPermaLink="false">http://www.rafaelcunha.com/2008/11/14/links/</guid>
		<description><![CDATA[Bom, como eu não tenho custume de colocar links na categoria de Links hoje eu vou fazer um post para isso, para alguns links interessantes que sempre utilizo, sejam eles no trabalho ou por mera diversão, quem sabe é algo útil ou divertido a você também.

Segundo a vivo o firefox não suporta HTML
PHP Manual ( [...]]]></description>
			<content:encoded><![CDATA[<p>Bom, como eu não tenho custume de colocar links na categoria de Links hoje eu vou fazer um post para isso, para alguns links interessantes que sempre utilizo, sejam eles no trabalho ou por mera diversão, quem sabe é algo útil ou divertido a você também.</p>
<ul>
<li><a href="http://geek42.org/2008/11/14/segundo-a-vivo-firefox-nao-suporta-html/" onclick="javascript:pageTracker._trackPageview('/outbound/article/http://geek42.org/2008/11/14/segundo-a-vivo-firefox-nao-suporta-html/');">Segundo a vivo o firefox não suporta HTML</a></li>
<li><a href="http://docs.php.net/docs.php" onclick="javascript:pageTracker._trackPageview('/outbound/article/http://docs.php.net/docs.php');">PHP Manual ( Melhor lugar de consulta php )</a></li>
<li><a href="http://ondras.zarovi.cz/sql/demo/" onclick="javascript:pageTracker._trackPageview('/outbound/article/http://ondras.zarovi.cz/sql/demo/');">SQL design ( para modelar bases de dados )</a></li>
<li><a href="http://www.blueshoes.org/en/developer/php_cheat_sheet/" onclick="javascript:pageTracker._trackPageview('/outbound/article/http://www.blueshoes.org/en/developer/php_cheat_sheet/');">Tabela php de comparações</a> <a href="http://blog.duodraco.com/" onclick="javascript:pageTracker._trackPageview('/outbound/article/http://blog.duodraco.com/');">by duodraco</a></li>
<li><a href="http://silici0.labrute.fr/" onclick="javascript:pageTracker._trackPageview('/outbound/article/http://silici0.labrute.fr/');">Vamos a luta ?</a></li>
<li><a href="http://www.pmob.co.uk/temp/star-rating2.htm" onclick="javascript:pageTracker._trackPageview('/outbound/article/http://www.pmob.co.uk/temp/star-rating2.htm');">Votação com estrelas somente com CSS</a></li>
</ul>
<p><!--e5ac197bbcb99b2b8b760401a4e56937--><!--ea015e618a62a71e33a4df52bde476ff--><!--83ac545f356c99d41dfc56a1243c40ec--></p>
]]></content:encoded>
			<wfw:commentRss>http://www.rafaelcunha.com/2008/11/14/links/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
