Thursday, 31 May 2018

Image Resize and save by using GD function and Percentage based

<?php
$filename = 'test.jpg';
$percent = .5;
list($width, $height) = getimagesize($filename);
$newwidth = $width * $percent;
$newheight = $height * $percent;
$thumb = imagecreatetruecolor($newwidth, $newheight);
$source = imagecreatefromjpeg($filename);
imagecopyresized($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
$ourFileName = "newtest.jpg";
imagejpeg($thumb, $ourFileName);
imagedestroy($thumb);
?>

Wednesday, 23 May 2018

How to create custom log in cakephp?

1. Add bootstrap for this in below

CakeLog::config('customlog', array('engine' => 'File'));

2. Create log message in custom logfile

CakeLog::write('customlog', 'myArray');

Check now you log directory once created

Friday, 18 May 2018

Mysql dump in terminal mode

For taking Dump : mysqldump -u username -p test> test>

Then Enter Password if prompts for password


For Restoring Dump :  mysql -u username -p test> < test>

Then Enter Password if prompts for password

Now I have restored the dump. So no need to take dump and restore.

scp -r <username>@<domainname/ip address>:/<file path>  <destination path>


For Windows
mysql.exe -uroot -p dbname < dump
you need to do this in xampp/mysql/bin/ path