on Basics Tutorials

CakePHP from Scratch: Installing and the basics

8 comments
logo
Tweet about this on TwitterShare on FacebookShare on Google+Share on LinkedInShare on RedditShare on StumbleUpon

This series is dedicated to show how easy it is to work and develop great application in CakePHP. This series assumes that you have a general understanding of PHP and a basic understanding of object-oriented programming (OOP), but the beginners will be able to follow it.

CakePHP is a rapid development framework for PHP that provides an extensible architecture for developing, maintaining, and deploying applications.

Using commonly known design patterns like MVC (Model-View-Controller) and ORM (Object Relationship Mapping) within the convention over configuration paradigm, CakePHP reduces development costs and helps developers write less code.

It is helping developers to reduce the amount of time writing repeatable code so they can concentrate on the pure awesomeness of the application they are developing.

What does Convention over configuration means? It is a software design paradigm which seeks to decrease the number of decisions that developers need to make, gaining simplicity, but not necessarily losing flexibility.

The phrase essentially means a developer only needs to specify unconventional aspects of the application. For example, if there’s a class Sale in the model, the corresponding table in the database is called sales by default. It is only if one deviates from this convention, such as calling the table “products_sold”, that one needs to write code regarding these names.

All of this will be much clearer when we start using the framework and building our application.

So, let us go to CakePHP.org and download the latest release (there is a big Download button on the front page). After you downloaded it, extract the content to your local development environment or upload it to the server. Please, rename the folder to cake for easing the access to it.

CakePHP folder structure

Picture show the folder structure that the framework uses. You’ll notice three main folders:

Basically, the installation for development is finished. Point your browser to the folder you extracted CakePHP to and you should see that it is working, but has some Warnings written on the screen. Let us correct the things Cake is warning us about.

Open /app/config/core.php and find this lines:

/**
 * A random string used in security hashing methods.
 */
	Configure::write('Security.salt', 'DYhG93b0qyJfIxfs2guVoUubWwvniR2G0FgaC9mi');

/**
 * A random numeric string (digits only) used to encrypt/decrypt strings.
 */
	Configure::write('Security.cipherSeed', '76859309657453542496749683645');

Basically, you just need to change the Security.salt and Security.cipherSeed values to increase the security of your application. So just ad a number or two wherever you want, or change the whole thing. Save the file and refresh the page. First couple of warnings are gone now. If you have warning that tmp directory is not writable, change permissions on /app/tmp folder to 0755 or higher.

Last warning is telling us to rename /app/config/database.php.default to /app/config/database.php, so let us do that. After refreshing, CakePHP says that it is not able to connect to the database. Go ahead and create a database that you will use for this tutorials.

Now open /app/config/database.php and edit the database credentials (under ‘default’ array) to match your settings, save the file and refresh the page.

Congratulations, you successfully installed CakePHP framework.

Stay tuned, our second tutorial will tell you more about CakePHP basic principles and conventions and will introduce the most powerful feature – The bakery.

Tweet about this on TwitterShare on FacebookShare on Google+Share on LinkedInShare on RedditShare on StumbleUpon