Monday 8 September 2014

Why Developers Prefer Cakephp Framework For Large Scale Website Development?

Nowadays, CakePHP is a commonly-used PHP framework that helps developers to build dynamic websites and web applications at ease. Originated since 2005, Cakephp is an open source, MVC structured platform that offers a well managed code behind interface to quick start your project.

Some Facts
  • Around 43% of Cakephp websites are built in business category globally. (Source: BuiltWith)
  • In 2013, Cakephp is 5th most promising frameworks among all other PHP platforms. (Source: SitePoint)
  • Easily available large communities of skilled Cakephp developers make complex website development smooth.
While Cakephp is a robust and reliable website development framework, there are some more excellent advantages for developers:

Zero Configurations

Cakephp framework operates with ZERO configurations, so it helps developer to pay full attention on logical part rather than dealing with configuration issues. Also Cakephp developers don’t have to manage extra configurations excluding database connections, as it consists of auto removed features.

Regular Updation

CakePHP is certainly everyone’s ideal choice in all PHP frameworks because it consistently remains to be upgraded and is often utilized by expert PHP programmers in world-wide. Cakephp offers customized solutions to make programmers app meet with their client’s requirements.

Language Support

It is hard for developers to work with same language all times. This is the reason why language support is a key feature of Cakephp framework, as it supports numerous languages that helps programmer to work comfortably. It removes the warrior work with only one language at all.

Code Re-usability

Cakephp facilitate developers with code re-usability feature that saves their lots of time in writing similar codes over and over again. Also it helps developer to finish their work in short time-frame. Hence programmers can also expand the usability of their applications using plug-ins.

Thursday 7 August 2014

How To Integrate Wordpress Blog With Cakephp Application?


 Cakephp Wordpress Integration

Integration of blog with Cakephp application is not new for a PHP developer, but if we talk about cross platform integration, it takes time to understand functionality and compatibility of both frameworks. The same problem occurred with me last month, when client required integrating a Wodpress CMS with Cakephp Application.

I have researched a lot and find a good tutorial Integrating Wordpress with Your Website in Wordpress support section. Here is the process I followed:
  • First install WordPress and copy & paste wordpress folder into app/webroot of CakePHP.
  • Access .htaccess file from CakePHP root directory and place these lines, given below:
          RewriteEngine on
          RedirectMatch temp ^/blog/wp-admin$ http://www.example.com/blog/
          RewriteRule ^blog$ blog/ [L]
          RewriteRule ^blog/wp-admin$ blog/wp-admin/ [L]
          RewriteRule ^$ app/webroot/ [L]
          RewriteRule (.*) app/webroot/$1 [L]

This results URL like this: “http://www.example.com/blog/“, but if you want URL like this: “http://www.example.com/blog”, there should be little change in this process:
  • First install WordPress and copy & paste this folder same folder where your ‘app’ folder remained.
  • Here find CakePHP - .htaccess file to run wordpress from webroot/blog directory (Original Source: Githhub.com):
           <IfModule mod_rewrite.c>
            RewriteEngine on

            RewriteCond %{REQUEST_URI} !^/blog.*
            RewriteCond %{REQUEST_URI} !-f
            RewriteRule ^$ app/webroot/ [L]

            RewriteCond %{REQUEST_URI} !^/blog.*
            RewriteCond %{REQUEST_URI} !-d
            RewriteRule (.*) app/webroot/$1 [L]
           </IfModule>

If you have some more methods to share, please comment below.

Tuesday 29 April 2014

News: Cakephp 1.3.18 and 2.4.8 released on April 29, 2014





Cakephp core team has announced the availability of Cakephp 1.3.18 and 2.4.8 on April 29, 2014. Cakephp Developers, who are struggling with security issues, now recommended to use SecurityComponent.


Lists of expected changes in 1.3.18 are given below:
  • Model conditions containing : or ? are now handled correctly. This fixes issues around using casting in conditions
  • SecurityComponent form tampering hashes now include the URL path as a hash input.

Lists of expected changes in 2.4.8 are given below:
  • SQLServer now properly appends the schema name when describing tables.
  • Hash::extract() can now match boolean attributes.
  • fclose() errors when using shells should no longer happen.
  • CakeResponse::file() now throws an exception when paths contain '..'.
  • ShellDispatcher now casts argv to an array. This fixes issues when cake console was invoked from a non-cli SAPI.
  • TextHelper::autoLink() now correctly links urls with subdomains containing '\_'.
  • SecurityComponent form tampering hashes now include the URL including the query string as a hash input.

