CakePHP Basics Tutorial – Part 1

Overview

In this tutorial I’ll show you in about 30 minutes how to do a basic setup of CakePHP and read some data from the database without writing any SQL!  This will be an i-don’t-know-how-many-parts tutorial, but I’ll try to add every week a few until the basics are covered!

In this tutorial I’ll be covering

  1. Explain CakePHP
  2. Explain MVC in a nutshell
  3. Download and setup CakePHP
  4. Create a database table
  5. Create a Model, View and Controller
  6. Query the database without writing any SQL
  7. Visualize the returned data in a view

Let me know if you enjoyed it!

At this moment I have 4 parts written out, but if you want me to talk about something I didn’t cover in the tutorials, just ask it via the comments! I hope you’ll enjoy it, because coding is awesome, right!?

The tutorial

Share this post

52 Responses

  1. That’s great, Thanks for this tutorial. Can you help me my friend?
    I can’t config mod_rewrite. I’m really happy for this help.
    & I hope you will reply for my question.
    Thank you!

  2. I’m kinda new to programing with mamp and php, where exactly is your tutorial directory, currently i’m a only getting the “it Works!” page from local host and none of the cake php. And when I do put the cakephp Folder into the WebServer/Documents/ only the directory shows, not the cake php website.

    Do you know what i am doing wrong?

  3. Hey hie Frederik
    i want to know how to apply own external stylesheet in cakePHP
    I have already emailed you this question there i have written in brief.
    And your tutorial is much useful to me and all beginners over there 🙂

  4. hey frederic! pls be kind enuf to help me with this, i have no clue where i am stuck

    m using ubuntu

    i have my app, lib, plugins, vrndors foolder in var/www/cakephp

    i had altered my routed file to change the landing page of localhost/cakephp. so now instead of executing pages controller..it says Missing Controller : cakephp controller not found,

    on localhost/cakephp/users.php and
    localhost/cakephp/users/index.php
    its giving 404 NOt found.
    this happened immediately after deleting .htaccess files and uncommenting Configure::write(‘App.baseUrl’, env(‘SCRIPT_NAME’)); in core.php

  5. I could install cakephp and get to my new home page alright by following the tutorial. However, /cake_php/users results in a 404 by the web server.

    Here is some info about my installation. Im on a bitnami lamp stack. my cakephp_basics app is installed at /opt/lampstack-5.4.15-0/apache2/htdocs/cakephp_basics

    Any help would he great. Let me know you need more info from me.

    And great tutorial by the way. Saved a tonne of time for me.

  6. Thanks for this! It really helped me wrap my head around the way the model, controller, and view interact, and did a simpler and more succinct job of explaining some of the behind-the-scenes things CakePHP is doing. I’m looking forward to watching the rest!

  7. plz provide some other tutorials as soon as possible as you have provide the first one which is more attractive and easy to learn the basic of cakephp….thanks alot

  8. Hello,

    Your tutorials are great. I have small doubt in phpstorm. when writing code in phpstorm, the codes did not autocompelete instantaly in .ctp file. But it works well in .php file. Why do not working in .ctp file?. Please help me.

    Thanks in advance

    1. Hi, thanks! Really happy my tutorials are helping you out 🙂
      You can add autocomplete in CTP files by assign them to the PHP file types via File -> Settings -> File Types.

  9. Hi! Thanks for the great tutorials!

    Heb ze allemaal doorlopen en ben nu bezig met een eigen databank en wou ook alle stappen terug doorlopen maar dan met mijn gegevens.

    Ik zit vast als ik ze allemaal wil weergeven op mijn pagina. Ik krijg deze error:
    Error: Call to a member function find() on a non-object

    Deze files heb ik:

    ————————-
    LoginController.php
    class LoginController extends AppController{
    public function index(){
    $users = $this->User->find(‘all’);
    pr($users);
    }

    index.ctp
    Login

    Login.php
    class User extends AppModel {
    }

    ———————–

    $users = $this->User->find(‘all’);
    die “User” vanwaar haal je die?

    1. Ik heb het opgelost door de UsersController te gebruiken.
      Alleen snap ik nog altijd niet goed vanwaar die “User” komt?

  10. The best php tutorial still i have seen…and i am sure that i won’t get better than this…thanx a lot…:)

  11. I searched for hours for a simple tutorial on how to get started with cakephp and this went so far ahead of expectations. Amazing tutorial

  12. Thanks for doing this, Frederik! I was struggling to really understand the concepts of MVC and CakePHP at the same time for a few weeks (on and off trying to prototype my own projects) and finally found this. Very clear and helpful! Thank you!

  13. Great tutorial!
    I have learned the powerful basics shown in this video and help me to solve a problem ofrom one of our website customer that need to migrate his webpage.
    Thank you and keep going!,,

  14. I am trying to learn CakePHP. Your fisrt video is amazing and very helpful. I will continue with the others.

    Keep going

    Apythanos from Hellas

  15. Very clear and nicely explained!
    You made it plain and simple!

    Hoping to see more for cakephp and more.

    Thanks very much!

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Posts