open source guy
open source guy

Reputation: 2787

How php execute in file with extension .ctp in cakephp?

I am new to cakephp. I am wondering how php code execute file with extension .ctp . How php executed in .ctp file extension in cakephp? How can execute php code in file with extension .css with cakephp technique ?

Upvotes: 3

Views: 1462

Answers (3)

Jon
Jon

Reputation: 437336

The code inside views is executed because Cake uses include to process it. You can do the same yourself:

include('any_file_you_want.with_any_extension');

As long as there is a PHP start tag and the syntax is OK, any code inside that file will be executed.

Upvotes: 2

Hardik Sondagar
Hardik Sondagar

Reputation: 4495

CakePHP is PHP Framework on MVC Structure . MVC Stand for Model View Controller.

Model : where your database tables define and all the processing and validations like if you have table named "USER" then to access that table you will create UserModel.php inside Model directory.

Controller : For every Model one Controller is define for our business logic.here our Controller name will be UsersController.php

View :: View file have extension .ctp. It define how data will be shown on Client's browser.

Flow Of CakePHP : Client Request will be go to first UsersController.php. Controller will fetch Data from UserModel.php. After processing retrieved data Controller pass this data to View. View(.ctp) file contains HTML,CSS and Client Side Scripting data and that will goes back to Client Machine where it'll be display.

Upvotes: 0

Php Geek
Php Geek

Reputation: 1107

Look cakephp follows a MVC architecture.

Hence the files structures are divided into 3 main modules:-

1.Model:- This the file in which you write your validations.
2.COntroller:- This the file where you write your programs logic.
3.View:- This is the file where you write your output/design in the form of HTML and also write Java script.

Now coming back to your question. The .ctp files are nothing but the View part of the cakephp. They are initiated/ called by the controllers. The controllers act as a heart of ur php.They are the one's to call your .ctp file and execute the file and also css files are called and handled by them only.

Go through the documentation throughly...

I understand documentation may be bit confusing, read it 4-5 times u wil get to knw every thing abt cake...

Upvotes: 1

Related Questions