Beruflich Dokumente
Kultur Dokumente
• English
STEP 1
AllowOverwrite is Set to All
We need to make sure that the web root directory, or the directory in which we plan to
keep CakePHP has AllowOverwrite set to all. We can do this by checking Apache’s main
configuration file http.conf. This file should be located in the directory called conf, where
we have installed Apache. In this file, there should be option for the web root directory.
As the following configuration shows, the web root (which is L:/wamp/www for this
particular installation) has a Directory entry in which the AllowOverwrite option is set to
all. If the directory under web root, in which we plan to keep Cake, has a directory entry,
we need to check that one too.
<Directory “L:/wamp/www”>
Options Indexes FollowSymLinks
AllowOverride all
Order Deny,Allow
Deny from all
Allow from 127.0.0.1
</Directory>
STEP 2
Mod_rewrite Module is Loaded
We also need to make sure that the Apache is loading the mod_rewrite module. To do
this, we again have to check the http.conf file. There should be a section in the http.conf
file named Dynamic Shared Object (DSO) Support, where all the different modules that
are loaded by Apache are listed. The modules that are not being loaded are commented
out with # in the beginning of the line. So, we need to make sure that the mod_rewrite
module line is not commented out. If it is, we just need to remove the # from the
beginning of the line:
Make sure to restart Apache once you have made the above changes.
As long as the above configurations are set accordingly, Apache should be running
CakePHP applications without any issues at all.
STEP 3
Copy CakePHP to www
STEP 4
So the directory structure will be somewhat like this
C:\wamp\www\CakePHP
To test your installation go to your web browser and enter similar to this URL
http://localhost/CakePHP
Why CAKEPHP?
1. Almost every experienced developer hates writing same code again and again
because it’s really is nothing but wastage of time. For eg:- Creating same boring
add/edit/delete functions for entities and all. Other problem faced by most of the
developers is the organization of code. Most of them may not understand how actually to
keep their code organized or if they really need it at starting phases. But when we reach at
later stages, our code becomes messy and messier. CakePHP solves this problem by its
MVC structure and its attractive features.
5. I prefer this because of the total control is in my hand. If I want then I can use the
predefined coding structure or I can wrote it by myself using standard.
6. Component: Components are packages or group of logic that are shared and used
between several controllers. If I want to copy and paste specific code between controllers
then I might consider wrapping some functionality in a component and include this into
the controller which is needed. I can use component in different reasons. Such as:
• Security
• Sessions
• Access control lists
• Emails
• Cookies
• Authentication
• Request handling
• Image resize
• Paypal payment getway.
7. Behavior: Model behaviors are a way to organize some of the functionality defined
in CakePHP models. They allow us to separate logic that may not be directly related to a
model, but needs to be there. By providing a simple and powerful way to extend models,
behaviors allow us to attach functionality to models by defining a simple class variable.
That’s how behaviors allow models to get rid of all the extra weight that might not be
part of the business contract they are modeling or that is also needed in different models
and can then be extrapolated.
8. Helpers: Helpers are the component-like classes for the views in the application. It
contains presentational logic that is shared between many views, elements, or layouts. Let
any 3rd party editor such as fck editor, I can easily add this with any views.
9. PHP compatibilities: Compatible with PHP4 and PHP5. So I don’t think about the
hosting.
10. CRUD: Integrated CRUD for database interaction so that we can easily control data
transaction.
12. Code generation: I can bake the cake and generate the code automatically. Though I
hate it. I always want to know everything and write the whole code by my hand.
13. Route: there is a file named route.php. By this, I can easily control the URL and the
access of the project.
14. Validation: I can use the built in validation in model as well as controller. I prefer
the validation in controller.
17. The framework also provides a basic organizational structure, from filenames to
database table names, keeping your entire application consistent and logical. This concept
is simple but powerful. Follow the conventions and you’ll always know exactly where
things are and how they’re organized.
18. Execution time: CakePHP is much slower then coldignetor. Average execution time
for cakephp is 0.31sec where coldignetor get only 0.19sec. Though the execution time
can be reduced for cakephp but it will not be less then coldignetro.
19. Timely Delivery and Deployment: There’s no doubt that CakePHP will accelerate
the development process. Finishing it before deadline means more debugging period.
21. Fully Functional Code: The way applications are developed using Cake offers us to
perform various tests. Best of all, it allows us unit testing to the simplest entities and their
functions. For eg: If I have built a online exam system with it, I know ‘exam’ is entity of
my application and the functions like exam, resultCalculation, result, examSet etc. are
more easily tested.
22. Visual Tweaks after development/deployment: Since, Cake has MVC structure, all
views inside Cake are always in a separate files (*.ctp) which are free of any complex
PHP code. This not only makes the Visual stuff easier to implement but makes it easier to
modify too.
23. Easy understandable Code: All our entities (Models), functions to these entities
(Controllers), User Interface (View) are in separate files, so I will not start studying a
controller if I am looking to change the Caption of some input field or any other random
task.
24. SEO: In terms of SEO, I have complete freedom of my html through the layouts and
views, and the routing system allows any self URLs I want, so no restrictions there and
easy to SEO
Controllers contains all of the logic of your application. Each controller can offer
different functionality depends on the business logic; controllers retrieve and modify data
by accessing database tables through models; and they register variables and objects,
which can be used in views.
Models are active representations of database tables: they can connect to your database,
query it (if instructed to do so by a controller) and save data to the database by creating
the object of the represented table. It is important to note that in order to correctly apply
the MVC architecture, there must be no interaction between models and views: all the
logic is handled by controllers. That means a model create a abstract object and maintain
the connection with DB. Serve the purpose according to controller to retrieve, save,
update and delete data.
Views can be described as template files or output that present their content to the user:
variables, arrays and objects that are used in views are registered through a controller.
Views should not contain complex business logic; only the elementary control structures
necessary to perform particular operations, such as the iteration of collected data through
a foreach construct, should be contained within a view. Throw a view, a user can give
input and get output from the application. Its just used for this.
This architecture can greatly improve the maintainability and the organization of your
site’s code:
Controllers, models and views are stored in pre-defined directories within CakePHP’s
directory structure. Here’s the directory structure that’s used:
• app/
o config/
o controllers/
o models/
o plugins/
o tmp/
o vendors/
o views/
o webroot/
• cake/
o config/
o docs/
o libs/
• vendors/
Although this may seem worrisome for some developers, it’s a good compromise that can
really accelerate the development process.
CakePHP features Controller, Model, and View classes, but it also features some
additional classes and objects that make development in MVC a little quicker and more
enjoyable and improve efficiency. Components, Behaviors, and Helpers are classes that
provide extensibility and reusability to quickly add functionality to the base MVC classes
in your applications.
Always a developer have to know one thing. Developer create a CONTROLLER for
a specific business logic, create models for each DB TABLE and create views for
each function if the view is necessary. For view, developer have to create a folder
under app/view/ folder.
A Component is a class that aids in controller logic. If you have some logic you want to
share between controllers (or applications), a component is usually a good fit. As an
example, the core EmailComponent class makes creating and sending emails a snap.
Rather than writing a controller method in a single controller that performs this logic, you
can package the logic so it can be shared.
Controllers are also fitted with callbacks. These callbacks are available for your use, just
in case you need to insert some logic between CakePHP’s core operations. Callbacks
available include:
A Helper is a class that aids in view logic. Much like a component used among
controllers, helpers allow presentational logic to be accessed and shared between views.
One of the core helpers, AjaxHelper, makes Ajax requests within views much easier.
Most applications have pieces of view code that are used repeatedly. CakePHP facilitates
view code reuse with layouts and elements. By default, every view rendered by a
controller is placed inside a layout. Elements are used when small snippets of content
need to be reused in multiple views.
Similarly, Behaviors work as ways to add common functionality between models. For
example, if you store user data in a tree structure, you can specify your User model as
behaving like a tree, and gain free functionality for removing, adding, and shifting nodes
in your underlying tree structure.
Models also are supported by another class called a DataSource. DataSources are an
abstraction that enable models to manipulate different types of data consistently. While
the main source of data in a CakePHP application is often a database, you might write
additional DataSources that allow your models to represent RSS feeds, CSV files, LDAP
entries, or iCal events. DataSources allow you to associate records from different sources:
rather than being limited to SQL joins, DataSources allow you to tell your LDAP model
that it is associated to many iCal events.
• beforeFind()
• afterFind()
• beforeValidate()
• beforeSave()
• afterSave()
• beforeDelete()
• afterDelete()
The names of these methods should be descriptive enough to let you know what they do.
Application Extensions:
Controllers, helpers and models each have a parent class you can use to define
application-wide changes. AppController (located at /app/app_controller.php),
AppHelper (located at /app/app_helper.php) and AppModel (located at
/app/app_model.php) are great places to put methods you want to share between all
controllers, helpers or models.
Although they aren’t classes or files, routes play a role in requests made to CakePHP.
Route definitions tell CakePHP how to map URLs to controller actions. The default
behavior assumes that the URL “/controller/action/var1/var2” maps to
Controller::action($var1, $var2), but you can use routes to customize URLs and how they
are interpreted by your application.
6. If you change the maximum execution time as 3600 seconds and maximum
memory for 128MB from php.ini, then you don’t have to think about anything else.
Why Cakephp???
Cakephp is a popular, free and rapidly developed framwork of php. I love cakephp. When
I started my career, I didn’t know even HTML. So php or Cakephp or any other
framework are the same hard to me. But luckily I started with Cakephp and found that it
is lot easier and huge supporting framework. It followed MVC architecture pattern and
the ORM. And now I just write the prosidure sequently from the beginning to the end.
The given informaton is based on cakehph manual form http://cakephp.org . First we
have to know why we use cakephp.
The CakePHP framework provides a robust base for your application. It can handle every
aspect, from the user’s initial request all the way to the final rendering of a web page.
And since the framework follows the principles of MVC, it allows you to easily
customize and extend most aspects of your application.
The framework also provides a basic organizational structure, from filenames to database
table names, keeping your entire application consistent and logical. This concept is
simple but powerful. Follow the conventions and you’ll always know exactly where
things are and how they’re organized.
1. Easy to learn.
3. Flexible licensing.
6. Integrated CRUD (Create, Read, Update & Delete) for database interaction.
7. Application scaffolding.
8. Code generation.
13. View Helpers for AJAX, JavaScript, HTML Forms and more.
18. Localization.
19. Works from any web site directory, with little to no Apache configuration involved.