Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Here's my blog post on migrating from 1.3 to 2.x : <a href="http://www.forceflow.be/2011/11/12/migrating-from-cakephp-1-3-to-2-0/" rel="nofollow">http://www.forceflow.be/2011/11/12/migrating-from-cakephp-1-3-to-2-0/</a></p> <p>For future reference, I've included the content of that post here. Enjoy!</p> <p><strong>Getting started</strong></p> <p>There are several ways to update, but for small to medium projects, I found it best to just unzip the new CakePHP 2 structure, and manually copy over your Controllers and Views to their new folders. Mind you that the folder structure has changed significantly. For instance, the controllers map is now Controller. Pay attention to where you copy the files – don’t worry about the filenames themselves, we’ll come to that later.</p> <p>Make sure you update core.php and database.php (now located in (cakephp root)/app/Config) with the values for your application. Make sure to copy over the salt and cipherseed values from your old installation too, since CakePHP will continue whining when you use the default ones – it’s a security risk. Also, to get the database connection up and running again, the syntax was changed:</p> <pre><code>'driver' =&gt; 'mysqli' </code></pre> <p>becomes</p> <pre><code>'datasource' =&gt; 'Database/Mysql' </code></pre> <p><strong>Bulk work: Upgrade via console</strong></p> <p>In order to rename all your app files to the new CakePHP file structure, there is a console command. New to CakePHP 2.0 is that each application now has its own console. Navigate to your app’s console (not the Console in /lib/Cake !) in /app/Console, make sure the Console command is executable by doing a chmod +x on it, and execute:</p> <pre><code>./cake upgrade all </code></pre> <p>This will rename all files to the new cake standard, and update all references within your PHP code.</p> <p><strong>Cleaning Up</strong></p> <p>Unfortunately, this is not the end. Chances are thin that your code will just run fine now. Have a look at the CakePHP 2.0 migration guide for more information. I’ll sum up the issues I’ve dealt with the most here:</p> <p>In your views, you now have to address the Helper classes through the <em>$this</em> object. No more calling, for example </p> <pre><code>$html-&gt;link( </code></pre> <p>, it’s </p> <pre><code>$this-&gt;Html-&gt;link( </code></pre> <p>now, sir.</p> <p>Also:</p> <ul> <li>The <em>JavascriptHelper</em> is now called JsHelper.</li> <li>The <em>Auth</em> component has changed significantly. The <em>login()</em> action is not automatically added when you use the component, you’ve got to manually specify it now. Check the new Auth component documentation for more info.</li> </ul> <p>The <em>AjaxHelper</em> has been removed, along with the handy functions for AJAX-style searches, like <em>observefield</em>. I’ve cooked my own <em>observefield</em> using jQuery – use at your own risk. I serialise a form, which in this case holds a query input box which allows me to do a live-search-and-update for Reservations.</p> <pre><code>$this-&gt;Js-&gt;get('#query')-&gt;event('keyup', $this-&gt;Js-&gt;request( array('controller' =&gt; 'sales','action' =&gt; 'searchReservations', $event['Event']['id']), array( 'update' =&gt; '#view', 'async' =&gt; true, 'dataExpression' =&gt; true, 'method' =&gt; 'post', 'data' =&gt; $this-&gt;Js-&gt;serializeForm(array('isForm' =&gt; false, 'inline' =&gt; true))) </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload