2014-07-07

Baking with CakePHP on Ubuntu

OK so there are several blog posts out there on getting started with CakePHP and Ubuntu and installing it from scratch. Ubuntu does provide CakePHP in its repositories, and I've been trying to get to grips with going through the tutorial for the Blog application in the tutorial on http://book.cakephp.org/.

The example code blocks include the path for a user "ian" creating the "blog" application from the tutorial. This post only details the steps needed to get the application working correctly.

Preparation

As with everything else, Ubuntu doesn't have the latest & greatest in their repositories. 12.04 has 1.3.7 whereas 14.04 has 1.3.14. The one advantage of this is that this post will apply to a wide range if installations! :-)

To start you obviously need CakePHP installed. This is as simple as running
  sudo apt-get install cakephp cakephp-scripts  

This should install all dependencies too. My standard install has Apache, PHP and MySQL installed anyway.
My usual development route is to create in my userdir then release once I'm happy with it. This means that you need to enable the userdir nad rewrite mods in apache and then enable the php engine in the userdirs.
sudo a2enmod userdir
sudo a2enmod rewrite
vi /etc/apache2/mods-enabled/userdir.conf
  Change
    AllowOverride All
vi /etc/apache2/mods-enabled/php5.conf
  Comment out 
#            php_admin_value engine Off

Now we're ready to start baking!

Baking

So, create a public_html directory in your home directory and cd into it then run
  cake bake blog  

You'll then be presented with something like
Welcome to CakePHP v1.3.14 Console
---------------------------------------------------------------
App : public_html
Path: /home/ian/public_html
---------------------------------------------------------------
Bake Project
Skel Directory: /usr/share/php/cake/console/templates/skel
Will be copied to: /home/ian/public_html/blog
---------------------------------------------------------------
Look okay? (y/n/q)

Follow the prompts to set up the database configuration. NOTE:- Leave the database connection name as default.

Edit .htaccess

You need to add the following line to the .htaccess file in the application root directory and the webroot directory. Edit it to match the URL you enter to get the the application root in your web browser.

RewriteBase /~ian/blog/

Edit the application configuration

Given the path in the Baking section above, you need to edit /home/ian/public_html/blog/webroot/index.php to specify the full path to the directory:-

**
 * The full path to the directory which holds "app", WITHOUT a trailing DS.
 *
 */
        if (!defined('ROOT')) {
                define('ROOT', DS.'home'.DS.'ian'.DS.'public_html');
        }
/**
 * The actual directory name for the "app".
 *
 */
 if (!defined('APP_DIR')) {
  define('APP_DIR', 'blog');
 }

You should now have a working application that you can then enhance as per the Blog tutorial.

2012-10-04

Bran Parkin Cookies

Ingredients
  • 4oz/100g Margarine
  • 2tbsp Golden Syrup
  • 12oz/350g Self Raising Flour
  • 8oz/225g Brown Sugar
  • 2tsp Ginger
  • 1tsp Bicarbonate of Soda
  • 3oz/75g Kellogg's All Bran
  • 1 Egg, beaten
  • ½ tsp Salt
Method

  1. Melt the syrup and margarine together in a small pan
  2. Put the dry ingredients into a mixing bowl
  3. Add the egg and syrup mixture
  4. Mix into a smooth dough
  5. Make into 2 inch balls, flatten slightly
  6. Place on a greased baking tray and bake at 180C (350F) Gas Mark 4
  7. Bake for 15-20 minutes or until golden brown

2012-10-03

Blueberry Oat Cokies


American flour is different from ours. What they call all-purpose flour is closer to our strong bread flour. I find that a mixture of self raising and other strong white or wholemeal flour works perfectly well.
When you bake cookies they spread quite a lot, so leave plenty of room between them. The easiest way to shape them is to take a dessertspoonful of mixture, roughly form them into a ball, pop on to the greased baking tray and then flatten slightly with a fork.


Ingredients
  • 4 oz/100 g butter
  • 4 oz/100 g granulated sugar
  • 4 oz/100 g light soft brown sugar
  • 1 egg
  • 4 oz/ 100 g wholemeal flour
  • 4 oz/100 g self-raising flour
  • 3 oz/75 g porridge oats
  • 1 pkt dried blueberries
Method
  1. Cream the butter and sugar, and beat in the egg. Add the flour mixed with the oats and stir well.
  2. Mix in the blueberries. If the mixture seems a little too stiff, then add a few drops of milk, but be careful not to make it too soft.
  3. Form into dessert spoon-sized balls as described above, and place on the trays.
  4. Bake for 8-10 minutes until golden, then cool on a wire rack.
  5. Eat warm, or cool completely and store in an airtight container.

Cherry Almond Cookies

American flour is different from ours. What they call all-purpose flour is closer to our strong bread flour. I find that a mixture of self raising and other strong white or wholemeal flour works perfectly well.
When you bake cookies they spread quite a lot, so leave plenty of room between them. The easiest way to shape them is to take a dessertspoonful of mixture, roughly form them into a ball, pop on to the greased baking tray and then flatten slightly with a fork.

Ingredients
  • 4 oz/100 g butter
  • 8 oz/200 g granulated sugar
  • 4 oz/100 g strong plain flour
  • 4 od100 g self raising flour
  • 1 egg
  • a few drops almonds essence
  • 4 oz/100 g glace cherries, quartered
  • 2 oz/50 g flaked almonds
Method
  1. Cream the butter and sugar, and add the egg. Mix in the flour and the nuts.
  2. Rinse the cherries in warm water, then dry on kitchen paper. Stir them into the mixture.
  3. Form into dessert spoon-sized balls as described above, and place on the trays.
  4. Bake for 8-10 minutes until golden, then cool on a wire rack.
  5. Eat warm, or cool completely and store in an airtight container.


2012-09-30

The Ultimate Fudge

(Makes about 800g/1 3/4Ib)
  • 400g (1402) tin of sweetened condensed milk
  • 150ml (5fl oz) milk
  • 450g (1lb) demerara sugar
  • 125g (4oz) butter
Variations:
  • 2tbsp dark rum and 125g (402) raisins
  • 75g (302) mixed dried fruit and Chopped nuts
  • 175g (602) plain chocolate
Method:
  1. Gently heat all the ingredients in a large non-stick saucepan.
  2. Bring to the boil and simmer gently for 10-15 minutes, stirring continuously, until it reaches 116°C (240°F) on a sugar thermometer. (Alternatively, test for the ‘soft ball’ stage: drop a little fudge mixture into a jug of cold water. lf a soft ball forms, it is ready.)
  3. Remove from the heat, beat until thick and grainy (about 10 minutes).
  4. If liked, add any of the variations suggested above at this stage.
  5. Pour into a greased 18cm (7in) square tin and leave to cool.
  6. When cold, cut into squares and store in an airtight tin for up to a month.

Toffee Krispies

(Makes 20)
  • 75g (3oz) butter
  • 150g (5oz) sugar
  • 400g (14oz) tin of condensed milk
  • 1tbsp golden syrup
  • 50g (2oz) Rice Krispies
Method:
  1. Melt the butter and sugar in a saucepan, add the condensed milk and syrup
  2. Heat gently, stirring continuously and bring to the boil.
  3. Simmer for 5 minutes, then stir in the Rice Krispies and pour into a lightly greased 18cm (7in) square tin.
  4. Leave the mixture to set in a cool place, then cut into squares.
  5. Store in an airtight container for up to a week.

Coconut Ice

(Makes 1.25kg/27/2lb)
  • 400g (14oz) tin of sweetened condensed milk
  • 500g1 (1 lb 2oz) icing sugar, sifted, plus extra to dust
  • 350g (12oz) desiccated coconut
  • A few drops of red food colouring
Method:
  1. Mix together the milk and the icing sugar. Stir in the coconut (the mixture should be stiff) and divide in half.
  2. Colour half of the mixture pale pink using a few drops of red food colouring. Shape the pink and white mixtures into two identically shaped bars and press firmly together.
  3. Dust a chopping board with a coating of icing sugar and leave the coconut ice on it until firm.
  4. Cut into pieces. Store in an airtight container for 2-3 weeks.