Friday 11 April 2014

Infographic: Comparison Between Cakephp And CodeIgniter!

PHP Frameworks (Cakephp and CodeIgniter) provide a firm structure for code. It also saves us from rewriting the same code and creating the functionalities all over again.

While CodeIgniter would be well-suited for smaller applications, CakePHP is an advanced framework-distributed under MIT license. Each framework has its own pros and cons, but it really depends on your project's complexity and provision to choose the suitable one.

So here is an Infographic that provides a brief comparison between Cakephp and CodeIgniter frameworks with their respective pros and cons:


Wednesday 12 March 2014

Why Cakephp Framework is Best Choice for Website Development?

Cakephp is an open source programming language that helps to develop efficient and potential websites and its applications. Now-a-days, it is the first choice for most developers and programmers to develop a website fast. Now question arises, if there are so many other PHP frameworks available for web development, why several developers and programmers still trust on Cakephp? So, here are the features that make Cakephp highly noticeable from other frameworks:

Open Source

Open source in terms of computing is stands for: 


Similarly, Cakephp is an open source website development platform that ensures users for free availability and modification of code. Many cakephp developers use it to develop customized CMS and websites. One main advantage is most of the big Cakephp Communities like Github offers updates, codes and plug-ins for free use.

Model-View-Controller (MVC) Architecture


Cakephp is based on the Model-View-Controller pattern that isolates the business layer from the presentation layer.  Therefore, model is responsible for database connectivity and saving data to the database. The view processes data in supported format and layout. The controller handles the user request. 

Code Reusability

As we discussed previously Cakephp is an open source framework, hence several communities provides freely available codes which is reusable and can be modified. Thus, it makes CakePHP website development faster as CakePHP developers can use already existed code. It also increases efforts and potential of developers regarding optimized logic and structure in developing the web applications for a website.

CRUD

Image Courtesy: programming-free.com

CRUD stands for Create, Read, Update and Delete. CakePHP provides CRUD concept based on Active Record design pattern. The Active Record design is an approach to access data from database. It’s built-in to wrap the database table and row in a php class itself. So, CRUD is an easy act for cakephp programmers to create, modify and delete entities from the system.

Easy to configure and Built-in Libraries

The best part of Cakephp framework is easy configuration and installation. You just install it from Cakephp.org and use it with some initial modifications like database connectivity and change in security files. It saves developers time configuring the CakePHP as it can automatically detect most features and settings. It has many in-built validation rules or libraries that can be easily used for particular uses.

Monday 3 March 2014

News: Cakephp 2.4.6 released on March 02, 2014


Cakephp core team has released the new Cakephp version 2.4.6 on March 02, 2014. People, who are struggling with previous Cakephp version’s issues, now can download this bug-fix Cakephp 2.4.6 release from Githhub.com/cakephp .

Some of the changes are given below:
  • Extract task handles quotes inside validation messages correctly.
  • Model::field() now works with fields translated with TranslateBehavior.
  • Core tests are no longer part of PEAR packages. This solves issues when the pear package is used as a composer dependency, and an incorrect classmap was generated.
  • FormHelper::checkbox() can now generate checkboxes for empty values.
  • Postgres can now convert boolean fields to integer when using SchemaShell.
  • Changes to how ID's are generated for radio inputs were reverted. These changes caused issues in some applications.
  • API documentation has been improved.
  • Reverse routing for prefixed actions was improved.
  • Temporary associations setup with TranslateBehavior::bindTranslation() are now correctly unbound & restored.
  • Clearing data with MemcacheEngine will now work with greater than 100 slabs.
  • Validation::decimal() now works with localized floats.
  • Invalid data in datetime pickers is now correctly handled.
  • FormHelper::postLink() and FormHelper::postButton() now handle N dimensional data.

Monday 24 February 2014

3 Shopping Cart Plug-ins For Cakephp Website Development

Shopping Cart Plugins

You can find several shopping cart plug-ins online, but here are three popular ones, everybody should know:

1. Cakephp Shopping Cart

A simple PHP Shopping Cart built with CakePHP PHP framework.

  • CakePHP 2.4 rapid development php framework
  • CakePHP DebugKit
  • Bootstrap 3 front-end framework with Mobile Friendly Responsive design
  • jQuery, jQuery UI JavaScript Library,
  • Authorize.net Payment Gateway for Credit Card Payment
  • PayPal Express Checkout
  • Google Checkout
  • AJAX functions for search autocomplete, shopping cart updates
  • Product Brands
  • Product Categories
  • Product Tags
  • Product Options

Note: Its status is still showing “INCOMPLETE” Tag.

To download its ZIP, please Read here: https://github.com/andraskende/cakephp-shopping-cart

2. Cakecart - Shoppingcart Plug-in

CakeCart is a shopping cart built on-top of the CakePHP framework. Currently it is in the pre-alpha stage.
Its purpose will be to allow anybody familiar with the CakePHP framework to customize and easily launch an e-commerce website. Currently has authorize.net support and later scheduled to add in Paypal and Google checkout support.

For Installation, Read here: https://github.com/samanz/cakecart

3. Kaching - Shoppingcart Plug-in

Kaching is tailored for developers that want full control on building their online store. Kaching provides the store administration and lots of features (see project page). You build the store's look and feel interacting with our controllers. Kaching is also distributed under the MIT License.

For Installation, Read here: https://github.com/mfriesen/kaching-php

Wednesday 29 January 2014

4 Steps To Make Registration Form In Cakephp



Before starting to learn about how to make registration form in Cakephp, I want to make it clear that you should read abo MVC model in Cakephp.

Step 1 - Create Table and fields

In first step we create table in database then create fields that are generally included in registration forms (like username, password, email id etc.)

Database query to create table: Create table ‘tablename’
Database query to create field:
CREATE TABLE tablename (
ID INT NOT NULL AUTO_INCREMENT,
PRIMARY KEY(ID),
username VARCHAR (50) NOT Null,
password VARCHAR (50) NOT Null,
email VARCHAR (100) NOT Null,
firstname VARCHAR (25),
lastname VARCHAR (25),
)";
 

Note: - You can write any suitable name in place of “tablename”.

Step 2 - Create Model

Model is the part that takes care of the database logic. Create model with “tablename.php” in app/models as we defined name of table is “tablename” in first step. To make action on “tablename” we have to declare name (like name) because it uses in controller to save data. Code looks like: $this->name->save(data).

Code to create model: 
<?php
class tablename extends AppModel
{
var $name=' name ';
}
?>


Step 3 - Create View

View is the part that presents data received from model. Create view ‘register.ctp’ in app/view/tablename. We are creating form here in HTML although you can use helpers provided by cakephp to create form too.

Code to create view:
<html>
<form action="../tablename/register" method="post">
<p>Register your account.</p>
<label>Username:</label><input name="username" size="40" />
<label>Password:</label><input type="password" name="password" size="40"/>
<label>Email Id:</label><input name="email" size="40" maxlength="100" />
<label>First Name:</label><input name=" firstname " size="25" />
<label>Last Name:</label><input name=" lastname " size="25" />
<input type="submit" value="register" />
</form>
</html>


Note: Always remember the input name should be same as column name of our table.

Step 4 - Create Controller

Controller is a part that responds to user with combined action of model and view part. Create ‘tablename_controller.php‘ in app/controllers.

Code to create controller:
<?php
Class tablename_Controller extends AppController
{
function register(){
if (!empty($this->params['form']))
{
if($this->name->save($this->params['form']))
{
$this->flash('Registration Successful','/tablename/register’);
}
else
{
$this->flash('Not succeeded','/tablename/register');
}
}
}
}
?>


How above codes work?

First user open registration form here, "tablename/register/" in his browser. User fills the registration form details and click on register button. In controller it will check for the register function as we mentioned the action of form as ‘../register’ .

Register function in controller will save the data of form by using given statement
$this->name->save($this->params['form'])

This statement create insert query in database, i.e.
Insert INTO
Tablename(username, password, email, firstname, lastname)
Values
(‘mike’,’mike123’,’mike@gmail.com’,’mike’,’hussy’)


After insert command, a message pop-ups on your window “Registration successful” and you are done!

Resource: W3schools.com

Monday 6 January 2014

3 Ways to load models in Cakephp framework


There are three ways in CakePHP to load models. In these three methods, two works outside of a Controller.

App::import() only finds and require()s the file and you'll need to instantiate the class to use it. You can tell import() the type of class, the name and file path details.

ClassRegistry::init() loads the file, adds the instance to the object map and returns the instance. This is the better way to load something because it sets up 'Cake' things as would happen if you loaded the class through normal means. You can also set an alias for the class name which I've found useful.

Controller::loadModel() uses ClassRegistry::init() as well as adds the Model as a property of the controller. It also allows $persistModel for model caching on future requests. This only works in a Controller and, if that's your situation, I'd use this method before the others.