Featured
-
How Regression Testing Detects Integral Errors In Business Processes
Humans are forever changing and evolving and so to
by kristina.rigina -
Get Display Banner Advertising Opportunity on FindNerd Platform
“Do you have a product or service that nee
by manoj.rawat -
Android O Released with Top 7 New Features for App Developers
Android was founded by Andy Rubin, Rich Miner, Nic
by sudhanshu.tripathi -
Top 5 Features That Make Laravel the Best PHP Framework for Development
Laravel is a free open source Web Framework of PHP
by abhishek.tiwari.458 -
Objective C or Swift - Which Technology to Learn for iOS Development?
Swift programming language is completely based on
by siddharth.sindhi
Tags
What is the best way to create global variables in CakePHP?
Hello All,
In this blog we will discuss creation of global variables in CakePhp.
Sometimes there is a need to access a variable everytime in the application, so instead of declaring it again and again we can declare the variable globally ...
How to speed up your CakePHP Website
Hello Readers,
These are some techniques to speed up the cakephp website:-
1. Upgrade versions regularly
When you work on cakephp website.You need to upgrade your Cake website to the latest version in order to keep it performing at its be...
How to pass variables from CakePHP to JavaScript
Hello All,
In this blog we will discuss about how to pass CakePhp variable in javascript.
So firstly we will be initiallizing a variable in the function below i.e abc(),then set this variable in for the ctp file.
Example-
function abc...
How to enable CakePHP's SQL dump in the controller
Hello All,
In this blog we will discuss about how to enable the SQL dump in your CakePhp's controller.
For this you have to write in below code in your controller function-
$db=ConnectionManager::getDataSource('default');
$...
Why I switched from CakePHP to Symfony2
CakePHP or Symphony2? This is a common question that are arising in the developers community and topic lists this may lead developers sometimes get undermine to clarify users as which is the best framework in php.
Lets talk about Symphony2...
base_url in CakePHP
Hello if you want current base url(Include Domain) or Get current url.
Lets take an example
http:// localhost/root_folder.
you just need to write the following code below:-
<?php echo $this->Html->url('/', true)?>
How to disable caching completely in Cakephp?
Hello if you want to disable you website's caching complety you just need to write configure code in core.php file
ex
You will have to look into /app/config/core.php and look for the line
Open app/config/core.php file and try to find
Con...
How to set checkbox to checked in CakePhp
Hi All,
In this blog we will discuss about how to set checkbox checked in cakePhp application.
You should set the checkbox checked/selected with the 'selected' option.
For example-
You can find a list of categories from the database t...
How to change user password in CakePhp using Auth
Hi All,
In this blog we will discuss how to change the password in cakePhp by using Auth.
Firstly, in your model you have to define a function beforeSave which will hash your password to auth password, you can do this by writing the below co...
Submitting current timestamp in CakePHP
Hi
If you want to send curret_timestamp, you can store it by using function below.
DboSource::expression('NOW()');
Lets take an example, save your timestamp in a key 'your_datetime_field'
$this->data['SomeModel']['your_datetime_f...
Checking an Ajax request incakephp
For checking the ajax request one have to use the request handler component.
In Cake PHP to obtain the information about the HTTP request as a form of AJAX which are requested into your application for that the Component Request Handler is use...
How to use another model in current model using cakephp?
Hi
If you want a condition where you can load another model inside you model. you can do as I code, see the example below
App::import('Model', 'MyModel'); $my_model = new MyModel();
Or you can write
$this->SomeModel->MyModel;...
How to load Vendors in CakePhp
Loading vendors usually means you are loading packages , so in CakePHP you can use:
App::import('Vendor','');
As an expample if you want to load a vendor named recurly which is saved in your app's Vendor folder and you want to access the...
Updating one field in database using CakePhp
Updation in CakePHP is basically based on knowing the primary key(Id) of the records one wants to change/edit.
You can update a field in CakePhp by two ways:-
a)By using saveField method
$this->ModelName->id=$id;
$this->Mode...
cakephp excel/csv export component
Hello,
If you want to add CSV export component using cake php, for that you can do by following steps:-
First take the controller file and create an action, the code will go like this:-
<?php
class Export_my_dataController extend...
What is the equivalent to getLastInsertId() in Cakephp?
Hello if you want to get last insert id or something equivalent to this you can try following steps:-
Lets take this example, Here I just inserted the field in column
$data = array('menuName' =$_REQUEST['menuname'])
$this->Menu...
What is a .ctp file used for in CakePHP?
CakePHP provides user to do advance view designing and making custom architecture for designing, for quick web developments. The CTP file extension is associated with the CakePHP. Ctp file contains template CakePHP template.
It is as same as a...
How to get complete current URL using Cakephp Framework in PHP
If you need to print the complete current url you can do following steps.
1. In the view file code will go like this:
<?php echo $this->here; ?>
This syntax'll give you the absolute url starting from hostname i.e. /controller/...
Facebook login using CakePHP
To create a Facebook login using cakephp we need facebook app with appId, apiKey and secret key which are required for facebook login to work. Facebook connect and enables users to authenticate your application instantly with a Facebook Account.
...
How to write a join query across multiple tables in CakePHP?
Fetching data from the database takes a lot time process. Eventually when you need to combine multiple tables in order to fetch the data, reducing database calls becomes very meaningful.
Although in CakePhp's model, by default if the associat...
Redirect not found page to home page in CakePHP
When we try a wrong URL in cakephp then it displays an error page with error message:
"Controller class could not be found".
We can override this message and also can handle this exception using Error.php of cake. We can override this func...
Creating background Tasks with Appshell and CakePHP
Hello Friends,
Sometime we need to run some background tasks using cakephp without user interaction or delayed response to user from server.
For this we can use CAKEPHP AppShell utility.
Syntax:
/path/to/cake/console/cake -app /path/...
How to fix TCPDF file opening issue on smart devices
Hello Friends,
If you are using TCPDF( A Plugin used to generate PDf files) then sometime you may face that this files are not opening in smart devices. You may see some garbage data instead of pdf file.
Then do not worry, just put a exit; af...
Add prefix to urls in CakePHP
CakePHP has power to do a lot with conventions by using routes. Its additionally possible to utilize custom prefixes adjacent to your admin routes for extra flexibility. Prefix routing can be enabled from within the core configuration file by set...
Using multiple database connections in CakePHP model
Hello Readers,
Till now we may develop our appication with single database . Is their any ways to integrate our application with multiple databases ? . Yes we have.
There are methods to use multiple databases for development and for produc...
InterNationalization in CakePHP
Hello Readers ,
Today we will learn about the concept of " InterNationalization in CakePHP " .
"InterNationalization" simply means if you are making an application and you wants to make that applications to reach a larger audience to cater...
10 Useful Plugins in CakePhp
CakePHP allows us to set up a combination of models,views ,controllers and release them as a packaged application called Plugins which can be used in the CakePHP applications.
Some of the useful Plugins in CakePhp web application are as foll...
Protecting your CakePhp application against Sql injection
SQL injection is a technique where malicious users can inject the SQL commands /queries into an SQL statement, resulting in false input of the web page and the security of a web application.
Eventually CakePhp already protects the application...
How to save session in Mysql database using CakePhp?
Sometimes the web infrastructure do not share session data with each other. For this reason, sessions may be lost between requests.
Using MySQL effectively ripps out this problem, as all session data is directed to and from the database server ...
Solr integration in CakePHP with solarium client
Hi,
Before using Solr in CakePHP, we need to decide which Solr client we are going to use. After doing lots of search I finalized Solarium which is up to date and easy to use.
For Installing Solr, I used following link:
http://www.shayande...
Enable CakePHP with multilingual support and create PO file using cakephp-script
Enabling multilingual support and creating po locale files are very easy with cakephp-script.
We can use cakephp console framework for this.
There are few simple steps to create po files first:
1: Navigate to you app folder: cd /path/to/cake...
CakePHP Form Validation Using Ajax
As we know cakephp have not any kind of in-build form validater to check requried fields. So by ajax we can check form validation.
The flow is that first of all we have to submit the form via ajax to controller and check the validation throw c...
If cakephp not cofigured properly
If Cakephp throwing an error:- URL rewriting is not properly configured on your server.
To fix this issue follow below steps:
Check .htaccess files in root directory
Let say you have directory with the name of myproject
then check ....
How to resolve social media login hybridauth error in cakephp
If you facing an error to login through hybridauth and throwing this error(You cannot access this page directly) then you can follow below steps to resolve it.
Please check you session id by php predefined function
session_id();
If ...
How to Make Database Association on Selected Pages In Cakephp
If you want to make Database Association on Selected Pages In Cakephp follow the below steps,
Below code can set association where it require and you can also reduce unnecessary queries firing to database.
Make function in your model and ...
How to get Cakephp All Fields From Database on live server / localhost
If Cakephp not getting newly added columns from database on live server / localhost to solve this issue use below steps:
Go to app / config.php the edit file and set
Configure::write('debug',0);
to
Configure::...
Paypal: Create Recurring Payments Profile Working Code
This code use to deduct amount automatically from paypal buyers account. It is something like advance payment mode. If user agree with automatically deduction when he / she paying through paypal then amount will deduct according to billing period...
How to download file using PHP script
We use this script to download a file from a given define file path location
In this script we are using two variable:
1:) $fileName // for file name with path.
2:)$title //for file name changed in you given title name.
<?...
Advantage of "loadModel" over "$uses"
Advantage of loadModel over uses
While using "$uses", many unrelated model gets loaded. So it's best practice to use it only when it is needed through out the controller. If you only need it randomly then loadModel(). Another way of loading a...
Using Containable in CakePHP
Containable behavior was introduced in CakePHP 1.0. It helps you out to find out the data from the associated models/tables in a consistent way.
Containable simplifies the binding operation in your model bindings. To use the new behavior, you...
Passing extra data with push notification
Sometime we do need to send additional data while sending Push-notification on iPhone , this can be easily achieved by adding following line to your code. But one should keep in mind that apple does have a limitation of 144 character while sendin...
Password hasing in CakePHP
CakePHP uses a Security class for hashing the passwords.
I am writing some examples below that will definitely help you out in understanding the different ways of password hashing in CakePHP:
echo "I am md5 CAKE:".Security::hash("dinesh","md5...
Problem with password encryption when moving from core php to cakePHP
Hi all,
I had a requirement to move a project from core php to cakePHP framework. Migrating code was clear as I had to just modify syntax of code-base. But the problem came, when I had to implement login authentication with username and passwo...
Clean ugly HTML
CakePHP do help us a lot with its own 'Form' and 'HTML' helpers but it often outputs some very ugly and hard to read HTML.
This little trick will make it a lot cleaner.
Create a file named app_helper.php in your app's root directory.
Ne...
Solution for error 'The requested address '/' was not found on this server' in cake PHP
If anyone face the error 'The requested address '/' was not found on this server' in cakePHP, then try these two steps:-
Add function date_default_timezone_set() somewhere in you cake/app folder.
If above solution not works then place date_...
Stop browser to cache image ,css, js in cakePHP
core.php (inside /app/config/) has lot of features that help us improve our web application.
Configure::write(Asset.timestamp, force);
Setting the Asset.timestamp to force will add a time value after every css,js and image tag in your HTM...
Unbinding Model in cakePHP
Lets say there are two models named as User and Post. A User hasMany Post, so in our User model we have a relation like this :-
class User extends AppModel{
var $name = User;
var $hasMany = array(Post=>array(foreignKey=>user_...
Using Email or Username to login with auth in cakephp
We seldom need to login into application using Email or Username while using Auth with Cakephp. To achieve this we either need to write customized Auth component or we can achieve the same with the following code :
public function validateUs...
Forming Tree structure in cakephp
Sometime you may need to form a tree structure from the values of the database table.
For Ex-
You may need to form a hierarchy of categories and subcategories like this:
My Categories
Fun
Sport
Surfing
...
How to filter hasMany related model records in cakePHP when using find function?
Lets say we have models User and Friend related by User hasMany Friend relation. If we are required to pull out all users along with their female friends then how do we do that?
Usually people think like this :
$this->User->find('all...