I am new to cakephp.I installed CakePHP.I wnat a simple program so as to know how to use cakephp.I tried everysite but couldnot understand how the MVC works while writing a program.I also want to know how database is created in CAKEPHP>

Hi Dear ,

please follow this link " You Got the meaning of MVC http://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93controller

if you talk about cake php the follow the link http://book.cakephp.org/1.3/view/876/The-Manual

you you need for sample code

follow these steps,

under app folder ---

**apps/model--
**

**create    note.php**

<?php
class Note extends AppModel
{
  var $name = 'Note';
}
?>




**apps/controller**


**create    notes_controller.php**


<?php
class NotesController extends AppController
{
var $name = 'Notes';
var $scaffold;
}
?>

Here is the quickest, and yet nothing is pretty dirty.. just to get your fingers wet on blank page, and to taste the model->controller->view concepts.

Step One: The MODEL Copy codes below and save it app/Model/Test.php

<?php
##  save this in app/Model/Test.php
  class Test extends AppModel {

  }

Step Two: The CONTROLLER Copy codes below and save it app/controller/TestsController.php Please take note on the plural Tests...

 <?php
  ## save this file app/controller/TestsController.php
  ## notice the naming convention above?? Tests is plural
   class TestsController extends AppController {
        ## you define helpers here or
        ## write functions 
    public function index() {



   }

   }

Step Three: The VIEW ** open app/View/ directory, and within this directory create a new directory called ** Tests . Once again, I urge you to take a look at the Tests directory name, it is plural again.

Copy codes below and save it as app/View/Tests/index.ctp

<!-- File: /app/View/Tests/index.ctp -->

<h1>Test Page</h1>
<p>Hello! This is my first page created in CakePHP</p>

Step Four: Direct your browser to localhost/cakeDirectory/Tests/ . You should be reading the **" Hello! This is my first page created in CakePHP"
**

Summary:

Create Model file, create controller file, create directory for your scripts, create the view page inside the script directory.

Now, experiment with many libraries and functions cakePhp has to offer...

Say, you want to create another page "about Us"; all you need to do is follow the same process, except the controller part. On the TestsController.php, you just add,

  public function about() {
  }

and then your page in the view/Testsm will be about.ctp, and the model will be about.php

When i run index.ctp i got the following errorrs:I do exactly as mentioned above

Sweet, "Cake 1.3.0" got Baked by CakePHP!

Your tmp directory is writable.
URL rewriting is not properly configured on your server.

Help me configure it
I don't / can't use URL rewriting

The FileEngine is being used for caching. To change the config edit APP/config/core.php

Your database configuration file is present.

Fatal Error (256): ConnectionManager::getDataSource - Non-existent data source default [APP\cake\libs\model\connection_manager.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.