CakePHP 3 Tutorial - part 2: Databases

Поділитися
Вставка
  • Опубліковано 8 лют 2025
  • ** UPDATED FOR CAKEPHP 4.0 **
    • CakePHP 4 Tutorial - #...
    SQL script for tables:
    CREATE TABLE users (
    id INT AUTO_INCREMENT PRIMARY KEY,
    email VARCHAR(255) NOT NULL,
    password VARCHAR(255) NOT NULL,
    created DATETIME,
    modified DATETIME
    );
    CREATE TABLE bookmarks (
    id INT AUTO_INCREMENT PRIMARY KEY,
    user_id INT NOT NULL,
    title VARCHAR(50),
    description TEXT,
    url TEXT,
    created DATETIME,
    modified DATETIME,
    FOREIGN KEY user_key (user_id) REFERENCES users(id)
    );
    CREATE TABLE tags (
    id INT AUTO_INCREMENT PRIMARY KEY,
    title VARCHAR(255),
    created DATETIME,
    modified DATETIME,
    UNIQUE KEY (title)
    );
    CREATE TABLE bookmarks_tags (
    bookmark_id INT NOT NULL,
    tag_id INT NOT NULL,
    PRIMARY KEY (bookmark_id, tag_id),
    FOREIGN KEY tag_key(tag_id) REFERENCES tags(id),
    FOREIGN KEY bookmark_key(bookmark_id) REFERENCES bookmarks(id)
    );
    ------------------------------------------------------------------
    Thanks so much for watching! Please comment, like or subscribe in order to support me. Also, please consider donating here:
    jbjcode.com/don...
    Donations are whats keeping me going, as the financial aid helps justify the amount of time spent + to buy new equipment for recording and editing.
    Thank you!
    /J.B.J.

