CakePHP 1.2.0.6311 beta blog tutorial

view a random? 6,825 views

I couldn’t get the current stable version to work online, I think this is because of our .htaccess rules, subdomains and virtual hosting solution - but who knows…

Luckily, I stumbled (not using stumble, but Google) upon a post describing similar issues relating to sub-domain. This post discribed a bug fix, but also mentioned in an update that the fix was not required in the latest beta version of CakePHP. So I thought I’d give it a shot.

I’m very happy to say, the fix worked. But you’ll need to do a few amendments to the cakePHP blog tutorial for it to work in the Beta release. But the great part about the Beta release, is it tells you everything that you are doing wrong - so you don’t need this article… Just get into it.

They’ve added a form helper, which has meant the deprecation of several of the html helper methods, so add.thtml becomes:

<h1>Add Post</h1>
<form method="post" action="<?php echo $html->url('/posts/add')?>">
<p>
Title:
<?php echo $form->text('Post/title', array('size' => '40'))?>
<?php echo $form->error('Post/title', 'Title is required.') ?>
</p>
<p>
Body:
<?php echo $form->textarea('Post/body', array('rows'=>'10')) ?>
<?php echo $form->error('Post/body', 'Body is required.') ?>
</p>
<p>
<?php echo $form->submit('Save') ?>
</p>
</form>

and edit.thtml becomes:

<h1>Edit Post</h1>
<form method="post" action="<?php echo $html->url('/posts/edit')?>">
<?php echo $form->hidden('Post/id'); ?>
<p>
Title:
<?php echo $form->text('Post/title', array('size' => '40'))?>
<?php echo $form->error('Post/title', 'Title is required.') ?>
</p>
<p>
Body:
<?php echo $form->textarea('Post/body', array('rows'=>'10')) ?>
<?php echo $form->error('Post/body', 'Body is required.') ?>
</p>
<p>
<?php echo $form->submit('Save') ?>
</p>
</form>

There are a couple of other changes, for example you are recommended to change the security.salt for your application in the file cake/app/config/core.php, just slap some random sequence in here. Configure::write(’Security.salt’, ‘RandomStringofLettersAndNumbers’)

The database array has some extra options:

var $default = array(
'driver' => 'mysql',
'persistent' => false,
'host' => 'localhost',
'port' => '',
'login' => 'user',
'password' => 'password',
'database' => 'database_name',
'schema' => '',
'prefix' => '',
'encoding' => ''
);

And the routes.php should be changed to:
Router::connect ('/', array('controller'=>'posts', 'action'=>'index'));

Update: You can check out the code from our subversion source repository, it looks a lot better there. The project copies the edited files over a clean CakePHP installation. It also uses Ant to configure the site specific settings, so you can use the same files for Local and Server deployments, without writing request logic overhead into your code.

Last 5 posts by James Little
Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • del.icio.us
  • Facebook
  • Google
  • MisterWong
  • Reddit
  • Scoopit
  • StumbleUpon
  • Technorati
  • rss

Related Posts:

One Trackback

  1. By Anonymous on February 25, 2008 at 1:21 pm

    CakePHP 1.2.0.6311 beta blog tutorial…

    You’ll need to do a few amendments to the cakePHP blog tutorial for it to work in the Beta release. But the great part about the Beta release, is it tells you everything that you are doing wrong - so you don’t need this article… Just get into it….

Post a Comment

Your email is never published nor shared.