Backup MySQL Databases

If you are running a database driven website then your data sitting in MySQL database id most important for you. In most of shared hosting there is no provision for scheduled backup of databases. So I have written a script to take backup of all databases associated with the account.

CakePHP to Red Hat’s Openshift

There is only 6 easy steps to deploy your application to cloud.

Step 1 : Sign Up

Just visit to openshift and sign up a new account.

Step 2 : Install client tool

For installation instruction of client visit here

Step 3 : Create domain

Domain is the unique namespace for every account. Execute following command to create your domain

Step 4 : Create application

app name is the name of your application ant app type is the type of application you want to create. For a php application we execute following command:

Step 5 : Add MySQL to your application

Step 6 : Deploy your application to cloud
Once the application is created, it needs to deployed to cloud. After execution of step 4, a folder with the application name is created in current directory. Goto current directory and add cakephp to it.

 

You can access your application from the URL :

http://mycake-mydomain.rhcloud.com

File Upload in CakePHP

In this post I will describe how to upload images in CakePHP. It will automatically upload and move the uploaded file to the wanted location. It will automatically rename the file if there is another file with same name exist. A lot of other features are also available.

  • Download Upload Component file and copy it to the location app/Controller/Component/UploadComponent.php
  • Initialize
  • Your add action would looks like:
  • We have setup our controller. Now its time to setup view file add.ctp. The file file should look like following:
  • All done.

UploadComponent class file is well document so you can always find all configuration setting for the uploaded images.