КОМЕНТАРІ • 88

  • @heohni
    @heohni 9 років тому

    This is so great to get back to cake after a longer brake and just 2.x experience! Cake 3 is sooo new and different... I am looking forwward to learn how it works now!

  • @livininabubble
    @livininabubble 9 років тому

    Thanks a lot for this! As a (even php) noob I have some serious trouble understanding the written tutorials on the official site. Your explanations made everything much clearer for me! I think your pace is just right and especially the thrown in explanations about basic structures and naming conventions are really helpful!
    Keep them tutorials coming please! =)
    Just two things (for other serious noobs out there ;D) -->
    My editor can't do code completion with cake specific stuff and did not automatically add the "use Cake\Auth\DefaultPasswordHasher" on top of User.php. I did not notice the missing line first and had to add it manually. In the video the line just appears and is easy to miss ;).
    Also I'm on Windows with XAMPP and I had to cd myself directly into the htdocs\bookmarker\bin folder and then do all the cake baking from there, without writing the "bin/" every time.

    • @JBJProgramming
      @JBJProgramming  9 років тому

      +Eve K Thanks a lot for compliments, and glad it works for you! Also thanks for the extra explanations for other people that might struggle with similar issues!
      I will upload the next one soon, so keep an eye out on my channel! 1-2 days is the plan for the next upload, so stay tuned ;)
      Thanks for watching

  • @jackhales6179
    @jackhales6179 5 років тому

    "This is powerful stuff" - You're a good teacher, haha. Cracking up at your speech conventions though!

  • @sdasshuva
    @sdasshuva 9 років тому

    Your tutorials are awesome man. Please make some more of Cakephp. I watched both of them and will watch the future tuts. thanks.

    • @JBJProgramming
      @JBJProgramming  9 років тому

      +sdasshuva Thanks a lot! I am sorry for the lack of uploads, but i have the next one planned very soon! So within a few days it should be up, so keep an eye out for my channel.

  • @mikeramirez7922
    @mikeramirez7922 7 років тому

    Thank you! Your tutorial was extremely useful in getting started the right way.

  • @MrPrasadpyda
    @MrPrasadpyda 9 років тому +2

    Awesome tutorial !!.. I got ver trouble while installing & using cake php. After watching your videos i made it very simple. Thanks alot man. Looking for more videos. :) ThumsUP

    • @JBJProgramming
      @JBJProgramming  9 років тому +2

      +Prasad Pyda Glad it helped :) I too had trouble installing at first, also one of the reasons i made the video :)

  • @devin.n
    @devin.n 6 років тому

    thumbs up to every tut so far

  • @Yina1988
    @Yina1988 9 років тому

    Thanks a lot for the tutorials! Very helpful. :)

  • @heliotelisa
    @heliotelisa 9 років тому

    ajajaja like you said at the end, i started this tutorial about 6 times to finally understand how to do things right, a lot of erros in my way XD so i thank you for this good video ;D

  • @0870csm
    @0870csm 8 років тому

    Thank you very much for your tutorial. Have a good time :D !

  • @MicroUrb
    @MicroUrb 9 років тому +16

    JB, since this is an MVC framework you may want to edit this video and let students know that they have to add this code here: use Cake\Auth\DefaultPasswordHasher; else they are going to get an error.

    • @hjbc19
      @hjbc19 7 років тому

      Thanks!

  • @WillBarnett-c9m
    @WillBarnett-c9m 9 років тому

    Useful tutorial. Can you bake a database view or can it just bake direct tables?

    • @JBJProgramming
      @JBJProgramming  9 років тому

      +Will B You can bake entire databases, but that just means it will "bake" all tables in that specific database.

    • @WillBarnett-c9m
      @WillBarnett-c9m 9 років тому

      +J.B.J. Programming Thanks - but can you bake views or just tables?

  • @rubyhien1592
    @rubyhien1592 8 років тому

    thank you very much!! very nice!!

  • @oofy9103
    @oofy9103 6 років тому

    very helpful

  • @alevsk
    @alevsk 9 років тому

    nice videos man, I have been using the framework for several years (2.x) now :), Im looking to learn what is new in the 3.0 version. thanks.

    • @JBJProgramming
      @JBJProgramming  9 років тому +1

      +Lenin Alevski Thanks for the comment mate! Let me know if you have suggestions for improving the way i do the videos :) If there is something in particular you like or dislike, or something you would like done different.
      Thanks for watching! :) Next part will not be up before monday-tuesday next week due to holidays.

  • @naminhxoi8548
    @naminhxoi8548 7 років тому

    Thank you J.B.J!

  • @deepali129
    @deepali129 8 років тому

    Kindly share where is the routing for the /user or/bookmark is done when we do bin/cake bake all users or bin/cake bake all bookmarker

  • @meluxx
    @meluxx 9 років тому

    thanx alot dude, it was awesome . one question, when we bake how the page USERS created?

  • @InLightFilm
    @InLightFilm 8 років тому

    Thank you very much

  • @CamiloSanchez1979
    @CamiloSanchez1979 9 років тому +1

    Hey can you please make a video explaining the ORM to those of us that know cakephp 2? It's really difficult to know where things go now

  • @ranjanachauhan3838
    @ranjanachauhan3838 8 років тому

    hi i am new in cake php...... i installed it and set the database after that i am getting confuse .......dont know what to do ahead ......

  • @barnybumper
    @barnybumper 8 років тому

    the folders behviour, entity and table you talk about in 15:52 remain empty after filling the database. Did i miss something?

  • @andy1264able
    @andy1264able 7 років тому

    I am stuck in this error whenever I execute cake bake command.
    Exception: Cannot use 'Bake\Shell\CommonOptionsTrait' for command 'common_options_trait' it is not a subclass of Cake\Console\Shell.

  • @gon6556
    @gon6556 5 років тому

    I could connect to the database, but failed with bin/cake bake all users.
    error message is this.
    [PDOException] SQLSTATE[HY000] [2054]
    The server requested authentication method unknown to the client in /Applications/MAMP/htdocs/bookmarker/vendor/cakephp/cakephp/src/Database/Driver.php on line 92
    Do you know what is the reason why bake command is not working well?

  • @clarkrosario7898
    @clarkrosario7898 8 років тому

    HI tutorial looks good , but how can i go to the console to check if it has connected to the database, thank you.

  • @locnguyenphuoc5882
    @locnguyenphuoc5882 6 років тому

    I can't using this command. How can you enable ext-intl for mamp pro in macos. Can you help me? Thanks

  • @r.i.s.e.3908
    @r.i.s.e.3908 8 років тому +7

    you may want to tell people they need to add this line of code at the top: use Cake\Auth\DefaultPasswordHasher;

  • @feedbackers
    @feedbackers 9 років тому +3

    this tuto is amazing !! thank you so muuch
    however why the name of the application is /bookmarks, in which step we named it ?

    • @DjlilEmusic
      @DjlilEmusic 9 років тому

      in the first video he gives this project the name 'bookmarks'. I only figured out by watching this video that we're making a bookmarked site/app;p

  • @rohantapiyawala9096
    @rohantapiyawala9096 7 років тому

    Any support or suggestions for connecting to SQL SERVER database ?? work in an enterprise setup with already established database. Would be really helpful to get to use sqlserver for my project. Thanks

  • @mabrouknour1852
    @mabrouknour1852 8 років тому

    Thank you so much for this tutorial and your hole series but every time i try to add or delete something, an error shows up " Undefiened type """ " didn't know what that does mean !!!! and i haven't been able to figuret out :\

  • @ShashankNaithani
    @ShashankNaithani 9 років тому

    I M CONFUSED VERSION 3 DOES NOT HAVE THE APP FOLDER SO HOW SHOULD I LEARN AND WHAT TO DO I M USING WINDOWS AND HAVE INSTALL CAKE VIA COMPOSER I HAVE CREATED THE DATABASE BUT DON'T KNOW WHAT TO DO AHEAD. i m not getting page like u with the url localhost/8765..
    pls give some guidance

  • @gon6556
    @gon6556 5 років тому

    I did the exact same things as your codes, but I was not able to connect to SQL. Error message is this.
    CakePHP is NOT able to connect to the database.
    Connection to database could not be established: SQLSTATE[HY000] [2054] The server requested authentication method unknown to the client

    • @JBJProgramming
      @JBJProgramming  5 років тому

      Make sure you have the correct credentials for your local database (username and password) and that you have started a local testing environment (WAMP, MAMP, XAMP).

  • @vananananava9625
    @vananananava9625 2 роки тому

    Sir, can you create a small project using cakephp 4?

  • @nirobahmed3896
    @nirobahmed3896 8 років тому

    I've using wndows 8. i dont understand where run following this command,"bin\cake bake all users" Plz mention this.thanks.

    • @vafendaniel
      @vafendaniel 8 років тому

      in the terminal you have to join(?) to the project folder. your path should look like this: ?:\wamp\www\project\ and you can use bin\cake.

  • @burneggesmile
    @burneggesmile 9 років тому +1

    hi..somebody please tell me how to get the the data that appear on 10.20?after we edit the the coding to connect

  • @BitValentine
    @BitValentine 9 років тому +3

    What software are you using to develop and edit?

  • @moinuddinwaheed
    @moinuddinwaheed 9 років тому

    Please tell setting the environment variable for windows10 and then bake all users etc

  • @MurkVisionFilms
    @MurkVisionFilms 8 років тому

    Parse error: syntax error, unexpected => (T_DOUBLE_ARROW), expecting ';' in /Applications/MAMP/htdocs/cakewalk/bookmarker/src/Model/Entity/User.php on line

  • @hostvps8413
    @hostvps8413 9 років тому +2

    what you should do,is coding manually controllers,models,and views,and explain each part.

    • @shibnathroy106
      @shibnathroy106 9 років тому

      +Host Vps Completely agree !!! I want to implement cakephp on a custom design and using cake bake for that really confuses me

    • @hostvps8413
      @hostvps8413 8 років тому

      +shibnath roy you are using a custom design, so just cake bake controller and model, and adjust your custom design with cakephp view

  • @johnseaton7227
    @johnseaton7227 7 років тому

    I get Error: BookmarkerController could not be found. when I open the site instead of getting what you got (the ability to enter rows into the database)

    • @johnseaton7227
      @johnseaton7227 7 років тому

      Oops. My fault. I went to the page matching my database name. I should have gone to the page matching the table name.

  • @subornosamanta
    @subornosamanta 9 років тому

    How can I add csv/excel file to update my database?

  • @ayushiagrawal3190
    @ayushiagrawal3190 8 років тому

    controller missing exception comes when i run m my baked table in local host what to do

  • @LaProgramadora
    @LaProgramadora 8 років тому

    please, how to join many tables. (inner join in cake after baking)

    • @JBJProgramming
      @JBJProgramming  8 років тому

      Read up on cakephp associations. You can bake many-to-many associations but it is very important you have followed every convention, and even then it doesn't work very well. In my experience, the cake bake feature is only worth doing if you have a simple table you just want simple CRUD operations on it. If you go beyond that i find it best to implement from the ground-up

  • @SyamAraragi
    @SyamAraragi 5 років тому

    what's Earl?

  • @moinuddinwaheed
    @moinuddinwaheed 9 років тому

    How to use these commands in windows
    bin/cake bake all users
    bin/cake bake all bookmarks
    bin/cake bake all tags

    • @kevos5
      @kevos5 9 років тому +1

      +moinuddin waheed To get the commands to work in windows I had to modify the system environment variable path to exactly where the cake, cake.bat and cake.php files where located on my system. For example, my location was at "C:\xampp\htdocs\cakephp". Once this was set I was able to run "cake bake all users" etc WITHOUT the bin/. Hope this helps.

  • @thelastcodebender3661
    @thelastcodebender3661 9 років тому +1

    I get an error it says DefaultPasswordHasher is not found.

    • @tropyfastpinstripefurious1373
      @tropyfastpinstripefurious1373 9 років тому

      +Kim Carlo Cortez i have the same error, could you find the solution?

    • @tropyfastpinstripefurious1373
      @tropyfastpinstripefurious1373 9 років тому

      +Kim Carlo Cortez
      protected function _setPassword($password) {
      if (strlen($password) > 0) {
      return (new DefaultPasswordHasher)->hash($password);
      }
      }

    • @cormac71
      @cormac71 9 років тому +2

      +Kim Carlo Cortez try protected function _setPassword($value){
      return sha1($value);
      }
      or return md5($value) or other password encryption, the way shown in the video didnt work for me either :P

    • @hostvps8413
      @hostvps8413 9 років тому +2

      you didn't add this line:
      use Cake\Auth\DefaultPasswordHasher;

    • @brunotdantas
      @brunotdantas 8 років тому

      +cormac71 Thanks :) worked for me

  • @moinuddinwaheed
    @moinuddinwaheed 9 років тому

    Sir, where is the sql query

  • @vercevales
    @vercevales 9 років тому

    "Missing Controller"
    Any idea why I get this error? I cannot open localhost:8765/xyz

    • @JBJProgramming
      @JBJProgramming  9 років тому

      +Vercevales Which controller is missing?

    • @vercevales
      @vercevales 9 років тому

      I've managed to fix that. I created the database on my own and I must have done it with mistakes because when I created it changing slightly your SQL script everything worked fine :)

    • @clarkrosario7898
      @clarkrosario7898 8 років тому

      hi i have this "Error:
      The view for BookmarkController::index() was not found." how to I fix this?

  • @tropyfastpinstripefurious1373
    @tropyfastpinstripefurious1373 9 років тому

    which is the name of this text editor?

    • @JBJProgramming
      @JBJProgramming  9 років тому

      +Tropy Fast & Pinstripe Furious it is PHPStorm mate :)

  • @saddimohamed
    @saddimohamed 9 років тому +2

    top of the file/
    use Cake\Auth\DefaultPasswordHasher;
    function/
    protected function _setPassword($value){
    $hasher = new DefaultPasswordHasher();
    return $hasher->hash($value);
    }

  • @RichardFedorko
    @RichardFedorko 9 років тому

    More?

  • @hostvps8413
    @hostvps8413 9 років тому

    need more and more explanation,nothing new,all you do it's just reading what is in cakephp tutorial book,people needs basics and explanation to start with,and thanks for your efforts

    • @JBJProgramming
      @JBJProgramming  9 років тому +2

      +Host Vps Yes it is, that is what the tutorial is all about and i mention that in the first video - i make this series for people that doesn't like to read the material and would rather watch a video explaining it. The tutorial is also called "Bookmarker" which is the same name as the cake tutorial, so if you expected it to be anything other than that you haven't been paying attention mate :)

    • @hostvps8413
      @hostvps8413 9 років тому

      i thought it will be sth different than that, but thanks for your effort, great job :)

  • @pathethiam6149
    @pathethiam6149 8 років тому

    c'est intéressent mais les vidéos ne sont pas très claire

  • @ericoppong9295
    @ericoppong9295 7 років тому

    Bro i think using a windows laptop for your tutorials will be the right thing cuz many dont use Mac os #myopinion

  • @thrash_jesus
    @thrash_jesus 8 років тому +1

    Your intro is super cringe but the video is ok

    • @JBJProgramming
      @JBJProgramming  5 років тому

      i know, i have no idea what i was thinking lol xD thought about editing it out but now i just leave it there for giggles