Membuat Project Baru Menggunakan Fitur ‘Bake’ di CakePHP


Ini postingan kedua tentang CakePhp, untuk tutorial dasarnya bisa dilihat di https://toreizen.wordpress.com/2011/03/10/tutorial-dasar-cakephp/. Untuk membuat projek baru dengan menggunakan feature ‘bake’ dengan menggunakan console/command line. Didalam command line akan menggunakan kata kunci cake bake. Disini kita akan membuat project baru dengan nama ‘newcake’ dengan password dikosongkan dan dengan nama database ‘dbcakephp’. Langkah-langkahnya seperti dibawah ini :

1. Pastikan path php telah dimasukkan kedalam environment variable. Jika belum ada, dengan cara berikut :

a. Buka Environment Variable.

b. Didalam System Variables, carilah variable Path.

c. Edit variable Path dan isikan php path kedalamnya.

Setting php path di Environment Variable

2. Menambahkan path cakephp console (cake.bat) kedalam Environment Variable. Caranya seperti diatas, dan value yang akan kita isi yaitu …\xampp\htdocs\cakephp\cake\console.

CakePHP Console

3. Buka command prompt.
4. Arahkan kedalam tempat menaruh folder project, misalnya C:\xampp2\htdocs.

Microsoft Windows [Version 6.1.7600]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.
C:\xampp2\htdocs>cake bake
Welcome to CakePHP v1.3.7 Console
---------------------------------------------------------------
App : htdocs
Path: C:\xampp2\htdocs
---------------------------------------------------------------
What is the full path for this app including the app directory name?
Example:C:\xampp2\htdocs\myapp
[C:\xampp2\htdocs\myapp] > C:\xampp2\htdocs\newcake
Bake Project
Skel Directory: C:\xampp2\htdocs\cakephp\cake\console\templates\skel
Will be copied to: C:\xampp2\htdocs\newcake
---------------------------------------------------------------
Look okay? (y/n/q)
[y] >
Do you want verbose output? (y/n)
[n] >
---------------------------------------------------------------
Created: newcake in C:\xampp2\htdocs\newcake
---------------------------------------------------------------
Creating file C:\xampp2\htdocs\newcake\views\pages\home.ctp
Wrote `C:\xampp2\htdocs\newcake\views\pages\home.ctp`
Welcome page created
Random hash key created for 'Security.salt'
Random seed created for 'Security.cipherSeed'
CAKE_CORE_INCLUDE_PATH set to C:\xampp2\htdocs\cakephp in webroot/index.php
CAKE_CORE_INCLUDE_PATH set to C:\xampp2\htdocs\cakephp in webroot/test.php
Remember to check these value after moving to production server
Your database configuration was not found. Take a moment to create one.
---------------------------------------------------------------
Database Configuration:
---------------------------------------------------------------
Name:
[default] >
Driver: (db2/firebird/mssql/mysql/mysqli/odbc/oracle/postgres/sqlite/sybase)
[mysql] >
Persistent Connection? (y/n)
[n] >
Database Host:
[localhost] >
Port?
[n] >
User:
[root] >
Password:
>
The password you supplied was empty. Use an empty password? (y/n)
[n] > y
Database Name:
[cake] > dbcakephp
Table Prefix?
[n] >
Table encoding?
[n] >
---------------------------------------------------------------
The following database configuration will be created:
---------------------------------------------------------------
Name:         default
Driver:       mysql
Persistent:   false
Host:         localhost
User:         root
Pass:
Database:     dbcakephp
---------------------------------------------------------------
Look okay? (y/n)
[y] > y
Do you wish to add another database configuration?
[n] >
Creating file C:\xampp2\htdocs\newcake\config\database.php
Wrote `C:\xampp2\htdocs\newcake\config\database.php`
C:\xampp2\htdocs>
5. Karena project dibuat pada direktori htdocs yg merupakan document root web server apache, maka web bisa langsung diakses dari browser. Pastikan apache server telah berjalan, gunakan XAMPP Control Panel. Kemudian akses http://localhost/newcake

NewCake has been made

5 thoughts on “Membuat Project Baru Menggunakan Fitur ‘Bake’ di CakePHP

  1. Pingback: Naming Convension CakePHP « Cingkarabala

  2. No.1 -> Kita menyetting php path, step by stepnya bisa dilihat diatas. Jika belum ada, tentu saja kita isikan dan kalau sudah ada tidak usah kita hapus. (*perhatikan yang di-highlight)
    No.2 -> Kita menyetting path cakephp console, step by stepnya dah jelas diatas. (*perhatikan yang di-highlight)
    Kalau step 1 dan 2, sudah berhasil disetting baru bisa lanjut membuat CRUD menggunakan perintah CAKE BAKE.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s