<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0"><channel><atom:link rel="hub" href="http://tumblr.superfeedr.com/" xmlns:atom="http://www.w3.org/2005/Atom"/><description></description><title>V-tek</title><generator>Tumblr (3.0; @vtek2012)</generator><link>http://vtek.nl/</link><item><title>Migrate JsonView to CakePHP 2</title><description>&lt;p&gt;While working on the migration of a Cake1.x project to Cake2, I faced a problem with the JsonView plugin of Pagebakers. Instead of being catched by the JsonView View, it just printed out the plain old html error of a missing view.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;So what changed?&lt;/strong&gt; &lt;/p&gt;
&lt;p&gt;The variable &amp;#8220;&lt;strong&gt;$this-&amp;gt;view&lt;/strong&gt;&amp;#8221; which was used in Cake1 was replaced by &lt;strong&gt;$this-&amp;gt;viewClass&lt;/strong&gt; in Cake2. This was the number one cause of the problems.&lt;/p&gt;
&lt;p&gt;Other cause, was the plugin not being loaded using the CakePlugin system:&lt;/p&gt;
&lt;p&gt;&lt;code&gt; &lt;/code&gt;&lt;/p&gt;
&lt;pre class="brush: php"&gt;CakePlugin::load('JsonView');&lt;/pre&gt;
&lt;p&gt;&lt;code&gt; &lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;NOTE - &lt;/strong&gt;Don&amp;#8217;t forget to set the response type too!&lt;/p&gt;
&lt;pre class="brush: php"&gt;// set content-type to application/json&lt;br/&gt;$this-&amp;gt;response&amp;gt;type('json', 'application/json');&lt;/pre&gt;</description><link>http://vtek.nl/post/16762104308</link><guid>http://vtek.nl/post/16762104308</guid><pubDate>Mon, 30 Jan 2012 10:41:00 -0500</pubDate><category>CakePHP</category><category>Cake2</category><category>JsonView</category></item><item><title>Controller could not be found - Cake2 migration</title><description>&lt;p&gt;Today I&amp;#8217;m migrating one of our webapplications from Cakephp 1.3 to Cakephp 2.0.5.&lt;/p&gt;
&lt;p&gt;The upgrade itself was performed by calling the shell command script:&lt;/p&gt;
&lt;pre class="brush: bash"&gt;cake upgrade all&lt;/pre&gt;
&lt;p&gt;But one thing I&amp;#8217;ve been unable to find googling around was the answer to the error&lt;/p&gt;
&lt;pre class="brush: bash"&gt;Controller could not be found&lt;/pre&gt;
&lt;p&gt;Luckily I printed out the migration guide from &lt;a href="http://book.cakephp.org"&gt;http://book.cakephp.org&lt;/a&gt; , where this section of Routing changes pointed out that I&amp;#8217;d had to &lt;strong&gt;add &lt;/strong&gt;the following statement:&lt;/p&gt;
&lt;pre class="brush: php"&gt;require CAKE . 'Config' . DS . 'routes.php';
&lt;/pre&gt;
&lt;p&gt;This solves the problem of &amp;#8220;Controller could not be found&amp;#8221;&lt;/p&gt;</description><link>http://vtek.nl/post/16755856653</link><guid>http://vtek.nl/post/16755856653</guid><pubDate>Mon, 30 Jan 2012 06:10:00 -0500</pubDate><category>CakePHP</category><category>Cake1</category><category>Cake2</category></item><item><title>Bootstrap your CSS</title><description>&lt;p&gt;A lot of webdevelopers do repeating tasks on each project they make. One of these repeating tasks is building your CSS too make the project look great! With bootstrap - which is a project of twitter - most of all CSS styling is already done for you and enables you to easily extend it.&lt;/p&gt;
&lt;p&gt;You can find Bootstrap at&amp;#160;:&lt;br/&gt;&lt;a href="http://twitter.github.com/bootstrap/"&gt;&lt;a href="http://twitter.github.com/bootstrap/"&gt;http://twitter.github.com/bootstrap/&lt;/a&gt;&lt;/a&gt;&lt;/p&gt;</description><link>http://vtek.nl/post/16416666563</link><guid>http://vtek.nl/post/16416666563</guid><pubDate>Tue, 24 Jan 2012 14:00:06 -0500</pubDate></item><item><title> TinyMCE - Uncaught TypeError: cannot call method 'push' + spellChecker</title><description>&lt;p&gt;Recently I tried to integrate the php spellchecker of TinyMCE into a project we&amp;#8217;re working on, when I stumbled upon the error:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;uncaught typeerror cannot call method &amp;#8216;push&amp;#8217;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Googling around I found the solution to the problem by upgrading the TinyMCE package to a newer version (3.4.5). Hope it helps - because I didn&amp;#8217;t found that much information on the internet about it.&lt;/p&gt;</description><link>http://vtek.nl/post/16416650669</link><guid>http://vtek.nl/post/16416650669</guid><pubDate>Tue, 24 Jan 2012 13:59:42 -0500</pubDate></item><item><title>Trim UTF8 PHP</title><description>&lt;p&gt;If you trim files that we&amp;#8217;re exported using UTF8 encoding then be carefull that you also trim the non-breaking spaces in it. The default options of trim() do not include this, so you have to use the following code to be sure to also trim them:&lt;/p&gt;
&lt;pre class="brush: php"&gt;// turn non breaking space into 'normal' string
// to behave exactly like a non-breaking space
$myHTML = "&amp;amp;nbsp;abc";&lt;br/&gt;
$nbSpace = array_flip(get_html_translation_table(HTML_ENTITIES, ENT_QUOTES));&lt;br/&gt;
$converted = strtr($myHTML, $nbSpace);&lt;br/&gt;
// trim utf8 non breaking spaces&lt;br/&gt;
$converted = trim($converted,chr(0xC2).chr(0xA0));
&lt;/pre&gt;</description><link>http://vtek.nl/post/16416586155</link><guid>http://vtek.nl/post/16416586155</guid><pubDate>Tue, 24 Jan 2012 13:58:00 -0500</pubDate></item><item><title>Iterating through an object</title><description>&lt;p&gt;Did you knew that you could iterate through an objects variables? Well I did, but I already forgot that it was possible.&lt;/p&gt;
&lt;p&gt;Take a look at the following class:&lt;/p&gt;
&lt;pre class="brush: php"&gt;&amp;lt;?php

