<?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>El Blog del Antonio</title>
	<atom:link href="http://www.ramirezcobos.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.ramirezcobos.com</link>
	<description>Programming Web with PHP, CSS, Javascript and ∞</description>
	<lastBuildDate>Sun, 21 Apr 2013 09:45:45 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Yiinitializr: The Library</title>
		<link>http://www.ramirezcobos.com/2013/04/21/yiinitializr-the-library/</link>
		<comments>http://www.ramirezcobos.com/2013/04/21/yiinitializr-the-library/#comments</comments>
		<pubDate>Sun, 21 Apr 2013 09:45:45 +0000</pubDate>
		<dc:creator>Antonio Ramirez</dc:creator>
				<category><![CDATA[On The Web]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Portfolio]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Yii]]></category>
		<category><![CDATA[Yiinitializr]]></category>
		<guid isPermaLink="false">http://www.ramirezcobos.com/?p=1160</guid>
		<description><![CDATA[Introduction For those who have created a project boilerplate with Yiinitializr site, you will find that is not just a project boilerplate what you just downloaded. Within the boilerplate comes a library named: Yiinitializr (not very original I know). The classes within this tiny library are simple, yet powerful, and will help you build your own [...]]]></description>
				<content:encoded><![CDATA[<h1>Introduction</h1>
<p>For those who have created a project boilerplate with <a href="http://yiinitializr.2amigos.us/" target="_blank">Yiinitializr site</a>, you will find that is not just a project boilerplate what you just downloaded. Within the boilerplate comes a library named: <a href="http://yiinitializr.2amigos.us/" target="_blank">Yiinitializr</a> (not very original I know). The classes within this tiny library are simple, yet powerful, and will help you build your own project setup, the one that really fits your needs for your <a href="http://www.yiiframework.com" target="_blank">Yii </a>application.</p>
<h1>The Classes Explained</h1>
<p>The <a href="http://yiinitializr.2amigos.us/" target="_blank">Yiinitializr</a> classes will help boost your application installation with ease and also to run <a href="http://www.yiiframework.com" target="_blank">Yii</a> applications from its bootstrap files on a much cleaner way that the framework currently proposes. Let&#8217;s have a look at the following example:</p>
<pre class="brush: plain; title: ; notranslate">
// if installed via composer (pretty neat right?)
require('./../../common/lib/vendor/autoload.php');
Yiinitializr\Helpers\Initializer::create('./../', 'frontend', array(
    // will override frontend configuration file
    __DIR__ .'/../../common/config/main.php', // merged with
    __DIR__ .'/../../common/config/env.php', // merged with
    __DIR__ .'/../../common/config/local.php' // merged with
))-&gt;run();
</pre>
<h2>Yiinitializr\Cli namespace</h2>
<p>This namespace brings utilities to interact with the terminal or &#8216;cli&#8217;. <a href="https://github.com/nramenta/clio">A free beer goes to mr <strong>nramenta</strong> for them</a>.</p>
<h3>Yiinitializr\Cli\Console</h3>
<p>The Console class helps you to display information to the console. You probably, think that it as easy as to &#8216;echo&#8217; from any of your Command components that are runed by the Yiic command and is true, but this class comes with some magic:</p>
<h4>Color</h4>
<pre class="brush: plain; title: ; notranslate">Console::output('this is %rcolored%n and %Bstyled%n');</pre>
<h4>Prompt</h4>
<pre class="brush: plain; title: ; notranslate">$db_host = Console::prompt('database host', ['default' =&gt; 'localhost']);</pre>
<h4>Selection</h4>
<pre class="brush: plain; title: ; notranslate">
$opt = Console::select('Do you love Yii?',
    ['y' =&gt; 'yes', 'n' =&gt; 'no', 'a' =&gt; 'all']
);
</pre>
<h4>Confirm</h4>
<pre class="brush: plain; title: ; notranslate">$sure = Console::confirm('are you sure?');</pre>
<h4>Work</h4>
<pre class="brush: plain; title: ; notranslate">
&lt;?php
Console::stdout('Working ... ');
Console::work(function($socket) { // $socket is optional, defaults to a spinner
    $n = 100;
    for ($i = 1; $i &lt;= $n; $i++) {
        // do whatever it is you need to do
        socket_write($socket, &quot;[$i/$n]\n&quot;);
        sleep(1); // sleep is good for you
    }
});
Console::stdout(&quot;%g[DONE]%n\n&quot;);
</pre>
<h3>Yiinitializr\Cli\Daemon</h3>
<p>The Daemon class provides helpers for starting and killing daemonized processes.</p>
<pre class="brush: plain; title: ; notranslate">
&lt;?php
use Yiinitializr\Cli\Daemon;
if (Daemon::isRunning('/path/to/process.pid')) {
    echo &quot;daemon is running.\n&quot;;
} else {
    echo &quot;daemon is not running.\n&quot;;
}
</pre>
<h2>Yiinitializr\Composer namespace</h2>
<p>I should just call this namespace <strong>Tobias Schmunk</strong> as he was the master guru behind this class, the only thing I did was to read the e-book of <strong><a href="http://getcomposer.org">Composer</a></strong> and studied every single piece of his fabulous <a href="http://www.phundament.com/"><strong>Phundament</strong></a> application boilerplate. To modify the class to become of more general usage out of <strong><a href="http://www.phundament.com/">Phundament</a> </strong>has no much credit.</p>
<p>Here, we find the Callback class, a super useful class that will allow you to execute commands prior, post <strong>Composer</strong> extensions installations or updates. It makes use of the scripts configuration feature and even though for the current templates found at <strong><a href="http://yiinitializr.2amigos.us">Yiinitializr Site</a></strong> the only thing it does is to call <strong>Yiic migrate</strong> commands but I am sure that you are already thinking of its possibilities.</p>
<h2>Yiinitializr\Helpers namespace</h2>
<h3>Yiinitializer\Helpers\ArrayX</h3>
<p>This class includes cool functions to work with arrays. It contains one cloned from <strong>CMap</strong>, the <strong>mergeArray</strong> function, as we require this method in order to combine the different configuration files before the Yii application is even included. A clear example of it you find it on <strong>Yiinitializr/config/console</strong>, which is the file that where you set the configuration of your console application to run Composer callbacks. It has also</p>
<h3>Yiinitializr\Helpers\Config</h3>
<p>It reads the configuration file and provides an interface to access the settings. It also, when working with different environments, writes the &#8220;<em>env.lock</em>&#8221; file. By creating this file, it tells the <strong>Initializr</strong> helper class to not recreate the env.php configuration file of the environment selected. If anybody wishes to recreate them, in order to make use of other environment configuration file (ie. stage vs local), the coder just needs to delete the &#8220;<em>env.lock</em>&#8221; file from the <strong>Yiinitializr/config</strong> folder.</p>
<h4>The configuration file</h4>
<p>As with Yii, you need to go through a bit of configuration settings if you wish to handle your project structure initializing setup with <code>Yiinitializr</code>. But don&#8217;t worry, is not going to be too hard, the following is an example configuration file:</p>
<pre class="brush: plain; title: ; notranslate">
\\ where am i?
$dirname = dirname(__FILE__);
\\ where is the application folder?
$app = $dirname . '/../../..';
\\ where is the root?
$root = $app . '/..';
return array(
    // yii configurations
    'yii' =&gt; array(
        // where is the path of the yii framework?
        // On this example we have installed yii with composer
        // and as it is used after composer installation, we
        // can safely point to the vendor folder.
        'path' =&gt; $app . '/lib/vendor/yiisoft/yii/framework'
    ),
    // yiinitializr specific settings
    'yiinitializr' =&gt; array(
        // config folders
        'config' =&gt; array(
            // we just need the console settings
            // On this example, and due that I used environments
            // i created a custom console.php app for
            // Yiinitializr\Composer\Callbak class
            'console' =&gt; $dirname . '/console.php'
        ),
        // application structure settings
        'app' =&gt; array(
            // where is the root?
            'root' =&gt; $root,
            // directories setup
            'directories' =&gt; array(
                // where are the different configuration files settings?
                'config' =&gt; array(
                    // 'key' is the configuration name (see above init example)
                    'main' =&gt; $app . '/config',
                    'console' =&gt; $app . '/config',
                    'test' =&gt; $app . '/config'
                ),
                // where are my runtime folders?
                'runtime' =&gt; array(
                    // heads up! only the folder location as &quot;/config&quot; will be
                    // appended
                    $app
                ),
                'assets' =&gt; array(
                    // where to write the &quot;assets folders&quot;?
                    $root . '/www'
                )
            ),
            'files' =&gt; array(
                // files to merge the main configuration file with
                // initializr will merge it automatically
                'config' =&gt; array(
                    'main' =&gt; array('env', 'local'),
                    'console' =&gt; array('env', 'local'),
                )
            )
        ),
    )
);
</pre>
<h3>Yiinitializr\Helpers\Initializer</h3>
<p>This class requires a little bit more attention and I hope you take a bit of time reading its code to truly understand what it does. Improving this class, can make our lives easier with <a href="http://www.yiiframework.com" target="_blank">Yii</a> and I explain why:</p>
<ol>
<li>It tries to solve the problem with YII_DEBUG dynamically (no need to hardcode true|false on your index.php bootstrap file) &#8211; check the <a href="https://github.com/2amigos/yiinitializr/blob/master/Helpers/Initializer.php#L134" target="_blank">setOptions function</a>.</li>
<li>It creates all necessary read+write folders like runtime and assets (Yiinitializr works in conjunction with Composer but I am pretty sure some of you are already thinking on why is not <a href="http://www.yiiframework.com" target="_blank">Yii</a> creating those folders when they are not found? Initializer class may provide the solution:<strong> if it doesn&#8217;t exist, build it don&#8217;t fail on error!</strong>)</li>
<li>Automatically merges different configuration files that you may have for the different type of applications &#8211; check the <a href="https://github.com/2amigos/yiinitializr/blob/master/Helpers/Initializer.php#L62" target="_blank">config function</a>.</li>
</ol>
<h1>Final Notes</h1>
<p>We truly hope at <a href="http://2amigos.us" target="_blank">2amigOS!</a> that you find this library as useful as it is for us. We do not expect that this procedure should be implemented at <a href="http://www.yiiframework.com" target="_blank">Yii</a>&#8216;s core but some of the features included in this small library are certainly something to consider on its future releases. Happy Yii coding!</p>
<h1 id="hh1">References</h1>
<ul>
<li><a href="http://yiinitializr.2amigos.us/">Yiinitializr</a></li>
<li><a href="https://github.com/2amigos/yiinitializr">Yiinitializr Components</a></li>
<li><a href="https://github.com/tonydspaniard/yiinitializr-basic">The Basic Template</a></li>
<li><a href="https://github.com/tonydspaniard/yiinitializr-intermediate">The Intermediate Template</a></li>
<li><a href="https://github.com/tonydspaniard/yiinitializr-advanced">The Advanced Template</a></li>
</ul>
<p><center><br />
</center></p>
<a href="http://twitter.com/?status=RT%20%40%3A%20Yiinitializr%3A%20The%20Library%20-%20El%20Blog%20del%20Antonio%20http%3A%2F%2Fwww.ramirezcobos.com%2F2013%2F04%2F21%2Fyiinitializr-the-library%2F" class="tweet-this" ><img src="http://www.ramirezcobos.com/wp-content/plugins/simple-tweet/img/tweet.gif" title="Tweet this!" alt="Tweet this!" />Tweet this!</a>]]></content:encoded>
			<wfw:commentRss>http://www.ramirezcobos.com/2013/04/21/yiinitializr-the-library/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Yiinitializr: Maximum acceleration for your Yii project start!</title>
		<link>http://www.ramirezcobos.com/2013/04/12/yiinitializr-maximum-acceleration-for-your-yii-project-start/</link>
		<comments>http://www.ramirezcobos.com/2013/04/12/yiinitializr-maximum-acceleration-for-your-yii-project-start/#comments</comments>
		<pubDate>Fri, 12 Apr 2013 22:28:05 +0000</pubDate>
		<dc:creator>Antonio Ramirez</dc:creator>
				<category><![CDATA[On The Web]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[Yii]]></category>
		<guid isPermaLink="false">http://www.ramirezcobos.com/?p=1148</guid>
		<description><![CDATA[The history&#8230; we remember the days when we thought that YiiBoilerplate was a good fit for any project. They were good days, but we were being naive. Every project has different needs, and it’s those needs that set the requirements. Also, lets be realistic, if you were to develop a project where only the frontend UI [...]]]></description>
				<content:encoded><![CDATA[<p><br/><br/>The history&#8230; we remember the days when we thought that <strong><a href="https://github.com/clevertech/yiiboilerplate">YiiBoilerplate</a></strong> was a good fit for any project. They were good days, but we were being naive.</p>
<p>Every project has different needs, and it’s those needs that set the requirements. Also, lets be realistic, if you were to develop a project where only the frontend UI with a small admin section was needed, <strong><a href="http://yiinitializr.2amigos.us">Yiinitializr</a></strong> was overkill. In the end, people had to remove unneeded folders, the configuration was unnecessarily complex, a lot of people were not certain where to place the components and there were many other issues.</p>
<p>At <strong><a href="http://2amigos.us">2amigOS!</a></strong> we were slamming our heads down on our keyboards trying to figure out what was the best way to provide a project boilerplate that could fit everyones needs. We soon realized and agreed that <strong><a href="http://getcomposer.org">composer</a> </strong>was the best way to go as a dependency manager (special shout-out thanks to Mr Tobias Schmunk, the guy behind <strong><a href="http://phundament.com">Phundament</a></strong> for his great work and ideas), but we did not want to provide a fixed structure nor a set of extensions, again. Otherwise, we would just be putting a fresh coat of paint on the same problems. We wanted to give the power back to the developer to pick and choose based on their own needs. You know your project the most, so you should be able to set your own desired folder structure. You should be able to select which extensions you want to have pre-installed. And that, my amigos, is how <strong><a href="http://yiinitializr.2amigos.us">Yiinitializr</a></strong> was born!</p>
<p><a href="http://www.ramirezcobos.com/2013/04/12/yiinitializr-maximum-acceleration-for-your-yii-project-start/4y9rs/" rel="attachment wp-att-1153"><img class="aligncenter size-large wp-image-1153" alt="4Y9RS" src="http://www.ramirezcobos.com/wp-content/uploads/2013/04/4Y9RS-1024x306.png" width="640" height="191" /></a></p>
<p><strong><a href="http://yiinitializr.2amigos.us">Yiinitializr</a></strong> is technically still in beta (?). Why? Because we believe that we need your feedback, yes you, from the <strong><a href="http://www.yiiframework.com">Yii</a></strong> community, to make <strong><a title="Yiinitializr" href="http://yiinitializr.2amigos.us">Yiinitializr</a></strong> right for all of us. You’re going to be using it, often (c’mon, you know you will&#8230;), so why not have a say in whether it’s enough or not&#8230; in what else it should or should not provide.</p>
<p>Okay, okay.. enough talk&#8230; now, let’s see how this baby works!</p>
<p><strong><a title="Yiinitializr" href="http://yiinitializr.2amigos.us">Yiinitializr</a></strong> is extremely easy to use. It is composed of only one page that will ask you three simple things:</p>
<p>1. What template type do you want to use? Basic, Intermediate or Advanced</p>
<p><a href="http://www.ramirezcobos.com/2013/04/12/yiinitializr-maximum-acceleration-for-your-yii-project-start/captura-de-pantalla-2013-04-13-a-las-00-05-32/" rel="attachment wp-att-1150"><img class="aligncenter size-medium wp-image-1150" alt="Captura de pantalla 2013-04-13 a la(s) 00.05.32" src="http://www.ramirezcobos.com/wp-content/uploads/2013/04/Captura-de-pantalla-2013-04-13-a-las-00.05.32-300x72.png" width="300" height="72" /></a><br />
2. Which extensions do you want pre-installed? Just search and select&#8230; really.. that’s all&#8230; no kidding&#8230; cool, huh?</p>
<p><a href="http://www.ramirezcobos.com/2013/04/12/yiinitializr-maximum-acceleration-for-your-yii-project-start/0wdkw/" rel="attachment wp-att-1151"><img class="aligncenter size-medium wp-image-1151" alt="0WDkW" src="http://www.ramirezcobos.com/wp-content/uploads/2013/04/0WDkW-300x149.png" width="300" height="149" /></a><br />
3. Okay&#8230; maybe we misspoke&#8230; it’s really 3 steps; not questions. Download your finished project boilerplate!</p>
<p><a href="http://www.ramirezcobos.com/2013/04/12/yiinitializr-maximum-acceleration-for-your-yii-project-start/icvy8/" rel="attachment wp-att-1152"><img class="aligncenter size-medium wp-image-1152" alt="ICVY8" src="http://www.ramirezcobos.com/wp-content/uploads/2013/04/ICVY8-300x147.png" width="300" height="147" /></a><br />
4. What? Step 4? Maybe we can’t count, but you need to know what to do with the file you just downloaded, right? Well, here’s what you need to do:</p>
<p>Unzip, wherever you want your project to be, then (no, we are not going to tell you how to setup your database configuration. This is just a gentle reminder that you need to do that next&#8230;). Ahem&#8230; make your database configurations.<br />
Now, run the following commands inside the unzipped project’s root:</p>
<pre class="brush: php; title: ; notranslate">
// make sure you have the latest version of composer
php composer.phar self-update
// run your installation
php composer.phar install
</pre>
<p>Now, relax and love it! (or hate us, but keep it to yourself&#8230; really, all that negativity focused on us? We’re amigos! Come and share in the enchiladas&#8230; click on the docs below the templates to go to that github place and vent there&#8230;)</p>
<p>So, now you’re saying, “yeah, man&#8230; that is simple, but what are the template differences?”. We thought you’d never ask:</p>
<ul>
<li><strong>Basic</strong>: The small in scope project. Is your project just a frontend, or maybe a frontend with an admin interface? Well, this is the basic one, and it contains only <strong>/app</strong> and <strong>/www</strong>. Yes, you can still choose the extensions you want.</li>
<li><strong>Intermediate</strong>: Your needs are maybe a little more complex than the basic offers, but you don’t want to go crazy. This one is closest to the structure you might be familiar with from <strong><a href="http://www.yiiframework.com/wiki/374/yiiboilerplate-setup-a-professional-project-structure-in-seconds/">YiiBoilerplate</a></strong>, but it’s much much lighter. Intermediate has a good solid structure. It contains: <strong>/backend</strong>, <strong>/common</strong>, <strong>/console</strong> and <strong>/frontend</strong>, and this structure will work for most of your robust applications. Need more?</li>
<li><strong>Advanced</strong>: Now you’re talking! The advanced structure adds on the <strong>/api</strong> directory for your web services. Need we say more? Got ideas of world domination? It starts here! <img src='http://www.ramirezcobos.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </li>
</ul>
<p><strong>“But I want more details!”</strong> Yes, we agree, and this a great point to start the share of some knowledge. We know that once you download any of the template boilerplates you’ll start wondering what’s going on here. What the heck is this way of initializing applications? Check out the yiic.php or the index.php scripts within any of the application’s folder. See what we are doing. There is another surprise extension within, the Yiinitializr components. A set of classes that makes for a really easy way you can configure and install a project.</p>
<p>More documentation and discussion will be coming&#8230; we promise. We just wanted to let you play and react a little, first.</p>
<p><center><br />
<br />
</center></p>
<a href="http://twitter.com/?status=RT%20%40%3A%20Yiinitializr%3A%20Maximum%20acceleration%20for%20your%20Yii%20project%20start%21%20-%20El%20Blog%20del%20Antonio%20http%3A%2F%2Fwww.ramirezcobos.com%2F2013%2F04%2F12%2Fyiinitializr-maximum-acceleration-for-your-yii-project-start%2F" class="tweet-this" ><img src="http://www.ramirezcobos.com/wp-content/plugins/simple-tweet/img/tweet.gif" title="Tweet this!" alt="Tweet this!" />Tweet this!</a>]]></content:encoded>
			<wfw:commentRss>http://www.ramirezcobos.com/2013/04/12/yiinitializr-maximum-acceleration-for-your-yii-project-start/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>YiiBooster: How to implement files and images upload on TbRedactor Widget</title>
		<link>http://www.ramirezcobos.com/2013/03/26/yiibooster-how-to-implement-files-and-images-upload-on-tbredactor-widget/</link>
		<comments>http://www.ramirezcobos.com/2013/03/26/yiibooster-how-to-implement-files-and-images-upload-on-tbredactor-widget/#comments</comments>
		<pubDate>Tue, 26 Mar 2013 09:21:56 +0000</pubDate>
		<dc:creator>Antonio Ramirez</dc:creator>
				<category><![CDATA[How To]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Yii]]></category>
		<category><![CDATA[YiiBooster]]></category>
		<category><![CDATA[Tutorial]]></category>
		<guid isPermaLink="false">http://www.ramirezcobos.com/?p=1129</guid>
		<description><![CDATA[Introduction I have been requested to provide a tutorial on how to use the file upload feature of the TbRedactor widget, and even though I am no longer supporting the library due that the work belongs to Clevertech, I feel that I owe that to the Yii developers. So, here is the  tutorial. How to [...]]]></description>
				<content:encoded><![CDATA[<h2>Introduction</h2>
<p>I have been requested to provide a tutorial on how to use the file upload feature of the TbRedactor widget, and even though I am no longer supporting the library due that the work belongs to Clevertech, I feel that I owe that to the Yii developers. So, here is the  tutorial.</p>
<h2>How to do it</h2>
<p>As you know, if you try to use TbRedactor &#8220;out of the box&#8221; and if you click on the &#8220;insert image&#8221;, you will see a &#8220;popup window&#8221; as the following image:</p>
<p><a href="http://www.ramirezcobos.com/2013/03/26/yiibooster-how-to-implement-files-and-images-upload-on-tbredactor-widget/captura-de-pantalla-2013-03-24-a-las-15-34-57/" rel="attachment wp-att-1131"><img class="aligncenter size-medium wp-image-1131" alt="Captura de pantalla 2013-03-24 a la(s) 15.34.57" src="http://www.ramirezcobos.com/wp-content/uploads/2013/03/Captura-de-pantalla-2013-03-24-a-las-15.34.57-300x124.png" width="300" height="124" /></a></p>
<p>Not bad&#8230; but too plain. What about the really cool Fileupload shown on redactorJS site? How do we set it up? The answer is easier that you can imagine. In fact, the only thing that we need to tell the plugin is the URL address that will handle file and image upload processes.</p>
<pre class="brush: php; title: ; notranslate">
// with a TbActiveForm
echo $form-&gt;redactorRow(
    $model,
    'attribute_name',
    array(
       'class'=&gt;'span4',
       'rows'=&gt;5,
       'options'=&gt;array(
          'fileUpload' =&gt; $this-&gt;createUrl('site/testFileUpload'),
          'imageUpload' =&gt; $this-&gt;createUrl('site/testImageUpload'),
       )
    )
);
// as a widget
$this-&gt;widget('bootstrap.widgets.TbRedactorJs',
    array(
      'model'=&gt;$model,
      'attribute'=&gt;'attribute_name',
      'editorOptions'=&gt;array(
          'fileUpload' =&gt; $this-&gt;createUrl('site/testFileUpload'),
          'imageUpload' =&gt; $this-&gt;createUrl('site/testImageUpload'),
          'width'=&gt;'100%',
          'height'=&gt;'400px'
       )
    ));
</pre>
<p>As soon as we have that setup, the popup window will display differently:</p>
<div class="row-fluid">
<div class="span6">
<div id="attachment_1133" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.ramirezcobos.com/2013/03/26/yiibooster-how-to-implement-files-and-images-upload-on-tbredactor-widget/captura-de-pantalla-2013-03-26-a-las-09-49-56/" rel="attachment wp-att-1133"><img class="size-medium wp-image-1133" alt="Files Upload" src="http://www.ramirezcobos.com/wp-content/uploads/2013/03/Captura-de-pantalla-2013-03-26-a-las-09.49.56-300x228.png" width="300" height="228" /></a><p class="wp-caption-text">File Upload</p></div>
</div>
<div class="span6">
<div id="attachment_1136" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.ramirezcobos.com/2013/03/26/yiibooster-how-to-implement-files-and-images-upload-on-tbredactor-widget/captura-de-pantalla-2013-03-26-a-las-09-57-41/" rel="attachment wp-att-1136"><img class="size-medium wp-image-1136" alt="Images Upload" src="http://www.ramirezcobos.com/wp-content/uploads/2013/03/Captura-de-pantalla-2013-03-26-a-las-09.57.41-300x197.png" width="300" height="197" /></a><p class="wp-caption-text">Images Upload</p></div>
</div>
</div>
<div><span class="label label-warning">Important</span> How to handle file uploads is out of the scope of this tutorial. If you wish to know how to handle file uploads on the server from redactorJS, I highly recommend you <a title="Files upload" href="http://imperavi.com/redactor/docs/files/" target="_blank">to read the documentation at imperavi</a>.</div>
<p>But wait a minute, what about if we wish to insert an image that has been previously uploaded? If we look at the redactor&#8217;s site we find really cool thumbnail images to choose from. Well, is a bit tricky but not too hard. The only thing that you have to do is to provide a URL where to download the &#8220;json&#8221; file that will get the uploaded files and their location.</p>
<pre class="brush: php; title: ; notranslate">
// with a TbActiveForm
echo $form-&gt;redactorRow(
    $model,
    'attribute_name',
    array(
       'class'=&gt;'span4',
       'rows'=&gt;5,
       'options'=&gt;array(
          'fileUpload' =&gt; $this-&gt;createUrl('site/testFileUpload'),
          'imageUpload' =&gt; $this-&gt;createUrl('site/testImageUpload'),
          'imageGetJson'=&gt; $this-&gt;createUrl('site/testImageThumbs')
       )
    )
);
// as a widget
$this-&gt;widget('bootstrap.widgets.TbRedactorJs',
    array(
      'model'=&gt;$model,
      'attribute'=&gt;'attribute_name',
      'editorOptions'=&gt;array(
          'fileUpload' =&gt; $this-&gt;createUrl('site/testFileUpload'),
          'imageUpload' =&gt; $this-&gt;createUrl('site/testImageUpload'),
          'imageGetJson'=&gt; $this-&gt;createUrl('site/testImageThumbs')
          'width'=&gt;'100%',
          'height'=&gt;'400px'
       )
    ));
</pre>
<p>The following is an example action to return the thumbs and image information:</p>
<pre class="brush: php; title: ; notranslate">
public function actionTestUpload()
{
   echo json_encode(array(
        array(
           'thumb' =&gt; '/images/image1_thumb.png',
           'image' =&gt; '/images/image1_big.png',
           'title' =&gt; 'Title1', // optional
           'folder' =&gt; 'myFolder' // optional
        ),
        array(
           'thumb' =&gt; '/images/image2_thumb.png',
           'image' =&gt; '/images/image2_big.png',
           'title' =&gt; 'Title2', // optional
           'folder' =&gt; 'myFolder' // optional
        )
   ));
}
</pre>
<p>Obviously, the above example has to contain the right resources to work but the result would endup with something similar to the following:</p>
<div id="attachment_1139" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.ramirezcobos.com/2013/03/26/yiibooster-how-to-implement-files-and-images-upload-on-tbredactor-widget/captura-de-pantalla-2013-03-26-a-las-10-15-26/" rel="attachment wp-att-1139"><img class="size-medium wp-image-1139" alt="Images Choose" src="http://www.ramirezcobos.com/wp-content/uploads/2013/03/Captura-de-pantalla-2013-03-26-a-las-10.15.26-300x225.png" width="300" height="225" /></a><p class="wp-caption-text">Images Choose Option</p></div>
<h2>Further Reading</h2>
<ul>
<li><a href="http://imperavi.com/redactor/docs/settings/" target="_blank">Imperavi Redactor Doc Settings</a></li>
<li><a href="http://imperavi.com/redactor/docs/files/" target="_blank">Imperavi Redactor Doc Files Upload</a></li>
<li><a href="http://imperavi.com/redactor/docs/images/" target="_blank">Imperavi Redactor Doc Images Upload</a></li>
</ul>
<p><center><br />
<br />
</center></p>
<a href="http://twitter.com/?status=RT%20%40%3A%20YiiBooster%3A%20How%20to%20implement%20files%20and%20images%20upload%20on%20TbRedactor%20Widget%20-%20El%20Blog%20del%20Antonio%20http%3A%2F%2Fwww.ramirezcobos.com%2F2013%2F03%2F26%2Fyiibooster-how-to-implement-files-and-images-upload-on-tbredactor-widget%2F" class="tweet-this" ><img src="http://www.ramirezcobos.com/wp-content/plugins/simple-tweet/img/tweet.gif" title="Tweet this!" alt="Tweet this!" />Tweet this!</a>]]></content:encoded>
			<wfw:commentRss>http://www.ramirezcobos.com/2013/03/26/yiibooster-how-to-implement-files-and-images-upload-on-tbredactor-widget/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>YiiBooster: How to use TbFileUpload Widget</title>
		<link>http://www.ramirezcobos.com/2013/03/22/yiibooster-how-to-use-tbfileupload-widget/</link>
		<comments>http://www.ramirezcobos.com/2013/03/22/yiibooster-how-to-use-tbfileupload-widget/#comments</comments>
		<pubDate>Fri, 22 Mar 2013 10:48:19 +0000</pubDate>
		<dc:creator>Antonio Ramirez</dc:creator>
				<category><![CDATA[How To]]></category>
		<category><![CDATA[On The Web]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Yii]]></category>
		<category><![CDATA[YiiBooster]]></category>
		<category><![CDATA[Tutorial]]></category>
		<guid isPermaLink="false">http://www.ramirezcobos.com/?p=1124</guid>
		<description><![CDATA[Introduction The following wiki is to explain how to make use of the TbFileUpload widget from YiiBooster. I have received a couple of requests and I thought was worth writing a wiki for it. Usage Preparation First, we need to make sure we have a folder with write permissions, that will be the place where [...]]]></description>
				<content:encoded><![CDATA[<h2 id="hh0">Introduction</h2>
<p>The following wiki is to explain how to make use of the TbFileUpload widget from YiiBooster. I have received a couple of requests and I thought was worth writing a wiki for it.</p>
<h2 id="hh1">Usage</h2>
<h3 id="hh2">Preparation</h3>
<p>First, we need to make sure we have a folder with write permissions, that will be the place where we are going to save our uploaded files.</p>
<p>I normally create a <code>files</code> folder and I allocate it within my <code>www</code> one, that is where I keep my css, js, images files. So, even though you can place it where ever you wish and for the sake of the example, I will use the<code>files</code> folder name.</p>
<p>I also assume that you have configured a path alias that references the <code>files</code> folder. On this example, the path alias is <code>frontend.www.files</code>.</p>
<h3 id="hh3">Note</h3>
<ul>
<li>This demo only works if the MyModel class already includes the function getImageUrl($img_type=null). If not, comment the 2 lines inside the data array, where &#8216;url&#8217; and &#8216;thumbnail_url&#8217; are defined, to make the demo work</li>
<li>If the MyModel has a different name, it needs to be replaced 1-2 times inside the upload action</li>
<li>The url where we are going to upload our files =&gt; upload action</li>
</ul>
<p><em>Thanks <a href="http://www.yiiframework.com/user/9450/">Don Felipe</a></em></p>
<h3 id="hh4">Setup your model</h3>
<p>The way you handle validation on the server is up to you, the configuration I am going to provide now is just an example.</p>
<p>We are going to add one extra attribute to the model <code>picture</code>, which is going to hold any $_FILE type resource uploaded and validated when model is on <code>upload</code> scenario.</p>
<div>
<div>
<pre class="brush: php; title: ; notranslate">class MyModel extends CActiveRecord {
// ... more code here
/**
* This is the attribute holding the uploaded picture
* @var CUploadedFile
*/
public $picture;
// ... more code
/**
* @return array validation rules for model attributes.
*/
public function rules()
{
  return array(
    // ... more rules here
    array('picture', 'length', 'max' =&gt; 255, 'tooLong' =&gt; '{attribute} is too long (max {max} chars).', 'on' =&gt; 'upload'),
    array('picture', 'file', 'types' =&gt; 'jpg,jpeg,gif,png', 'maxSize' =&gt; 1024 * 1024 * 2, 'tooLarge' =&gt; 'Size should be less then 2MB !!!', 'on' =&gt; 'upload'),
    // ... more rules here
  );
}</pre>
</div>
</div>
<h3 id="hh5">Configuring the Widget</h3>
<p>To render the widget on your view is quite straightforward, the are a couple of things very important to configure:</p>
<ul>
<li>the url where we are going to upload our files</li>
<li>the file types we are going to accept and their maximum size</li>
</ul>
<p>Now, lets render it:</p>
<div>
<div>
<pre class="brush: php; title: ; notranslate">
&lt;?php $this-&gt;widget('bootstrap.widgets.TbFileUpload', array(
    'url' =&gt; $this-&gt;createUrl(&quot;my/upload&quot;),
    'model' =&gt; $model,
    'attribute' =&gt;'picture', // see the attribute?
    'multiple' =&gt; true,
    'options' =&gt; array(
    'maxFileSize' =&gt; 2000000,
    'acceptFileTypes' =&gt; 'js:/(\.|\/)(gif|jpe?g|png)$/i',
))); ?&gt;
</pre>
</div>
</div>
<h4>Handling Upload</h4>
<p>Everything is ready now but the controller. We have to configure the action that will handle the upload process. Here you go, the upload action of our controller -very, very basic &#8211; and not fully tested:</p>
<div>
<div>
<pre class="brush: php; title: ; notranslate">
class myController extends CController {
   // ... more code here&lt;/code&gt;&lt;/code&gt;/**
   * Handles resource upload
   * @throws CHttpException
   */
   public function actionUpload()
   {
      header('Vary: Accept');
      if (isset($_SERVER['HTTP_ACCEPT']) &amp;&amp;
      (strpos($_SERVER['HTTP_ACCEPT'], 'application/json') !== false))
      {
         header('Content-type: application/json');
      } else {
         header('Content-type: text/plain');
      }
      $data = array();
      $model = new MyModel('upload');
      $model-&amp;gt;picture = CUploadedFile::getInstance($model, 'picture');
      if ($model-&gt;picture !== null &amp;&amp; $model-&gt;validate(array('picture')))
      {
         $model-&gt;picture-&gt;saveAs(
            Yii::getPathOfAlias('frontend.www.files').'/'.$model-&gt;picture-&gt;name);
         $model&gt;file_name = $model-&gt;picture-&gt;name;
         // save picture name
         if( $model-&gt;save())
         {
            // return data to the fileuploader
            $data[] = array(
            'name' =&gt; $model-&gt;picture-&gt;name,
            'type' =&gt; $model-&gt;picture-&gt;type,
            'size' =&gt; $model-&gt;picture-&gt;size,
            // we need to return the place where our image has been saved
            'url' =&gt; $model-&gt;getImageUrl(), // Should we add a helper method?
            // we need to provide a thumbnail url to display on the list
            // after upload. Again, the helper method now getting thumbnail.
            'thumbnail_url' =&gt; $model-&gt;getImageUrl(MyModel::IMG_THUMBNAIL),
            // we need to include the action that is going to delete the picture
            // if we want to after loading
            'delete_url' =&gt; $this-&gt;createUrl('my/delete',
            array('id' =&gt; $model-&gt;id, 'method' =&gt; 'uploader')),
               'delete_type' =&gt; 'POST');
         } else {
               $data[] = array('error' =&gt; 'Unable to save model after saving picture');
         }
      } else {
         if ($model-&gt;hasErrors('picture'))
         {
            $data[] = array('error', $model-&gt;getErrors('picture'));
         } else {
            throw new CHttpException(500, &quot;Could not upload file &quot;. CHtml::errorSummary($model));
         }
      }
      // JQuery File Upload expects JSON data
      echo json_encode($data);
   }
   // .... more code here
} // end of controller
</pre>
</div>
</div>
<h2 id="hh6">Resources</h2>
<ul>
<li><a title="" href="http://blueimp.github.com/jQuery-File-Upload/">http://blueimp.github.com/jQuery-File-Upload/</a></li>
</ul>
<a href="http://twitter.com/?status=RT%20%40%3A%20YiiBooster%3A%20How%20to%20use%20TbFileUpload%20Widget%20-%20El%20Blog%20del%20Antonio%20http%3A%2F%2Fwww.ramirezcobos.com%2F2013%2F03%2F22%2Fyiibooster-how-to-use-tbfileupload-widget%2F" class="tweet-this" ><img src="http://www.ramirezcobos.com/wp-content/plugins/simple-tweet/img/tweet.gif" title="Tweet this!" alt="Tweet this!" />Tweet this!</a>]]></content:encoded>
			<wfw:commentRss>http://www.ramirezcobos.com/2013/03/22/yiibooster-how-to-use-tbfileupload-widget/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>2amigOS!</title>
		<link>http://www.ramirezcobos.com/2013/03/17/2amigos/</link>
		<comments>http://www.ramirezcobos.com/2013/03/17/2amigos/#comments</comments>
		<pubDate>Sun, 17 Mar 2013 21:02:26 +0000</pubDate>
		<dc:creator>Antonio Ramirez</dc:creator>
				<category><![CDATA[Ajax]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[Design]]></category>
		<category><![CDATA[How To]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[JQuery]]></category>
		<category><![CDATA[On The Web]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Portfolio]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[Yii]]></category>
		<category><![CDATA[News]]></category>
		<guid isPermaLink="false">http://www.ramirezcobos.com/?p=1112</guid>
		<description><![CDATA[Guys, the time has come when I had to make a move from freelance world to something more serious (even though the name of the company doesn&#8217;t sound like it ). I have left Clevertech for good. I have to recognize that I truly enjoyed working with them, always working on challenging tasks and interesting tasks [...]]]></description>
				<content:encoded><![CDATA[<p>Guys, the time has come when I had to make a move from freelance world to something more serious (even though the name of the company doesn&#8217;t sound like it <img src='http://www.ramirezcobos.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> ). I have left <a href="http://www.clevertech.biz">Clevertech</a> for good. I have to recognize that I truly enjoyed working with them, always working on challenging tasks and interesting tasks that made me be constantly up to date with new technologies (not much time to update the blog though!). Also, received great support when bringing up new ideas to the table, such as providing open source tools to improve internal operations and also help the Yii community. Thats how <a href="https://github.com/clevertech/YiiBoilerplate">YiiBoilerplate</a> and <a href="https://github.com/clevertech/Yiibooster">YiiBooster</a> were born. Yes, it was fun and I really appreciate every single moment spend with them. Nevertheless, the opportunity came to build my very own company and opportunities are not to run away nowadays.</p>
<p>So, I am not longer working for that great company nor I am longer available for a freelance work on a personal basis, from now on, everything should be contracted throughout my very own company: <a title="2amigOS! Consulting Corporation LLC" href="http://2amigos.us">2amigOS! Consulting Corporation LLC</a>. I know the name is quite long, but we wanted to have <a href="http://2amigos.us">2amigOS! </a>so badly, that it was the only way to get it. Hope you don&#8217;t mind <img src='http://www.ramirezcobos.com/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> </p>
<p>I&#8217;ve got a great partner, and we have great people working with us. The company was made with one and only purpose: <strong>to be happy</strong>. And we will do whatever we want and what we like in order to pursue that goal, for us and for our customers of course! Check out our philosophy:</p>
<blockquote><p><em>Taking our shared love for internet technology one-step further (and singing the whole way), an idea and work philosophy was born: <a href="http://2amigos.us">2amigOS!</a> We believe in honesty, simplicity in design and intuitiveness in use for building new applications or helping you with yours. We provide code reviews, application development services, data analysis and database architectural design. We are also strong supporters of the open-source community, and with that in mind we contribute to them, as often as possible while building ourselves a heavy arsenal of tools and libraries to get any project launched&#8230; This is not about work, and it is not about the money. It&#8217;s about creating great things together, yourself included&#8230; it&#8217;s about having fun realizing our dreams. In the end, we are just a couple of nerds that love building incredible things&#8230; </em></p>
<p><em>Who knew development could be so much fun? We did!</em></p></blockquote>
<p>How that it sounds? Great right? Our specialties are <strong>Code Review</strong>, <strong>Web Development</strong>, <strong>Data Analysis &amp; Design</strong>, <strong>Managed Hosting</strong>, and <strong>Training</strong>. More than enough&#8230; for now.</p>
<p>If you are a programmer and wish to be part of this, let me know, send me your <strong>github</strong> account or CV and you never know, we could be working together and having some fun with one of our customers&#8217; projects.</p>
<p>And if you are a want to become one of our customers and/or believe that we can help you achieve the development of your project/idea? Please, <a href="http://2amigos.us/site/contact">let us know</a> too, we will be very honest with you and tell you straight whether we are your team of people or not.</p>
<p>Cheers and thanks all for visiting my blog! I promise to keep it updated from now on (I have more time now <img src='http://www.ramirezcobos.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> )</p>
<p><center></center></p>
<a href="http://twitter.com/?status=RT%20%40%3A%202amigOS%21%20%20-%20El%20Blog%20del%20Antonio%20http%3A%2F%2Fwww.ramirezcobos.com%2F2013%2F03%2F17%2F2amigos%2F" class="tweet-this" ><img src="http://www.ramirezcobos.com/wp-content/plugins/simple-tweet/img/tweet.gif" title="Tweet this!" alt="Tweet this!" />Tweet this!</a>]]></content:encoded>
			<wfw:commentRss>http://www.ramirezcobos.com/2013/03/17/2amigos/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>YiiBooster &#8211; Make it Gorgeous, do it Fast.</title>
		<link>http://www.ramirezcobos.com/2012/10/04/yiibooster-make-it-gorgeous-do-it-fast/</link>
		<comments>http://www.ramirezcobos.com/2012/10/04/yiibooster-make-it-gorgeous-do-it-fast/#comments</comments>
		<pubDate>Thu, 04 Oct 2012 12:18:01 +0000</pubDate>
		<dc:creator>Antonio Ramirez</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[Yii]]></category>
		<guid isPermaLink="false">http://www.ramirezcobos.com/?p=1082</guid>
		<description><![CDATA[Introduction It all started with the amazing extension of Chris to allow Yii programmers to include the beauty of Bootstrap into our Yii applications. I was in charge to create a Yii project startup for Clevertech and I thought that Yii-Bootstrap should be standard for it, and that was the reason it was included in YiiBoilerplate. It was an excellent decision. Then, CEO Kuty [...]]]></description>
				<content:encoded><![CDATA[<h2 id="hh0">Introduction</h2>
<p>It all started with <a title="" href="http://www.cniska.net/yii-bootstrap/">the amazing extension of Chris</a> to allow Yii programmers to include the beauty of <a title="" href="http://twitter.github.com/bootstrap/index.html">Bootstrap</a> into our Yii applications.</p>
<p>I was in charge to create a Yii project startup for <a title="" href="http://www.clevertech.biz/">Clevertech</a> and I thought that <a title="" href="http://www.cniska.net/yii-bootstrap/">Yii-Bootstrap</a> should be standard for it, and that was the reason it was included in <a title="YiiBoilerplate" href="http://www.yiiframework.com/wiki/374/yiiboilerplate-setup-a-professional-project-structure-in-seconds/">YiiBoilerplate</a>. It was an excellent decision.</p>
<p>Then, CEO Kuty Shalev, told me to provide solutions for the common challenges that Yii developers confront in our projects at <a title="" href="http://www.clevertech.biz/">Clevertech</a>, we wanted to do things fast. That was the reason I started to create a widget library that, with the support and help of colleague programmers, was growing and growing everyday.</p>
<p>The goal was to maintain the beauty of Twitter Bootstrap, so the widgets were built on top of the development version of Chris&#8217; Yii-Bootstrap extension. The results were highly acceptable, and we agree to share this with the community so to help and improve it for the benefit of everybody.</p>
<p>I truly hope it helps you build beautiful applications and to easy some of the challenges you face. Would be great to have your support to improve, as by helping the community, you will help Yii, and that will always be good for all us.</p>
<h2 id="hh1">Overview</h2>
<p>YiiBooster is a collection of widgets that will ease the task of developing Yii applications, as well as, giving your application a little boost. Basically, YiiBooster tackles the most common challenges that Yii developers face while trying to enhance their applications.</p>
<h2 id="hh2">Widget List</h2>
<p>YiiBooster has a huge collection of widgets, it includes all <a title="" href="http://www.cniska.net/yii-bootstrap/">Yii-Bootstrap</a> widgets plus many more:</p>
<ul>
<li>Buttons</li>
<li>Button groups</li>
<li>Button dropdowns</li>
<li>Boxes</li>
<li>Navigational tabs, pills, and lists</li>
<li>Navbar</li>
<li>Breadcrumbs</li>
<li>Labels and badges</li>
<li>Typographic components</li>
<li>Thumbnails</li>
<li>Alerts</li>
<li>Progress bars</li>
<li>Tables and Grids</li>
<li>Forms</li>
<li>JQuery UI Bootstrap Theme</li>
<li>JSON Grid</li>
<li>Extended Grid</li>
<li>Extended Summaries</li>
<li>Grid/Chart Switcher</li>
<li>Bootstrap Editable Widgets</li>
<li>Image Column</li>
<li>Inline Editing Columns</li>
<li>Calculated Sums</li>
<li>Picker Columns</li>
<li>Modals</li>
<li>Tabs</li>
<li>Tooltips</li>
<li>Popovers</li>
<li>Collapse</li>
<li>Carousel</li>
<li>Typeahead</li>
<li>and many more&#8230;</li>
</ul>
<p>For more information on how to get started with the library plus tons of examples per widget, please visit<a href="http://yii-booster.clevertech.biz/">YiiBooster Site</a>.</p>
<h2 id="hh3">Important</h2>
<p>Even though the library was built on top of <a title="" href="http://www.cniska.net/yii-bootstrap/">Yii-Bootstrap</a> and we have kept the configuration of YiiBooster and the naming conventions in honor of Chris, it is not compatible with it. We have made lots of changes plus many enhancements.</p>
<p>This is also true for the JQuery plugins within. We had to modify them to work with the widgets and provide the expected functionality.</p>
<h2 id="hh4">Resources and Download</h2>
<div>
<p>Contribute to this library through our Github repository!</p>
</div>
<ul>
<li><a href="http://yii-booster.clevertech.biz/">YiiBooster Site</a></li>
<li><a href="https://github.com/clevertech/YiiBooster">YiiBooster Github repository</a></li>
<li><a href="https://github.com/clevertech/YiiBooster/zipball/master">YiiBooster Zipball</a></li>
<li><a href="https://github.com/clevertech/YiiBoilerplate">YiiBoilerplate Github repository</a></li>
<li><a href="https://github.com/clevertech/YiiBoilerplate/zipball/master">YiiBoilerplate Zipball</a></li>
<li><a href="http://www.cniska.net/yii-bootstrap/">Yii-Bootstrap</a></li>
<li><a href="http://www.yiiframework.com/extension/yii-bootstrap-editable/">Yii-Editable</a></li>
</ul>
<blockquote><p><strong><a href="http://www.yiiframework.com/extension/yiibooster/"><img src="http://clevertech.biz/images/slir/w54-h36-c54:36/images/site/index/home/clevertech-logo.png" alt="Clevertech" /></a><br />
well-built beautifully designed web applications<br />
<a href="http://www.clevertech.biz/">www.clevertech.biz</a></strong></p></blockquote>
<p><center><br />
</center></p>
<a href="http://twitter.com/?status=RT%20%40%3A%20YiiBooster%20-%20Make%20it%20Gorgeous%2C%20do%20it%20Fast.%20-%20El%20Blog%20del%20Antonio%20http%3A%2F%2Fwww.ramirezcobos.com%2F2012%2F10%2F04%2Fyiibooster-make-it-gorgeous-do-it-fast%2F" class="tweet-this" ><img src="http://www.ramirezcobos.com/wp-content/plugins/simple-tweet/img/tweet.gif" title="Tweet this!" alt="Tweet this!" />Tweet this!</a>]]></content:encoded>
			<wfw:commentRss>http://www.ramirezcobos.com/2012/10/04/yiibooster-make-it-gorgeous-do-it-fast/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>YiiBackboneBoilerplate &#8211; Project Setup for your Yii+BackboneJS applications</title>
		<link>http://www.ramirezcobos.com/2012/09/13/yiibackboneboilerplate-project-setup-for-your-yiibackbonejs-applications/</link>
		<comments>http://www.ramirezcobos.com/2012/09/13/yiibackboneboilerplate-project-setup-for-your-yiibackbonejs-applications/#comments</comments>
		<pubDate>Thu, 13 Sep 2012 15:52:31 +0000</pubDate>
		<dc:creator>Antonio Ramirez</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[Yii]]></category>
		<guid isPermaLink="false">http://www.ramirezcobos.com/?p=1078</guid>
		<description><![CDATA[YiiBackboneBoilerplate We at Clevertech use this folder structure setup for our own projects when developing BackboneJS applications. Overview YiiBackboneBoilerplate, aims to provide Yii Backbone developers with an application folder to ease the startup of their projects. It uses the flexibility of our YiiBoilerplate with a twist for BackboneJS applications. What is BackboneJS? Backbone.js gives structure to web applications by providing models with key-value binding and [...]]]></description>
				<content:encoded><![CDATA[<h3><strong>YiiBackboneBoilerplate</strong></h3>
<p>We at <a href="http://clevertech.biz/" data-bitly-type="bitly_hover_card"><strong><em>Clevertech</em></strong></a> use this folder structure setup for our own projects when developing <a href="http://www.backbonejs.org/" data-bitly-type="bitly_hover_card">BackboneJS</a> applications.</p>
<h3 id="hh0">Overview</h3>
<p><strong>YiiBackboneBoilerplate</strong>, aims to provide <em>Yii Backbone developers</em> with an application folder to ease the startup of their projects. It uses the flexibility of our <a href="https://github.com/clevertech/YiiBoilerplate" data-bitly-type="bitly_hover_card"><strong>YiiBoilerplate</strong></a> with a <em>twist</em> for BackboneJS applications.</p>
<h3>What is BackboneJS?</h3>
<p>Backbone.js gives structure to web applications by providing models with key-value binding and custom events, collections with a rich API of enumerable functions, views with declarative event handling, and connects it all to your existing API over a RESTful JSON interface.</p>
<p>You may be thinking that Yii is too powerful to be used just as a RESTful service. That for this purpose it could be done with <a href="http://nodejs.org/" data-bitly-type="bitly_hover_card">NodeJS</a> or any of the other libraries available, but it is the power of Yii and for the sake of application scalability that we decided to use it.</p>
<h3 id="hh1">BackboneJS + Yii</h3>
<p>We love to work at <a href="http://clevertech.biz/" data-bitly-type="bitly_hover_card"><strong><em>Clevertech</em></strong></a> with <a href="http://www.yiiframework.com/" data-bitly-type="bitly_hover_card">Yii</a>, in fact, it is one of the biggest assets of our company nowadays. Nevertheless, we are very aware of the new trends, and we had the opportunity to work with <a href="http://www.backbonejs.org/" data-bitly-type="bitly_hover_card">BackboneJS</a>. So we decided that it could be good to provide a project startup for our developers, and allow us to get the best out of both worlds.</p>
<h3 id="hh2">Backbone Overall Folder Structure</h3>
<p>This document will be focused mainly in the folder structure that we set for the Backbone application. Please, read <a href="https://github.com/clevertech/YiiBoilerplate" data-bitly-type="bitly_hover_card">YiiBoilerplate&#8217;s README</a> for a deeper explanation of the main <a href="http://www.yiiframework.com/" data-bitly-type="bitly_hover_card">Yii</a> folder structure setup.</p>
<p>Below the directory structure we are using:</p>
<pre>/
backend/
    ...
common/
    ...
console/
    ...
frontend/
    ...
    www/
        app/
            css/
            img/
            js/
                boilerplate/
                collections/
                libs/
                models/
                views/
                app.js
                controller.js
                main.js
                router.js
                vent.js
            templates/
tests/
    ...</pre>
<h3>Backbone Application Directories</h3>
<p>In the js directory, we have:</p>
<ul>
<li><strong><em>boilerplate</em></strong>: we have created a set of elements for you to create a model, collection, module and/or view. Please, note that the basic application skeleton that we have setup for you is based on<a href="https://github.com/marionettejs/backbone.marionette" data-bitly-type="bitly_hover_card">Backbone.Marionette</a>, and the views are different from normal Backbone views.</li>
<li><strong><em>collections</em></strong>: this is were we place the Backbone collections for our application.</li>
<li><strong><em>libs</em></strong>: holds the main libraries. We included the ones we thought would be the most useful.</li>
<li><strong><em>models</em></strong>: this is were we place the Backbone models for our application.</li>
<li><strong><em>views</em></strong>: and this is where we place the backbone views.</li>
</ul>
<p>A special note regarding the <strong><em>templates</em></strong> directory. This folder is normally within the <strong><em>js</em></strong> folder, but we thought that it would be better to separate UI design from the business logic of the javascript files.</p>
<h4 id="hh3">The <em>runpostdeploy</em> script</h4>
<p>This section is actually extracted from <a href="https://github.com/clevertech/YiiBoilerplate" data-bitly-type="bitly_hover_card">YiiBoilerplate</a>, but it is worth repeating the procedure.</p>
<p>The project has a very handy script that automatically creates the required and folders that are <strong>not</strong> shared for a Yii application, the <strong>runtime</strong> and <strong>assets</strong> folders, extracts the configuration settings specified for a specific environment then copies them to the ****-env.php*** files, and then runs migrations when not on private environments &#8211;we believe that migrations should be always run manually by developers on their machines.</p>
<p>To use this, from the application&#8217;s root folder, simply run:</p>
<p><code>./runpostdeploy environmentType migrations</code></p>
<ul>
<li><strong>environmentType</strong> (required): can be &#8220;any&#8221; of the ones you configure on the <strong>environments</strong> folders (i.e.<code>./runpostdeploy private</code> to use ****-private.php*** configurations)</li>
<li><strong>migrations</strong> (optional): could be &#8220;<strong>migrate</strong>&#8220;&#8221; or &#8220;<strong>no-migrate</strong>&#8220;.
<ul>
<li>migrate: will run migrations</li>
<li>no-migrate: will not run migrations (on private we won&#8217;t run them anyway)</li>
</ul>
</li>
</ul>
<h3 id="hh4">Final Notes</h3>
<p>We would like to inform that this is just a startup <strong>boilerplate</strong> for your own projects. It is not intended by any means to be used <strong><em>&#8216;AS IS&#8217;</em></strong>, but rather as a base to scale to more complicated structures.</p>
<p>Neverteless, we have included a couple of goodies that we hope to improve with the help of the community.</p>
<h3 id="hh5">Resources and Download</h3>
<div>Get the most up to date version from the Github repository!</p>
</div>
<ul>
<li><a href="https://github.com/clevertech/YiiBackboneBoilerplate" data-bitly-type="bitly_hover_card">YiiBackboneBoilerplate Github repository</a></li>
<li><a href="https://github.com/clevertech/YiiBackboneBoilerplate/zipball/master" data-bitly-type="bitly_hover_card">YiiBackboneBoilerplate Zipball</a></li>
</ul>
<p>====</p>
<blockquote><p><strong><a href="http://www.yiiframework.com/wiki/390/yiibackboneboilerplate-project-setup-for-your-yii-backbonejs-applications/"><img src="http://clevertech.biz/images/slir/w54-h36-c54:36/images/site/index/home/clevertech-logo.png" alt="Clevertech" /></a><br />
well-built beautifully designed web applications<br />
<a href="http://www.clevertech.biz/" data-bitly-type="bitly_hover_card">www.clevertech.biz</a></strong></p></blockquote>
<a href="http://twitter.com/?status=RT%20%40%3A%20YiiBackboneBoilerplate%20-%20Project%20Setup%20for%20your%20Yii%2BBackboneJS%20applications%20-%20El%20Blog%20del%20Antonio%20http%3A%2F%2Fwww.ramirezcobos.com%2F2012%2F09%2F13%2Fyiibackboneboilerplate-project-setup-for-your-yiibackbonejs-applications%2F" class="tweet-this" ><img src="http://www.ramirezcobos.com/wp-content/plugins/simple-tweet/img/tweet.gif" title="Tweet this!" alt="Tweet this!" />Tweet this!</a>]]></content:encoded>
			<wfw:commentRss>http://www.ramirezcobos.com/2012/09/13/yiibackboneboilerplate-project-setup-for-your-yiibackbonejs-applications/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>YiiSES &#8211; Implement Bulk Mail Marketing with Amazon Simple Email Service</title>
		<link>http://www.ramirezcobos.com/2012/09/09/yiises-implement-bulk-mail-marketing-with-amazon-simple-email-service/</link>
		<comments>http://www.ramirezcobos.com/2012/09/09/yiises-implement-bulk-mail-marketing-with-amazon-simple-email-service/#comments</comments>
		<pubDate>Sun, 09 Sep 2012 20:44:50 +0000</pubDate>
		<dc:creator>Antonio Ramirez</dc:creator>
				<category><![CDATA[On The Web]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[Yii]]></category>
		<category><![CDATA[Mail]]></category>
		<guid isPermaLink="false">http://www.ramirezcobos.com/?p=1054</guid>
		<description><![CDATA[Introduction I had to develop a module for a client at Clevertech that was quite interesting and not any developed for Yii yet. The module was to take care of the bulk mail services of the client and it supposed to work with nearly new Amazon Simple Email Service, which make the task even more interesting. [...]]]></description>
				<content:encoded><![CDATA[<h2>Introduction</h2>
<p>I had to develop a module for a client at <a href="http://www.clevertech.biz">Clevertech</a> that was quite interesting and not any developed for <a href="http://www.yiiframework.com">Yii</a> yet. The module was to take care of the bulk mail services of the client and it supposed to work with nearly new <a href="http://aws.amazon.com/ses/">Amazon Simple Email Service</a>, which make the task even more interesting. The end result was <a href="https://github.com/clevertech/YiiSES">YiiSES</a> and to tell you the truth I was very happy with it.</p>
<p>Nevertheless, an image is worth thousand words, check the following thumbnails:</p>
<a href='http://www.ramirezcobos.com/2012/09/09/yiises-implement-bulk-mail-marketing-with-amazon-simple-email-service/screen-shot-2012-08-30-at-1-45-31-pm/' title='Screen Shot 2012-08-30 at 1.45.31 PM'><img width="120" height="120" src="http://www.ramirezcobos.com/wp-content/uploads/2012/09/Screen-Shot-2012-08-30-at-1.45.31-PM-120x120.png" class="attachment-thumbnail" alt="Screen Shot 2012-08-30 at 1.45.31 PM" /></a>
<a href='http://www.ramirezcobos.com/2012/09/09/yiises-implement-bulk-mail-marketing-with-amazon-simple-email-service/screen-shot-2012-08-30-at-1-45-48-pm/' title='Screen Shot 2012-08-30 at 1.45.48 PM'><img width="120" height="120" src="http://www.ramirezcobos.com/wp-content/uploads/2012/09/Screen-Shot-2012-08-30-at-1.45.48-PM-120x120.png" class="attachment-thumbnail" alt="Screen Shot 2012-08-30 at 1.45.48 PM" /></a>
<a href='http://www.ramirezcobos.com/2012/09/09/yiises-implement-bulk-mail-marketing-with-amazon-simple-email-service/screen-shot-2012-08-30-at-1-45-59-pm/' title='Screen Shot 2012-08-30 at 1.45.59 PM'><img width="120" height="120" src="http://www.ramirezcobos.com/wp-content/uploads/2012/09/Screen-Shot-2012-08-30-at-1.45.59-PM-120x120.png" class="attachment-thumbnail" alt="Screen Shot 2012-08-30 at 1.45.59 PM" /></a>
<a href='http://www.ramirezcobos.com/2012/09/09/yiises-implement-bulk-mail-marketing-with-amazon-simple-email-service/screen-shot-2012-08-30-at-1-46-18-pm/' title='Screen Shot 2012-08-30 at 1.46.18 PM'><img width="120" height="120" src="http://www.ramirezcobos.com/wp-content/uploads/2012/09/Screen-Shot-2012-08-30-at-1.46.18-PM-120x120.png" class="attachment-thumbnail" alt="Screen Shot 2012-08-30 at 1.46.18 PM" /></a>
<a href='http://www.ramirezcobos.com/2012/09/09/yiises-implement-bulk-mail-marketing-with-amazon-simple-email-service/screen-shot-2012-08-30-at-1-47-04-pm/' title='Screen Shot 2012-08-30 at 1.47.04 PM'><img width="120" height="120" src="http://www.ramirezcobos.com/wp-content/uploads/2012/09/Screen-Shot-2012-08-30-at-1.47.04-PM-120x120.png" class="attachment-thumbnail" alt="Screen Shot 2012-08-30 at 1.47.04 PM" /></a>
<a href='http://www.ramirezcobos.com/2012/09/09/yiises-implement-bulk-mail-marketing-with-amazon-simple-email-service/screen-shot-2012-08-30-at-1-47-15-pm/' title='Screen Shot 2012-08-30 at 1.47.15 PM'><img width="120" height="120" src="http://www.ramirezcobos.com/wp-content/uploads/2012/09/Screen-Shot-2012-08-30-at-1.47.15-PM-120x120.png" class="attachment-thumbnail" alt="Screen Shot 2012-08-30 at 1.47.15 PM" /></a>
<a href='http://www.ramirezcobos.com/2012/09/09/yiises-implement-bulk-mail-marketing-with-amazon-simple-email-service/screen-shot-2012-08-30-at-1-47-26-pm/' title='Screen Shot 2012-08-30 at 1.47.26 PM'><img width="120" height="120" src="http://www.ramirezcobos.com/wp-content/uploads/2012/09/Screen-Shot-2012-08-30-at-1.47.26-PM-120x120.png" class="attachment-thumbnail" alt="Screen Shot 2012-08-30 at 1.47.26 PM" /></a>
<a href='http://www.ramirezcobos.com/2012/09/09/yiises-implement-bulk-mail-marketing-with-amazon-simple-email-service/screen-shot-2012-08-30-at-1-47-54-pm/' title='Screen Shot 2012-08-30 at 1.47.54 PM'><img width="120" height="120" src="http://www.ramirezcobos.com/wp-content/uploads/2012/09/Screen-Shot-2012-08-30-at-1.47.54-PM-120x120.png" class="attachment-thumbnail" alt="Screen Shot 2012-08-30 at 1.47.54 PM" /></a>
<a href='http://www.ramirezcobos.com/2012/09/09/yiises-implement-bulk-mail-marketing-with-amazon-simple-email-service/screen-shot-2012-08-30-at-1-48-06-pm/' title='Screen Shot 2012-08-30 at 1.48.06 PM'><img width="120" height="120" src="http://www.ramirezcobos.com/wp-content/uploads/2012/09/Screen-Shot-2012-08-30-at-1.48.06-PM-120x120.png" class="attachment-thumbnail" alt="Screen Shot 2012-08-30 at 1.48.06 PM" /></a>
<a href='http://www.ramirezcobos.com/2012/09/09/yiises-implement-bulk-mail-marketing-with-amazon-simple-email-service/screen-shot-2012-08-30-at-1-48-22-pm/' title='Screen Shot 2012-08-30 at 1.48.22 PM'><img width="120" height="120" src="http://www.ramirezcobos.com/wp-content/uploads/2012/09/Screen-Shot-2012-08-30-at-1.48.22-PM-120x120.png" class="attachment-thumbnail" alt="Screen Shot 2012-08-30 at 1.48.22 PM" /></a>
<a href='http://www.ramirezcobos.com/2012/09/09/yiises-implement-bulk-mail-marketing-with-amazon-simple-email-service/screen-shot-2012-08-30-at-1-48-35-pm/' title='Screen Shot 2012-08-30 at 1.48.35 PM'><img width="120" height="120" src="http://www.ramirezcobos.com/wp-content/uploads/2012/09/Screen-Shot-2012-08-30-at-1.48.35-PM-120x120.png" class="attachment-thumbnail" alt="Screen Shot 2012-08-30 at 1.48.35 PM" /></a>
<a href='http://www.ramirezcobos.com/2012/09/09/yiises-implement-bulk-mail-marketing-with-amazon-simple-email-service/screen-shot-2012-08-30-at-1-48-44-pm/' title='Screen Shot 2012-08-30 at 1.48.44 PM'><img width="120" height="120" src="http://www.ramirezcobos.com/wp-content/uploads/2012/09/Screen-Shot-2012-08-30-at-1.48.44-PM-120x120.png" class="attachment-thumbnail" alt="Screen Shot 2012-08-30 at 1.48.44 PM" /></a>
<h2>Features List</h2>
<ul>
<li>Campaign Management</li>
<li>Campaign Stats
<ul>
<li>How many opened / failed / successful</li>
</ul>
</li>
<li>Amazon SES Usage Stats</li>
<li>Subscriber Management</li>
<li>Google track vars</li>
<li>And much more</li>
</ul>
<p>I think is much better if you check it out by yourself. The whole project is Open Source and is freely available under <a href="http://creativecommons.org/licenses/by-sa/3.0/" data-bitly-type="bitly_hover_card">Creative Commons Attribution-ShareAlike 3.0 Unported License</a>, you can get is source code at Clevertech&#8217;s github profile: <a title="github repository" href="https://github.com/clevertech/YiiSES">https://github.com/clevertech/YiiSES</a>, we would love to hear your feedback, specially me.</p>
<h3 id="hh0">YiiSES Overview</h3>
<p><strong><em>YiiSES</em></strong> is a &#8216;nearly&#8217; ready to use module that provides our Yii applications with a powerful mail marketing tool.</p>
<p>The system makes use of <strong><a href="http://aws.amazon.com/ses/" data-bitly-type="bitly_hover_card">Amazon Simple Email Service (Amazon SES)</a></strong>, chosen for its highly <a href="http://aws.amazon.com/ses/pricing/" data-bitly-type="bitly_hover_card">reduced price</a>, scalability and features. A developer can easily register and use its service at no charge. The only issue is that the developer will only be able to send to verified email addresses only.</p>
<p>This module has been ported to Open Source from one of the projects at <a href="http://clevertech.biz/" data-bitly-type="bitly_hover_card">Clevertech</a> and we are very happy with its results so far.</p>
<h3 id="hh1">Install</h3>
<p>Even though there was some good effort to make it easy to install, its configuration is a bit tricky. We hope this will change with a bit of help from the community.</p>
<p>Within the code you will find two types of configurations, one to be used with <a href="http://github.com/clevertech/YiiBoilerplate" data-bitly-type="bitly_hover_card">YiiBoilerplate</a> project structure (default), and the other when we install the module on a Yii&#8217;s default application structure.</p>
<p>The following instructions are to install the module on a Yii&#8217;s default application structure.</p>
<h4>Configuration</h4>
<ul>
<li>Create your web application <code>./yiic webapp &lt;folder&gt;</code></li>
<li>Create your <strong>modules</strong> folder under <strong>protected</strong> and unpack the module there</li>
<li>Place <strong>commands\CampaignCommand.php</strong> on your commands directory and <strong>ses\migrations..</strong> on the migrations directory.</li>
<li>Configure your <strong>config\main.php</strong> and <strong>config\console.php</strong> configuration files (make sure your db is setup correctly -<em>migrations will only work on mySQL db</em>):</li>
</ul>
<div>
<div>
<pre>// console.php
    …
    // urlManager must be the same configuration as on main.php
    'urlManager' =&gt; array(
        // remember to have your .htaccess setup correctly
        'urlFormat' =&gt; 'path',
        'showScriptName' =&gt; false,
        'urlSuffix' =&gt; '/',
        'rules'=&gt;array(
            '&lt;controller:\w+&gt;/&lt;id:\d+&gt;'=&gt;'&lt;controller&gt;/view',
            '&lt;controller:\w+&gt;/&lt;action:\w+&gt;/&lt;id:\d+&gt;'=&gt;'&lt;controller&gt;/&lt;action&gt;',
            '&lt;controller:\w+&gt;/&lt;action:\w+&gt;'=&gt;'&lt;controller&gt;/&lt;action&gt;',
        ),
    ),
    // request is required to create appropriate urls within the emails
    // when processed with the CampaignCommand.php
    'request' =&gt; array(
    )
    …
    // main.php
    …
    'modules' =&gt; array(
        'ses'=&gt;array(
            'password'=&gt;'clevertech',
        ),
    ),
    …
    // urlManager must be the same configuration as on main.php
    'urlManager' =&gt; array(
        // remember to have your .htaccess setup correctly
        'urlFormat' =&gt; 'path',
        'showScriptName' =&gt; false,
        'urlSuffix' =&gt; '/',
        'rules'=&gt;array(
            '&lt;controller:\w+&gt;/&lt;id:\d+&gt;'=&gt;'&lt;controller&gt;/view',
            '&lt;controller:\w+&gt;/&lt;action:\w+&gt;/&lt;id:\d+&gt;'=&gt;'&lt;controller&gt;/&lt;action&gt;',
            '&lt;controller:\w+&gt;/&lt;action:\w+&gt;'=&gt;'&lt;controller&gt;/&lt;action&gt;',
        ),
    ),
    …
    'params'=&gt; array(
        'ses.aws.key'=&gt;'',
    …</pre>
</div>
</div>
<ul>
<li>Setup required parameters on your configuration files (must be shared among console.php and main.php):
<ul>
<li><strong>ses.aws.key</strong>: Your <a href="http://aws.amazon.com/documentation/ses/" data-bitly-type="bitly_hover_card">Amazon SES API Key</a></li>
<li><strong>ses.aws.secret</strong>: Your Amazon SES Secret</li>
<li><strong>ses.aws.verifiedEmail</strong>: You are required to verify at least one email address on Amazon SES console in order to send emails</li>
<li><strong>ses.aws.test.email</strong>: Email where to send <em>test</em> emails. If your account is not in production, then this email should be also verified on Amazon SES console.</li>
<li><strong>ses.emailonacid.key</strong>: If you wish to preview and test your emails on <a href="http://www.emailonacid.com/" data-bitly-type="bitly_hover_card">EmailOnAcid</a> service, you have to configure your API key here.</li>
<li><strong>ses.emailonacid.pwd</strong>: Your password to access <a href="http://www.emailonacid.com/" data-bitly-type="bitly_hover_card">EmailOnAcid</a> service for testing and previewing your emails.</li>
<li><strong>ses.files.path</strong>: Set this parameter in order to make use of the image upload capabilities of<a href="http://redactorjs.com/" data-bitly-type="bitly_hover_card">RedactorJS</a>, our chosen WYSIWYG editor for the module.</li>
<li><strong>ses.files.url</strong>: Required to display the thumbnail gallery of <a href="http://redactorjs.com/" data-bitly-type="bitly_hover_card">RedactorJS</a>.</li>
<li><strong>ses.panel.login.url</strong>: The Route to the control panel. This parameter is required at the unsubscribe form. If somebody tries to remove an email from a registered user, then it will be presented with the link created from this route, to inform that he should log into its panel in order to unsubscribe.</li>
<li><strong>ses.from.name</strong>: Your application name. Will be included in the Emails From Name (ie.&#8221;My Application &#8221; )</li>
</ul>
</li>
<li>Make sure your paths are correctly set:
<ul>
<li>CampaignCommand.php::init() <strong>- line 74</strong></li>
<li>CampaignCommand.php::sendEmail() <strong>- line 376</strong></li>
<li>models\Email.php::formatHTMLMessage() <strong>- line 136</strong></li>
<li>models\Template.php::getView <strong>- line 65</strong></li>
</ul>
</li>
<li>Run migrations <code>./yiic migrate</code> from your command line prompt.</li>
</ul>
<h4>The User table and Model</h4>
<p>One important part of the configuration is how you deal with the subscribers. The module works by default with the assumptions that your application has a <strong>User</strong> model with <strong>id, email, and username, subscribed</strong>attributes.</p>
<p>The module comes with a single field for campaign that configures whether to send to subscribers or not but you can easily change that behavior to match different fields or subscription option from your registered members <em>-but this is something that I won&#8217;t explain here <img src='http://www.ramirezcobos.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </em>.</p>
<h3 id="hh2">Requirements</h3>
<p>The following requirements are all included already within the module:<br />
- <a href="http://www.yiiframework.com/extension/ephpthumb" data-bitly-type="bitly_hover_card">EPHPThumb</a> - <a href="https://github.com/zshannon/Amazon-Simple-Email-Service-PHP" data-bitly-type="bitly_hover_card">SES Component</a><br />
- <a href="http://www.yiiframework.com/extension/bootstrap" data-bitly-type="bitly_hover_card">YiiBootstrap</a><br />
- <a href="http://www.highcharts.com/" data-bitly-type="bitly_hover_card">HighCharts</a><br />
- <a href="http://www.redactorjs.com/" data-bitly-type="bitly_hover_card">RedactorJS</a></p>
<h3 id="hh3">Contribute</h3>
<div>
<p>If you wish to contribute, please fork our repository!</p>
</div>
<ul>
<li><a href="https://github.com/clevertech/YiiSES" data-bitly-type="bitly_hover_card">YiiSES Github repository</a></li>
</ul>
<p><center><br />
</center></p>
<a href="http://twitter.com/?status=RT%20%40%3A%20YiiSES%20-%20Implement%20Bulk%20Mail%20Marketing%20with%20Amazon%20Simple%20Email%20Service%20%20-%20El%20Blog%20del%20Antonio%20http%3A%2F%2Fwww.ramirezcobos.com%2F2012%2F09%2F09%2Fyiises-implement-bulk-mail-marketing-with-amazon-simple-email-service%2F" class="tweet-this" ><img src="http://www.ramirezcobos.com/wp-content/plugins/simple-tweet/img/tweet.gif" title="Tweet this!" alt="Tweet this!" />Tweet this!</a>]]></content:encoded>
			<wfw:commentRss>http://www.ramirezcobos.com/2012/09/09/yiises-implement-bulk-mail-marketing-with-amazon-simple-email-service/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>YiiBoilerplate &#8211; Setup a professional project structure in seconds</title>
		<link>http://www.ramirezcobos.com/2012/08/30/yiiboilerplate-setup-a-professional-project-structure-in-seconds/</link>
		<comments>http://www.ramirezcobos.com/2012/08/30/yiiboilerplate-setup-a-professional-project-structure-in-seconds/#comments</comments>
		<pubDate>Thu, 30 Aug 2012 10:41:33 +0000</pubDate>
		<dc:creator>Antonio Ramirez</dc:creator>
				<category><![CDATA[On The Web]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[Yii]]></category>
		<guid isPermaLink="false">http://www.ramirezcobos.com/?p=1043</guid>
		<description><![CDATA[YiiBoilerplate I have the great opportunity to work with Clevertech, and I was in charge of creating a boilerplate that the company could use in order to have a Yii project structure in a matter of seconds. You can think that we could use Yii&#8217;s default webapp command but there some project requirements just don&#8217;t [...]]]></description>
				<content:encoded><![CDATA[<h1>YiiBoilerplate</h1>
<p>I have the great opportunity to work with <a href="http://www.clevertech.biz">Clevertech</a>, and I was in charge of creating a boilerplate that the company could use in order to have a Yii project structure in a matter of seconds. You can think that we could use Yii&#8217;s default <strong>webapp</strong> command but there some project requirements just don&#8217;t fit.</p>
<p>We use this folder structure setup on <a href="http://www.clevertech.biz/" data-bitly-type="bitly_hover_card">Clevertech</a> for our own projects, we believe that can suit most of project requirements from Simple to Enterprise.</p>
<h3><a name="overview" href="https://github.com/clevertech/YiiBoilerplate#overview" data-bitly-type="bitly_hover_card"></a>Overview</h3>
<p><strong>YiiBoilerplate</strong>, aims to provide <em>Yii developers</em> an application folder structure with sufficient flexibility to satisfy from simple to enterprise application&#8217;s development needs.</p>
<p>It may look a little bit too complex at first sight but, at Clevertech, we understand that needs may vary along the development life cycle of a product in order to fulfill customer&#8217;s requirements and that commonly forces developers to modify the initial folder structure, thus making very hard for a new developer to jump in and &#8216;understand&#8217; where is all located.</p>
<p>In order to avoid such time consuming tasks, <strong>easy the life of our beloved developers</strong> and increase productivity, we make use of this folder structure template for our projects.</p>
<h3><a name="overall-structure" href="https://github.com/clevertech/YiiBoilerplate#overall-structure" data-bitly-type="bitly_hover_card"></a>Overall Structure</h3>
<p>Below the directory structure we are using:</p>
<pre>/
backend/
    components/
    config/
        environments/
            main-private.php *
            main-prod.php
            params-private.php *
            params-prod.php
    main-env.php *
    main-local.php *
    main.php
    params-env.php *
    params-local.php *
    params.php
    test.php
controllers/
    SiteController.php
    ...
extensions/
        behaviors/
        validators/
    lib/
    models/
        FormModel.php
        ...
    modules/
    runtime/ *
    views/
        layouts/
        site/
    widgets/
    www/
        assets/ *
        css/
        images/
        js/
        themes/
        index.php
        .htaccess
common/
    components/
    config/
        environments/
            params-private.php *
            params-prod.php
        params-env.php *
        params-local.php *
        params.php
    data/
    extensions/
        behaviors/
        validators/
    lib/
        Behat/
        Pear/
        Yii/
        Zend/
    messages/
    models/
    widgets/
console/
    commands/
    components/
    config/
        environments/
    lib/
    migrations/
    models/
    runtime/ *
    yiic.php
frontend/
    components/
    config/
        environments/
            main-private.php *
            main-prod.php
            params-private.php *
            params-prod.php
        main-env.php *
        main-local.php
        main.php
        params-env.php *
        params-local.php *
        params.php
        test.php
    controllers/
    extensions/
        behaviors/
        validators/
    lib/
    models/
    modules/
    runtime/ *
    views/
        layouts/
        site/
    www/
        assets/ *
        css/
        files/
        images/
            js/
            less/
        index.php
        robots.txt
        .htaccess
tests/
    bootstrap/
        FeatureContext.php
        YiiContext.php
    features/
        Startup.feature
    behat.yml
INSTALL.md
README.md
runbehat
runpostdeploy
yiic
yiic.bat</pre>
<p>When working in a team development environment, using any of the VCS (Version Control System) available (i.e. Git, SVN), the files and folders marked with an asterisk should <strong>not</strong> be included in the revision system.</p>
<h3><a name="top-level-directories" href="https://github.com/clevertech/YiiBoilerplate#top-level-directories" data-bitly-type="bitly_hover_card"></a>Top Level Directories</h3>
<p>At the top-most level, we have:</p>
<ul>
<li><strong><em>backend</em></strong>: the backend application which will be mainly used by site administrators to manage the whole system (avoiding admin modules at frontend application to avoid confusion)</li>
<li><strong><em>console</em></strong>: the console application that is compound of the console commands required for the system.</li>
<li><strong><em>frontend</em></strong>: the frontend application that is the main interface for end users. On a website development, this would be what the site users would see.</li>
<li><strong><em>common</em></strong>: the directory whose content is shared among all the above applications.</li>
<li><strong><em>test</em></strong>: the folder where we include all of our BDD system tests.</li>
</ul>
<p>The whole application is divided into three applications: backend, fronted and console. Following <a href="http://www.yiiframework.com/wiki/155/the-directory-structure-of-the-yii-project-site" data-bitly-type="bitly_hover_card">the directory structure of the yii project site</a>, with some twist on its configuration. The common folder is to store all files (extensions, components, behaviors, models, etc… ) that are shared among the mentioned applications.</p>
<p>When developing a large project with a long development cycle, we constantly need to adjust the database structure. For this reason, we also use the DB migration feature to keep track of database changes. We store all DB migrations under the <strong>migrations</strong> directory in <strong>console</strong>.</p>
<h3><a name="application-directories" href="https://github.com/clevertech/YiiBoilerplate#application-directories" data-bitly-type="bitly_hover_card"></a>Application Directories</h3>
<p>The directory structure of each application is very similar. For example <strong>backend</strong> and <strong>frontend</strong> both share the same directory structure with a slight variation at the <strong><em>www</em></strong> folder of the <strong>frontend</strong> and the inclusion of bootstrap theme and extensions for the<strong>backend</strong>, to easy the task to create Administrative panels.</p>
<p>The shared folder structure is this one:</p>
<ul>
<li><strong><em>components</em></strong>: contains components (i.e. helpers, application components) that are only used by this application</li>
<li><strong><em>config</em></strong>: contains application specific configuration files.</li>
<li><strong><em>controllers</em></strong>: contains controller classes</li>
<li><strong><em>extensions</em></strong>: Yii extensions that are only used by this application</li>
<li><strong><em>lib</em></strong>: third-party libraries that are only used by this application</li>
<li><strong><em>models</em></strong>: contains model classes that are specific for this application</li>
<li><strong><em>modules</em></strong>: contains modules that are only used by this application</li>
<li><strong><em>views</em></strong>: stores controller actions view scripts</li>
<li><strong><em>widgets</em></strong>: stores Yii widgets only used by this application.</li>
<li><strong><em>www</em></strong>: the web root for this application.</li>
</ul>
<p>We have created <strong>extensions</strong> and <strong>widgets</strong> folders, that could had been obviously included in the <strong>components</strong> folder, in order to clearly differentiate the types of components that could exist into a Yii application and easy the task to find them. So, for example, developers won&#8217;t search for a widget that renders a jQuery UI plugin within a folder that has application wide components, or helpers, or extensions, or…</p>
<p>The directory structure for <strong>console</strong> application differs from the others as it doesn&#8217;t require <strong>controllers</strong>, <strong>views</strong>, <strong>widgets</strong>, and <strong>www</strong>. It has a <strong>commands</strong> directory to store all console command class files.</p>
<h3><a name="the-common-directory" href="https://github.com/clevertech/YiiBoilerplate#the-common-directory" data-bitly-type="bitly_hover_card"></a>The Common Directory</h3>
<p>The common directory contains the files that are shared among applications. For example, every application may need to access the database using ActiveRecord. Therefore, we can store the AR model classes under the common directory. Similarly, if some helper or widget classes are used in more than one application, we should also put them under common to avoid duplication of code.</p>
<p>To facilitate the maintenance of code, we organize the common directory in a structure similar to that of an application. For example, we have components, models, lib, etc.</p>
<p style="text-align: right;"><strong><em>- source: <a href="http://www.yiiframework.com/wiki/155/the-directory-structure-of-the-yii-project-site#hh3" data-bitly-type="bitly_hover_card">Yii Framework Site</a></em></strong></p>
<h3><a name="application-configurations" href="https://github.com/clevertech/YiiBoilerplate#application-configurations" data-bitly-type="bitly_hover_card"></a>Application Configurations</h3>
<p>Applications of the same system usually share some common configurations, such as DB connection configuration, application parameters, etc. In order to eliminate duplication of code, we should extract these common configurations and store them in a central place. In our setting, we put them under the config directory in <strong>common</strong>.</p>
<h4><a name="how-to-configure-the-application" href="https://github.com/clevertech/YiiBoilerplate#how-to-configure-the-application" data-bitly-type="bitly_hover_card"></a>How to configure the application</h4>
<p>The configuration for this boilerplate is not that complicated as it seems at first sight. As mentioned before, if our system has both<strong>backend</strong> and <strong>frontend</strong> applications and they both share the same DB configuration. We just need to configure one of the files on the<strong>config</strong> sub-directory under the <strong>common</strong> folder.</p>
<p>The files within the config folder of each application and common folder requires a bit of explanation. When working in a team environment, different developers may have different development environments. These environments are also often different from the production environment. This is why the configuration folders on each application contains a list of files that try to avoid interference among the different environments.</p>
<p>As you can see, the config folders include a set of files:</p>
<ul>
<li>environments/<strong><em>params-private.php</em></strong>: This is to have the application parameters required for the developer on its development environment.</li>
<li>environments/<strong>params-prod.php</strong>: This is to have the application parameters required for the application on <strong>production</strong></li>
<li>environments/<strong>main-private.php</strong>: The application configuration settings required for the developer on its development environment.</li>
<li>environments/<strong>main-prod.php</strong>: The application configuration settings required for the application on <strong>production</strong></li>
<li><strong>main-env.php</strong>: This file will be override with the environment specific application configuration selected by the <strong>runpostDeploy</strong>script (as we are going to explain after)</li>
<li><strong>main-local.php</strong>: This is the application configuration options for the developer*</li>
<li><strong>params-env.php</strong>: This will be override with the environment specific parameters selected by the <strong>runpostdeploy</strong> script</li>
<li><strong>params-local.php</strong>: The application parameters for the developer*</li>
<li><strong>params.php</strong>: The application parameters</li>
<li><strong>test.php</strong>: Test application configuration options</li>
</ul>
<p>The configuration tree override in the following way:</p>
<p><strong><em>local settings &gt; environment specific &gt; main configuration file</em></strong></p>
<p>That means that local settings override environment specific and its result override main configuration file. And this is true for all configurations folders being the common configuration folder settings predominant over the application specific one:</p>
<p><strong>common shared params &gt; application params</strong> <strong>common shared config &gt; application config</strong></p>
<p>There is a slight difference between the *<strong><em>-private.php</em></strong> and the *<em><strong>-local.php</strong></em> files. The first ones are automatically read with the <strong><em>runpostdeploy</em></strong> script and it could be settings that developers sitting on same machines in internal networks, and the latest is the programmer&#8217;s configurations.</p>
<p>The base configuration should be put under version control, like regular source code, so that it can be shared by every developer. The local configuration should <strong>not</strong> be put under version control and should only exist in each developer&#8217;s working directory.</p>
<h4><a name="the-runpostdeploy-script" href="https://github.com/clevertech/YiiBoilerplate#the-runpostdeploy-script" data-bitly-type="bitly_hover_card"></a>The <em>runpostdeploy</em> script</h4>
<p>The project has a very useful script that automatically creates the required and <strong>not</strong> shared folders for a Yii application: the <strong>runtime</strong>and <strong>assets</strong> folders, extracts the configuration settings specified for a specific environment and copies them to the *<strong><em>-env.php</em></strong> files and runs migrations when not on private environments -we believe that migrations should be always run manually by developers on their machines.</p>
<p>From the application&#8217;s root folder, to run the script simply do:</p>
<pre><code>./runpostdeploy environmentType migrations </code></pre>
<ul>
<li><strong>environmentType</strong> (required): can be &#8220;any&#8221; of the ones you configure on the <strong>environments</strong> folders (i.e.<code>./runpostdeploy private</code> to use *<strong><em>-private.php</em></strong> configurations)</li>
<li><strong>migrations</strong> (optional): could be &#8220;<strong>migrate</strong>&#8220;&#8221; or &#8220;<strong>no-migrate</strong>&#8220;.
<ul>
<li>migrate: will run migrations</li>
<li>no-migrate: will not run migrations (on private wont run them anyway)</li>
</ul>
</li>
</ul>
<blockquote><p><img src="https://a248.e.akamai.net/camo.github.com/2c68c5f21262f75679c2d52f1c4d2704071d2ef7/687474703a2f2f636c65766572746563682e62697a2f696d616765732f736c69722f7735342d6833362d6335343a33362f696d616765732f736974652f696e6465782f686f6d652f636c65766572746563682d6c6f676f2e706e67" alt="Clevertech" /><br />
well-built beautifully designed web applications<br />
<a href="http://www.clevertech.biz/" data-bitly-type="bitly_hover_card">www.clevertech.biz</a></p></blockquote>
<p><center><br />
</center></p>
<a href="http://twitter.com/?status=RT%20%40%3A%20YiiBoilerplate%20-%20Setup%20a%20professional%20project%20structure%20in%20seconds%20-%20El%20Blog%20del%20Antonio%20http%3A%2F%2Fwww.ramirezcobos.com%2F2012%2F08%2F30%2Fyiiboilerplate-setup-a-professional-project-structure-in-seconds%2F" class="tweet-this" ><img src="http://www.ramirezcobos.com/wp-content/plugins/simple-tweet/img/tweet.gif" title="Tweet this!" alt="Tweet this!" />Tweet this!</a>]]></content:encoded>
			<wfw:commentRss>http://www.ramirezcobos.com/2012/08/30/yiiboilerplate-setup-a-professional-project-structure-in-seconds/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>ENexmo Yii Extension Library</title>
		<link>http://www.ramirezcobos.com/2012/03/21/enexmo-yii-extension-library/</link>
		<comments>http://www.ramirezcobos.com/2012/03/21/enexmo-yii-extension-library/#comments</comments>
		<pubDate>Wed, 21 Mar 2012 11:25:18 +0000</pubDate>
		<dc:creator>Antonio Ramirez</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[Yii]]></category>
		<guid isPermaLink="false">http://www.ramirezcobos.com/?p=1037</guid>
		<description><![CDATA[Introduction ENexmo Library allows Yii programmers to use the Restful API offered by Mobile Messaging provider Nexmo. ENexmo is a cloud-based SMS API that lets you send and receive high volume of messages at wholesale rates. Requires Nexmo API credentials EHttpClient Extension Yii Framework Quick Start Once you have created your Nexmo account and include ENexmo [...]]]></description>
				<content:encoded><![CDATA[<h2>Introduction</h2>
<p><a href="http://www.ramirezcobos.com/2012/03/21/enexmo-yii-extension-library/screen-shot-2012-03-21-at-12-22-41-pm/" rel="attachment wp-att-1038"><img src="http://www.ramirezcobos.com/wp-content/uploads/2012/03/Screen-Shot-2012-03-21-at-12.22.41-PM.png" alt="" title="Nexmo" width="300" height="243" class="alignright size-full wp-image-1038" /></a><a title="Nexmo" href="http://www.nexmo.com">ENexmo</a> Library allows Yii programmers to use the Restful API offered by Mobile Messaging provider Nexmo.</p>
<p><a title="Nexmo" href="http://www.nexmo.com">ENexmo</a> is a cloud-based SMS API that lets you send and receive high volume of messages at wholesale rates.</p>
<h2>Requires</h2>
<ul>
<li><a title="Nexmo Documentation" href="http://nexmo.com/documentation/index.html">Nexmo API credentials</a></li>
<li><a title="EHttpClient" href="http://www.yiiframework.com/extension/ehttpclient/">EHttpClient Extension</a></li>
<li>Yii Framework</li>
</ul>
<h2>Quick Start</h2>
<p>Once you have created your Nexmo account and include ENexmo library and EHttpClient on the extension folder is as easy as this:</p>
<p>&nbsp;</p>
<pre class="brush: php; title: ; notranslate">
/* import extensions before any call */
Yii::import('ext.httpclient.*');
Yii::import('ext.nexmo.*');
/* to send a message */
$nexmo_sms = new ENexmoSms('YOURAPIKEY','YOURAPISECRET');
$response = $nexmo_sms-&gt;sendTextMessage('RECIPIENTSNUMBER','SENDERID','Howdy testing! Please, search on http://www.google.com.');
/* responses are on JSON or XML. Defaults to JSON, but you can change that */
/* we use CHtml::encode for demo purposes only, to check for responses */
echo CHtml::encode($response);
/* to make requests for account */
$nexmo_account = new ENexmoAccount('key','secret');
$nexmo_account-&gt;format = ENexmoBase::FORMAT_JSON;
/* to search for a message */
echo CHtml::encode($nexmo_account-&gt;searchMessage('09AFDA98'));
//echo CHtml::encode($nexmo_account-&gt;searchMessagesByIds(array('09AFCC5B','09AFDA98')));
//echo CHtml::encode($nexmo_account-&gt;searchMessagesByDateAndRecipient('2012-03-20','34607040932'));
//echo CHtml::encode($nexmo_account-&gt;balance);
//echo CHtml::encode($nexmo_account-&gt;ownNumbers);
//echo CHtml::encode($nexmo_account-&gt;getSmsPricing('ES'));
</pre>
<p>Please check Nexmo API Documentation Nexmo API Documentation</p>
<a href="http://twitter.com/?status=RT%20%40%3A%20ENexmo%20Yii%20Extension%20Library%20-%20El%20Blog%20del%20Antonio%20http%3A%2F%2Fwww.ramirezcobos.com%2F2012%2F03%2F21%2Fenexmo-yii-extension-library%2F" class="tweet-this" ><img src="http://www.ramirezcobos.com/wp-content/plugins/simple-tweet/img/tweet.gif" title="Tweet this!" alt="Tweet this!" />Tweet this!</a>]]></content:encoded>
			<wfw:commentRss>http://www.ramirezcobos.com/2012/03/21/enexmo-yii-extension-library/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Served from: www.ramirezcobos.com @ 2013-05-20 19:35:21 by W3 Total Cache -->