Reduce Image Size To 10KB Using PHP code

//Copy this function in App Controller in cakePHP public function resizeImage($sourceImage, $targetImage, $maxWidth, $maxHeight, $quality = 80) { // Obtain image from given source file. /* if (!$image = @imagecreatefromjpeg($sourceImage)) { return false; } */ $info = getimagesize($sourceImage); if ($info[‘mime’] == ‘image/jpeg’) $image = imagecreatefromjpeg($sourceImage); elseif ($info[‘mime’] == ‘image/gif’) $image = imagecreatefromgif($sourceImage); elseif ($info[‘mime’] == […]

How to Reduce or Compress Image File Size Using PHP code?

<?php function compress($source, $destination, $quality) { $info = getimagesize($source); if ($info[‘mime’] == ‘image/jpeg’) $image = imagecreatefromjpeg($source); elseif ($info[‘mime’] == ‘image/gif’) $image = imagecreatefromgif($source); elseif ($info[‘mime’] == ‘image/png’) $image = imagecreatefrompng($source); imagejpeg($image, $destination, $quality); return $destination; } $source_img = ‘source.jpg’; $destination_img = ‘destination .jpg’; $d = compress($source_img, $destination_img, 90); ?>

Code Generation with Bake in cakePHP

The cake console is run using the PHP CLI (command line interface). If you have problems running the script, ensure that: You have the PHP CLI installed and that it has the proper modules enabled (eg: MySQL, intl). Users also might have issues if the database host is ‘localhost’ and should try ‘’ instead, as […]

Authentication and Authorization in cakePHP 3.4

Following our Blog Tutorial example, imagine we wanted to secure access to certain URLs, based on the logged-in user. We also have another requirement: to allow our blog to have multiple authors who can create, edit, and delete their own articles while disallowing other authors from making changes to articles they do not own. Creating All User-Related […]

How to install latest version of cakephp by composer

Requirements: HTTP Server for example Apache: Having mod rewrite is preferred but no meand requied. PHP 5.9 or greater (including php 7). mbstring php extension. intl extention (php_intl). Install Composer After that run command prompt and go to xampp/htdocs like I have xampp setup in E drive so run command into command prompt E: cd xampp […]

Export database using PHP

<?php //ENTER THE RELEVANT INFO BELOW $mysqlUserName = “Your Username”; $mysqlPassword = “Your Password”; $mysqlHostName = “Your Host”; $DbName = “Your Database Name here”; $backup_name = “mybackup.sql”; $tables = “Your tables”; //or add 5th parameter(array) of specific tables: array(“mytable1″,”mytable2″,”mytable3”) for multiple tables Export_Database($mysqlHostName,$mysqlUserName,$mysqlPassword,$DbName, $tables=false, $backup_name=false ); function Export_Database($host,$user,$pass,$name, $tables=false, $backup_name=false ) { $mysqli = new […]

Install Laravel 5 Framework on Ubuntu

Introduction Laravel is an Open Source PHP framework designed for the fast development of MVC Web applications in PHP. This article will help you to install Laravel 5 PHP framework on Ubuntu operating systems. Installing Composer I assume PHP, Apache and MySQL are already installed on your environment. First you need to install Composer PHP […]

What is CakePHP? Why Use it?

CakePHP is a free, open-source, rapid development framework forPHP. It’s a foundational structure for programmers to create web applications. Our primary goal is to enable you to work in a structured and rapid manner–without loss of flexibility. CakePHP takes the monotony out of web development. We provide you with all the tools you need to […]

How to setup a Cron Job for CakePHP 2.x on shared hosting

The Initial Setup Before begining the tutorial, its important to understand CakePHP Console and Shells. You can read about them in the CakePHP 2.x Cookbook. Basically, console applications are ideal for handling a variety of background tasks such as maintenance, and completing work outside of the request-response cycle. Using the console, you can create shells […]