class Car {
    public $tires = 4;
    public $doors = 5;
    public $color = "black";
    public $manufacturer = "Ferrari";
    protected $secret = "This is something you may not read";
}

&lt;/pre&gt;
&lt;p&gt;If you use the class mentioned above in some other file, you can iterate through its variables like:&lt;/p&gt;
&lt;pre class="brush: php"&gt;&amp;lt;?php

require_once 'car.class.php';

$car = new Car();
foreach($car as $car_detail =&amp;gt; $value) {
    print $car_detail." =&amp;gt; ".$value." &amp;lt;br&amp;gt;";
}

&lt;/pre&gt;
&lt;p&gt;This results in the output of:&lt;/p&gt;
&lt;pre class="brush: php"&gt;&amp;lt;?php&lt;/pre&gt;
&lt;pre class="brush: php"&gt;tires =&amp;gt; 4
doors =&amp;gt; 5
color =&amp;gt; black
manufacturer =&amp;gt; Ferrari
&lt;/pre&gt;
&lt;p&gt;If you paid really good attention to the class, you might notice that the secret variable is NOT included in our output. This is completely normal like, you cannot access the variable directly when it&amp;#8217;s a protected variable.&lt;/p&gt;</description><link>http://vtek.nl/post/16416472602</link><guid>http://vtek.nl/post/16416472602</guid><pubDate>Tue, 24 Jan 2012 13:55:00 -0500</pubDate></item><item><title>MVC in Zend Framework</title><description>&lt;p&gt;In this post I&amp;#8217;ll try to explain the implementation of MVC (Model-View-Controller) in the Zend Framework. If you are not familiar with Zend Framework, you might read the &lt;a href="http://www.vtek.nl/introduction-to-zend-framework.html" title="Introduction to Zend Framework"&gt;Introduction to Zend Framework&lt;/a&gt; post&lt;/p&gt;
&lt;p&gt;I assume you already know the idea behind the Model-View-Controller idea. If not please read the section below - or the MVC section on &lt;a href="http://framework.zend.com/manual/en/learning.quickstart.intro.html" title="MVC Introduction Zend Framework"&gt;this page&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;&lt;strong&gt;MVC Quick-Start&lt;/strong&gt;&lt;/h3&gt;
&lt;p&gt;In short Model-View-Controller comes down to this:&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;&lt;em&gt;Model&lt;/em&gt; - This is the part of your application that defines its basic functionality behind a set of abstractions. Data access routines and some business logic can be defined in the model.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;View&lt;/em&gt; - Views define exactly what is presented to the user. Usually controllers pass data to each view to render in some format. Views will often collect data from the user, as well. This is where you&amp;#8217;re likely to find HTML markup in your MVC applications.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Controller&lt;/em&gt; - Controllers bind the whole pattern together. They manipulate models, decide which view to display based on the user&amp;#8217;s request and other factors, pass along the data that each view will need, or hand off control to another controller entirely. Most MVC experts recommend &lt;a href="http://weblog.jamisbuck.org/2006/10/18/skinny-controller-fat-model"&gt;» keeping controllers as skinny as possible&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;&lt;p&gt;&lt;strong&gt;Frontcontroller&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Zend Framework is not only using the MVC design pattern, but it&amp;#8217;s also using the Frontcontroller design pattern.&lt;/p&gt;
&lt;p&gt;The Frontcontroller design pattern requires that all requests are processed through one file - which is a very common practice in a lot of open source webapplications (like Drupal, Typo3, etc.). In most webapplications this is done by using the mod_rewrite module (or similar) to rewrite everything to a file called &lt;em&gt;index.php&lt;/em&gt;. One big advantage of this design pattern is that for example, Authorization can be easily implemented into the system.&lt;/p&gt;
&lt;p&gt;In Zend Framework this &lt;em&gt;index.php&lt;/em&gt; takes care that the Frontcontroller is being instantiated.&lt;/p&gt;
&lt;h3&gt;&lt;strong&gt;Actions and controllers&lt;/strong&gt;&lt;/h3&gt;
&lt;p&gt;Using only one controller (the Frontcontroller) would result in large unmaintainable mess with too many methods.&lt;/p&gt;
&lt;p&gt;That&amp;#8217;s why we use multiple controllers in Zend Framework to split up the different parts of the application, each in its own controller. For example if you want to build a blog, you might build a BlogPostController where all functionality related to blogposts resides. Every task like creating, deleting or modifying a blogpost is called an &lt;em&gt;action&lt;/em&gt; in Zend Framework.&lt;/p&gt;
&lt;p&gt;To return to our example of a BlogPostController, that controller will look like this:&lt;/p&gt;
&lt;p&gt;[php]&lt;/p&gt;
&lt;p&gt;&amp;lt;?php&lt;/p&gt;
&lt;p&gt;class BlogPostController extends Zend_Controller_Action {&lt;/p&gt;
&lt;p&gt;// method that takes care of creating a blogpost&lt;br/&gt;public function createAction() { }&lt;/p&gt;
&lt;p&gt;// method that takes care of modifying a blogpost&lt;br/&gt;public function editAction() { }&lt;/p&gt;
&lt;p&gt;// method that takes care of deleting a blogpost&lt;br/&gt;public function deleteAction() { }&lt;/p&gt;
&lt;p&gt;// method that takes care of listing blogposts&lt;br/&gt;public function listAction() { }&lt;/p&gt;
&lt;p&gt;}&lt;/p&gt;
&lt;p&gt;[/php]&lt;/p&gt;
&lt;h3&gt;&lt;strong&gt;Routing and dispatching&lt;/strong&gt;&lt;/h3&gt;
&lt;p&gt;In Zend Framework each action has its own URL. Through the naming convention of controllerclasses and actions, Zend Framework is capable of translating an URL to the corresponding controllerclass and action. The translation process from URL to Controller/Action is called &lt;em&gt;Routing. &lt;/em&gt;The process that calls the specific controller and action, based on the translated request by the router, is called &lt;em&gt;dispatching.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;The request-object ( translated request from the router ) is being passed to the controller from the dispatcher. This request-object is being instantiated by the Frontcontroller, being passed to the router class to be filled with request information and at last being passed from the dispatcher to the corresponding controller.&lt;/p&gt;
&lt;p&gt;Below you will find an image that shows the total ZF MVC process.&lt;/p&gt;
&lt;h3&gt;&lt;strong&gt;Views&lt;/strong&gt;&lt;/h3&gt;
&lt;p&gt;I will write a dedicated post about views in Zend Framework, you will find this later on.&lt;/p&gt;</description><link>http://vtek.nl/post/16416362178</link><guid>http://vtek.nl/post/16416362178</guid><pubDate>Tue, 24 Jan 2012 13:54:31 -0500</pubDate></item></channel></rss>

