Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 

How to bind model at runtime in cakephp

Hello guys, Most of time we need to bind model at runtime, So cakephp provides inbuilt function bindModel(). Using this function we can associates model according to requirement . Using this technique we dont need to association in Model. I...

Cakephp ajax pagination using jquery

Using default pagination helper in cakephp. <div class="paginator"> <?php echo $paginator->first(' First ', null, null, array('class' => 'disabled')); ?> <?php echo $paginator->prev('Previous ', null,...

User authorization in Cakephp

In order to use the auth component. You have to add the component to the AppController. (/app/Controller/AppController.php) var $components = array('Auth'); Define $components array in your controller. public $components = array( '...

Remember me in Cakephp

In a portal login page once you check the Remember Me checkbox your login id will be remembered on the browser for 7 days. And when with in a 7 days if you login on the same browser, you will get logged out. Use the below code in order to use ...

How to configure Database in CakePHP

CakePHP database configuration details are in a file that is located at app/Config/database.php. the database file. You can edit the file in the notepad or sublime and can edit the feilds by which it will be connected to the database. Here w...

How to add Captcha with CakePHP

We can add captcha for blocking spams robots accessing our site or application. We can add captcha in our web application and website by using the below code -> <?php App::uses('AppController', 'Controller'); class PagesController exte...

What are Hooks in CakePHP ?

Hooks are the functions that we can call before and after doing any task in Models ( database related ). Like after finding data, before saving data etc. e.g beforeSave(), afterSave(), beforeFind(), afterFind() etc. <?php class Classnam...

How to join table in cakephp

Most of cakephp developer write custom query to join two table of database but cakephp provides best facility to join more than one two table in single query using association . Let see an Example:- SELECT * FROM `messages` INNER JOIN user...

find and save the records by using cakePHP models

make a controller name Pagescontroller.php and paste the following below code <?php class PagesController extends AppController { public $name = 'Pages'; /* Use Customer model */ public $uses = array('Customer'); ...

How to save data in CakePHP

This is a very simple application in cake php for saving the data into database. We can simple make it by making the database and connecting it to cake php. After making the database and tables we can use this code for saving the data input in...

HABTM in cakephp?

HABTM stands for Has And Belongs To Many. Its is a cake php associations that we defined in a models for accesing associated data across different entities over the database tables. Example - A product have more then one tags, and in the s...

CakePHP built-in sessions

CakePHP have several In-built sessions configurations. We can use these sessions as the basis or can create a fully custom solution for that. To use defaults inbuilt sessions, we can simply set the defaults key to the name and can override any s...

Exceptions in CakePHP

CakePHP uses the exceptions internally to show the logical cake PHP errors. All of the exceptions that occur in CakePHP raises a CakeException. CakePHP is also having the number of exception classes that we can use for HTTP errors. For con...

How To Install Plugins in Cake PHP

There are four ways to install a plugin in CakePHP-> Plugin install through Composer Manually plugin install Plugin installed As Git Submodule By Git Cloning 1- Manually To install a plugin manually in CakePHP, you just have to m...

Ubuntu enable mod rewrite in apache server

Go to this directory. etc/apache2/apache2.conf you will find below code with AllowOverride none. <Directory /> Options FollowSymLinks AllowOverride none Require all denied </Directory> <Directory /usr/sh...

.htaccess in Cakephp

Without .htaccess file in cakephp your application will not run. There are 3 different .htaccess files: /var/www/app/webroot/.htaccess <IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{REQUEST&#95;FILENAME} !-d...

Group By in Cakephp

The GROUP BY statement is used in conjunction with the aggregate functions to group the result-set by one or more columns. Below is the possible keys that we use in cakephp query. $params = array( 'conditions' => array...

How to make custom error pages in cakephp

Hello Readers , If any one enters the wrong URL then how to show our custom error page , follow the below code. Exception render need to set as an AppExceptionRender. /app/Config/core.php Configure::write('Exception', array( ...

What is the difference between two vendors folder available in cakephp?

Hello Readers In Cakephp framework (based on MVC) you noticed that there are two vendors folder. 1. One is it is in app folder. 2. Second one is in root folder. Therefore, the use of two vendor folders in Cakephp is that first (whic...

Component & Helper in Cakephp and why are they used?

Hello Readers A component is an independent piece of code written for specific task in cakephp that can be used for Emails, RequestHandling etc. Components is basically a package of logics that are shared between controllers. User also crea...

Features of cakephp

Hello Readers, Below are some of the features of CakePhp: CakePhp is basically a framework which is based on MVC pattern i.e(model view controller). Cakephp is compatible with php version 4 and 5 plus. Cakephp have built in validati...

Naming Conventions in CakePHP- Model, View, and Controller

CakePHP model, view, and controller naming conventions If we have a database with table named users, then following standard Cake PHP naming conventions should be used: 1. For Model filename = User.php classname = User directory...

Determine which submit button has been clicked

If we have two submit buttons and want to detect which one is pressed then simply use post method i.e. $this->request->data. <?php echo $this->Form->create(false); ?> <?php echo $this->Form->text('input'); ?> &l...

how to remove action name from URL in cakephp

Current URL is : http://mysite.com/MyController/view/page1 but if you want something like :http://mysite.com/MyController/page1 means you want to hide action name from URL. Then go to app/config/routes.php and type the below code. Rou...

User of Recursive in cakephp

It is used where ample data is fetched from the query and there are numerous levels of associations between your models. we use Recursive like this way. $this->Region->find('all', array('recursive' => 0)); These are levels of ...

Use of $this->set() in Cakephp

Hello Readers , In cakephp development framework we will use $this->set() several times . The set() method is basically use to create a variable in our view file i.e. ctp file . If suppose we have an array $userprofile and we want to ...

CakePHP Folder Structure

After downlaoding and extracting CakePHP folder, one should see the following files and folders: app cake vendors plugins .htaccess index.php README Three main folders in which one will usually work: 1.The app folder is one...

CakePHP request Cycle

When a user requests a page or a resource then the CAKEPHP request cycle starts. It can be explained with the below diagram: Let's now discuss the request cycle diagram with steps: 1.The request is redirected to webroot/index.php ba...

Pagination in Cakephp

In CakePHP pagination is provided by a Component defined in the controller for making paginated queries much easier. PaginatorHelper View is used for generating pagination links & buttons in a simpler way. Setting up the Query: Le...

How to change default cakephp paginator sorting label?

The default code of cakephp paginator sorting label. <?php echo $this->Paginator->sort('first_name'); ?> We can change it as follows: echo $this->Paginator->sort('first_name', 'First Name'); Explanation: Here we c...

Cakephp Callback functions

Hello Reader, We have three cakephp callback function which generally used into the cakephp projects. 1> beforeFilter(): beforeFilter() is the cakephp callback function which can be used in AppController or in Controller and this functio...

Recursive In CakePHP

Hello Readers By default cakephp will get the data of the Model that you are querying for and the data of the Models that are linked to the main Model. So, by using recursive in cakephp you will get the data of the single association as wel...

$this->request and $this->data in cakephp

Hello Readers, Generally, we use the $this->request and $this->data in cakephp to get and post the data in application as well as in API's. So, below we describe in brief about the request. $this->request: Above, request is the de...

Using CakePHP FormHelper with Bootstrap Forms

Hello Readers , If you are using Cakephp and not use Cakephp FormHelper then its a bad technique of coding . To use Cakephp FormHelper first of all declare FormHelper in controller . So we have the piece of Html code below which we need to...

How to echo out current URL in Cake's view?

Hello Readers , If you want to echo out the current URL in cakephp then follow the below codes. Current URL: http://example.com/controller/action/?query=12 We can do it this way like. <?php echo $this->request->here; ?> ...

CakePHP: Call to a member function setFlash() on a non-object

Hello Readers, We have a session helper in cakephp which is known as setFlash() basically use for showing messages after login successfully , user registration etc. First of all we have to assign the session helper in Controller. Code us...

Send an Email using email component in cakephp

Hello reader if you want to send email using the email component in cakephp you need to run the email component of cakephp ex You should place email send routine in your AppController: function _sendMail($to,$subject,$template) { $th...

eliminate php5 Strict standards errors

Hello readers! If you have recently upgraded you PHP from PHP 5.3 to PHP 5.4 . Then it might be possible that your script is displaying a lot of error messages. If you want to hide these error you just need to change in your cakephp setup Th...

How to make custom error pages in CakePHP 2.0

Hello reader! If you want to set a custom error webpage for your whole cakePHP project you can set this page at /views/layouts/default.ctp as layout for these error pages like 404/ page not found To customize it and set your own message, o...

How to use Bootstrap pagination with CakePHP pagination helper

Hello, if you are using pagination with cakephp framework and want to change the view of pagination just like twitter bootsrap then you can do this by doing follow changes in you view and css. We can do it by writing some custom classes in view ...

Enabling SSL in CakePhp

Hello All, In this blog we will discuss about how to enable ssl https in your cakephp application on the server. You can enable SSL on live server by following these steps:- 1.In your core.php add/change the BASE_URL defination to https:...

Find where field is not null in cakephp

Hello Readers! if you have a database table "users" which has a field "email". And you are looking for a query that fetch out every email field only which are not null in cakephp Here is the following code below you can use, and its working ...

Cake was unable to write to File cache in cakePhp

Hello All, In this blog we will discuss about the File cache write problem in CakePhp application. Everytime when you install new version of the cakePhp or port your code on to the server you come across this error depicting that the cake i...

CakePHP website mobile version

Hello All, In this blog we will discuss about how to make your website working with proper layout in the mobile devices. For this we can use CakePHP's RequestHandler's isMobile function to check if a mobile device is accessing the site. ...

How to use the HABTM Relationship in cakephp?

HABTM association is used when you have two models that need to be joined up, repeatedly, many times in many different ways. So below is the following steps to follow to use the above relationship. First we create the database and its tables ...

Find method with JOIN in CakePHP

Hello, if you are working on cakephp and you need the joins with find method here is an example. Here $my_joins is and array having multiple join cases in other different arrays inside it. $my_joins=array( 'joins' =&g...

How to Add a prefix to every URL in CakePHP?

Hello Reader! If you looking to fix a default language prefix for your all url in cakePhp then you can follow the steps which is the easiest and clean way :- Open file routes.php from the location Config/routes.php There in first line wri...

How to Install DebugKit on CakePHP

Hello Nerds! If you are going to develop a new project in cakephp then you might need Debugkit for that, and its really a lifesaving tool for rapid developments. You can install DebugKit using doing the following steps as:- Step 1:- You ne...

How Cake PHP redirect with parameters in url

Hello readers, If you are using cakephp and want to redirect user to any other page/controller with some passing values in url, Well cakephp provides you its own syntax written in php, check bellow example: $this->redirect( arra...

CakePHP check if user is logged in inside a view

Hello Readers, if you are looking for a condition to check whether a user is logged-In or not from view, you can use the following code:- if ($this->Session->read('Auth.User')){ // you can put your condition here } In ca...
Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: