CakePHP PHP App

CakePHP

by Cakedc

Development PHP Framework
Helps with: PHP
Similar to: Cloudways PHP SDK App Laravel App Drupal App Symfony App More...
Source Type: Open
License Types:
MIT
Supported OS:
Languages: C CPP

What is it all about?

CakePHP is a fast PHP framework for developers which commonly uses for design patterns like Associative Data Mapping, Front Controller and MVC.

CakePHP is designed to make common web-development tasks simple, and easy. By providing an all-in-one toolbox to get you started the various parts of CakePHP work well together or separately.

Key Features

* Build Quickly: Use code generation and scaffolding features to rapidly build prototypes. * No Configuration: No complicated XML or YAML files. Just setup your database and you're ready to bake. * Friendly License: CakePHP is licensed under the MIT license which makes it perfect for use in commercial applications. * Batteries Included: The things you need are built-in. Translations, database access, caching, validation, authentication, and much more are all built into one of the original PHP MVC frameworks. * Clean MVC Conventions: Instead of having to plan where things go, CakePHP comes with a set of conventions to guide you in developing your application. * Secure: CakePHP comes with built-in tools for input validation, CSRF protection, Form tampering protection, SQL injection prevention, and XSS prevention, helping you keep your application safe & secure.


Resources

Resource Type

Link

Wikipedia https://en.wikipedia.org/wiki/CakePHP
CakePHP 3.4 Red Velvet Cookbook https://book.cakephp.org/3.0/en/index.html

Pricing

Yearly
Monthly
Lifetime
Free
Freemium
Trial With Card
Trial No Card
By Quote

Description

Free - See site

Product Analysis

PHP

PHP frameworks and libraries

Cake PHP review

Cake PHP review

By Victor Carlo Jacaban III | 5/31/2016 | Product Analysis |Beginners

Cake PHP is an open source PHP framework that offers MVC (Model->View->Controller) architecture. It offers an understandable set of conventions that helps make processes easier and faster. It also reduces web application development cost & time considerably. Support wise, Cake PHP has a huge community for when you're in times of need. We can always seek help when we are stuck.

In terms of setting it up, you will not need to spend time searching the internet for how to do so because CakePHP's documentation itself covers the full scope of the framework and even provides sample app (blog application) as a guideline for beginners on how to start building their own application.

Below are some reasons why I love Cake PHP, based on my own personal experience.

 

MVC – as I said above, it follows an MVC pattern separating its logic from the view side. If you are used to a procedural way of coding PHP, MVC is not that easy to understand. One of the problems most commonly encountered by web developers upon first trying to use an MVC pattern is how to render or display data from the model and what the role of the controller should be; in other words, how to connect each of the three components. Cake PHP leaves you no choice but to follow an MVC patter and will really help you get used to coding in this manner. If you are able to run the sample blog they've provided in their documentation, you will understand how the Model, View and Controller are communicating.

 

Example:

Model

 

class User extends AppModel {

}

 

Cake PHP follows naming conventions. The proper way of naming classes in the Model is in the singular form. We will save the file under app/Model and name it User.php, in that way Cake PHP automatically detects that we will use users table in our database and will be used by UsersController.

 

Controller

 

class UsersController extends AppController {

public $helpers = array('Form');
 
public function index() {

$this->set('users', $this->User->find('all'));

}

}

 

As you can see, Cake PHP's controller naming convention is plural. Automatically this controller is already connected to the model we've created above. By default, index() is called when this controller does not  receive any instructions or directions as to which function to use. The declared helper above index() is an attribute where we can store CakePHP helper libraries like CacheHelper, FormHelper, JsHelper,Session Helper and etc. The index() will return all the users inside the users table. $this->User->find('all') is equevalent to "Select * from users" of Sql statement.

 

View

 

<h2>List of Users</h2>

<?php foreach ($users as $user): ?>

<p><?php echo $user['User']['firstname']; ?>  <?php echo $user['User']['lastname']; ?>

 

<?php endforeach; ?>

<?php unset($user); ?>

 

We can now loop through the users that were being set in our controller and display all the data inside the users table. From the code above, we'll assume that we have firstname and lastname columns in our users table and that that is the information we want our view to render. unset() will simply make it explicit that the variable's role has been completed and can never be assigned or an indication that its role is done.

 

Understandable Data Validation - Cake PHP offers simple and understandable Data Validation which is necessary to meet business rules of the application.

 

Example

class User extends AppModel {

public $validate = array(

'username' => 'alphaNumeric',

'password' => array(

'rule' => array('minLength', '6'),

'message' => 'Minimum of 6 characters long'

),

);

}

 

Assuming we have username and password on our users table, you can see what rules are applied on the sample fields.

 

Templating System – Cake PHP also provides a flexible templating system. You can build your own custom design the way you want it.

 

Test Cases – Cake PHP has built in testing support enabling you to make tests on your features easily for better development. Its main purpose of course is to check critical points in your application. It also improves performance and give us confidence that our application is good since it's been tested.

 

Example

 

Fixtures - defines the schema on how the table was created and how the table is to be populated. This will represent the records that we will use on our test case. 

 

class UsersFixture extends TestFixture
{
public $import = ['table' => 'users']; 

public $fields = [
'id' => ['type' => 'integer'],

'firstname' => ['type' => 'string', 'length' => 255, 'null' => false],

'lastname' => ['type' => 'string', 'length' => 255, 'null' => false],

'created' => 'datetime',

'modified' => 'datetime',

'_constraints' => [

'primary' => ['type' => 'primary', 'columns' => ['id']]
]
];

public $records = [
[
'firstname' => 'John',

'lastname' => 'Doe',

'created' => '2016-01-01 01:20:20',

'modified' => '2016-01-01 10:20:20'
],
];
}

 

You can see the schema of our users table and the sample record that was populated in it. We now have sample data that can be used in our test case.

 

Sample Test Case for Model

App::uses('User', 'Model');

class UserTest extends CakeTestCase {

public $fixtures = array('app.user');

public function setUp() {

parent::setUp();

$this->User = ClassRegistry::init('User');

}

public function testDisplay() {

$result = $this->User->display(array('id', 'firstname'));

$expected = array(

array('User' => array('id' => 1, 'firstname' => 'John')),

);

$this->assertEquals($expected, $result);

}

}

 

We called the fixture we created above through public $fixtures = array('app.user') so that we can use its record for our test. Assuming we have a display() on our user model, we can now check if it will display data and check if the results from our function with the data from our fixture is the same with the custom expected result. Basically it is testing if the specific function from the User model is doing what it's supposed to do.

setUp() initializes the objects that will be used on tests.

 

PHP Version Support - Cake PHP fully supports the latest version of the PHP Programming language. This enables developers to create web applications based on what their clients want and use new built in function in PHP.

 

Conclusion

 

I'm not saying that CakePHP is the best framework of all frameworks and that it doesn't have any downside but as what I have experienced coming from a functional way of PHP coding, I think it's very easy to understand especially when your are new to web development. As I stated before, this is based on my experiences using Cake PHP. I know there are more features that cake PHP offers and I'm confident I'll be able to learn them along the way.

By Victor Carlo Jacaban III | 5/31/2016 | Product Analysis

{{CommentsModel.TotalCount}} Comments

Your Comment

{{CommentsModel.Message}}

Top DiscoverSDK Experts

User photo
3355
Ashton Torrence
Web and Windows developer
GUI | Web and 11 more
View Profile
User photo
1490
Ronan McCarthy
Cross-Platform & Web developer.
Web | Mobile and 6 more
View Profile
User photo
1230
Gary Green
Expert programmer, Ask what you want
Web | JavaScript and 3 more
View Profile
User photo
1130
Harry Gold
Experienced Web developer.
Web | JavaScript and 3 more
View Profile
Show All

Interested in becoming a DiscoverSDK Expert? Learn more

X

Compare Products

Select up to three two products to compare by clicking on the compare icon () of each product.

{{compareToolModel.Error}}

Now comparing:

{{product.ProductName | createSubstring:25}} X
Compare Now