UPDATE: CakePHP Applikation Builder Online
Download CakePHP (1,1 MB) (aktuellere CakePHP Version)
Download XAMPP lite (20 MB) (aktuellere XAMPP Version hier)
CakePHP Installation und Einführung für Windows XP
Im Rahmen des Barcamp Stuttgart 2008.
XAMPP lite nach C:\xampplite\
entpacken. XAMPP lite läuft Stand-alone!
Cake nach C:\xampplite\htdocs\cakecore\
entpacken.
In C:\xampplite\apache\conf\httpd.conf
DocumentRoot "/xampplite/htdocs/cakecore/app/webroot"
setzen und
LoadModule rewrite_module modules/mod_rewrite.so
einkommentieren.
C:\xampplite\xampp-control.exe
starten.
Im Browser http://localhost/
, http://localhost/controller/action
aufrufen. Cake läuft :)
In C:\xampplite\htdocs\cakecore\cake\console\cake.bat
"C:\xampplite\php\php.exe -q "C:\xampplite\htdocs\cakecore\cake\console\cake.php %*
setzen statt php -p %...
Start > Ausführen...
starten und cmd
und bestätigen.
Foldenden Zeilen eintippen:
cd C:\xampplite\htdocs\cakecore\cake\console\
cake
Folgende Ausgabe kommt:
C:\xampplite\htdocs\cakecore\cake\console>cake
Welcome to CakePHP v1.2.0.7296 RC2 Console
---------------------------------------------------------------
Current Paths:
-app: app
-working: C:/xampplite/htdocs/cakecore/app
-root: C:/xampplite/htdocs/cakecore
-core: C:\xampplite\htdocs\cakecore\
Changing Paths:
your working path should be the same as your application path
to change your path use the '-app' param.
Example: -app relative/path/to/myapp or -app /absolute/path/to/myapp
Available Shells:
C:/xampplite/htdocs/cakecore\app\vendors\shells\:
- none
vendors\shells\:
- none
cake\console\libs\:
acl
api
bake
console
i18n
schema
testsuite
To run a command, type 'cake shell_name [args]'
To get help on a specific command, type 'cake shell_name help'
Jetzt cake bake
eintippen.
Folgende Ausgabe kommt:
C:\xampplite\htdocs\cakecore\cake\console>cake
Welcome to CakePHP v1.2.0.7296 RC2 Console
---------------------------------------------------------------
Current Paths:
-app: app
-working: C:/xampplite/htdocs/cakecore/app
-root: C:/xampplite/htdocs/cakecore
-core: C:\xampplite\htdocs\cakecore\
Changing Paths:
your working path should be the same as your application path
to change your path use the '-app' param.
Example: -app relative/path/to/myapp or -app /absolute/path/to/myapp
Available Shells:
C:/xampplite/htdocs/cakecore\app\vendors\shells\:
- none
vendors\shells\:
- none
cake\console\libs\:
acl
api
bake
console
i18n
schema
testsuite
To run a command, type 'cake shell_name [args]'
To get help on a specific command, type 'cake shell_name help'
Dann folgende Antworten auf den Dialog geben: (mysql, n, n, localhost, n, root, '', y, cake, n, n, ... y, n)
Name:
[default] >
Driver: (db2/firebird/mssql/mysql/mysqli/odbc/oracle/postgres/sqlite/sybase)
[mysql] > 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] >
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: cake
---------------------------------------------------------------
Look okay? (y/n)
[y] >
Do you wish to add another database configuration?
[n] > n
Creating file C:/xampplite/htdocs/cakecore/app\config\database.php
Wrote C:/xampplite/htdocs/cakecore/app\config\database.php
Im Browser sollte http://localhost/
folgende Meldung auftauchen: Cake is NOT able to connect to the database.
Zu http://localhost/phpmyadmin/
wechseln und bei Neue Datenbank anlegen
eine Datenbank mit dem Namen cake
anlegen mit Klick auf Anlegen
.
Dann folgendes SQL im Reiter SQL
ausführen:
CREATE TABLE `companies` (
`id` int(11) NOT NULL auto_increment,
`title` varchar(255) NOT NULL default '',
`city` varchar(255) NOT NULL default '',
`zip` int(11) default NULL,
`adress` mediumtext NOT NULL,
`modified` datetime default NULL,
`created` datetime default NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ;
CREATE TABLE `people` (
`id` int(11) NOT NULL auto_increment,
`salutation` enum('Herr','Frau') NOT NULL default 'Herr',
`name` varchar(255) default NULL,
`email` varchar(255) default NULL,
`telephone` varchar(255) default NULL,
`company_id` int(11) default NULL,
`modified` datetime default NULL,
`created` datetime default NULL,
PRIMARY KEY (`id`),
KEY `companies_id` (`company_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=4 ;
Wieder zurück auf http://localhost/
sollten alle vier Konfigurationsausgaben grün sein.
Wieder in der Comandozeile cake bake
, dann m
für Model.
Es sollten die zwei Tabellen die wir angelegt haben mit Namen erscheinen. Wir wählen 2
für Person
.
Wir legen folgendes Model an: validation criteria n
, model associations y
, Person belongsTo Company y
, additional model associations n
, Look okay? y
und unit test n
.
Jetzt legen wir einen Controller an:
cake bake Controller
Es sollten die zwei Tabellen die wir angelegt haben mit Namen erscheinen. Wir wählen wieder 2
für Person
.
Folgende Einstellungen: scaffolding y
, Look okay? y
und unit test n
.
Im Browser http://localhost/people/
aufrufen und testen. Personen anlegen, ansehen, editieren und sortieren mit Klick auf Table Header.
Jetzt ein Model und einen Controller für Company
bzw. Companies
anlegen, einzigster Unterschied nicht hasOne
sondern hasMany
mit y
beantworten.
Problemlösungen:
Bei Apache Problemen C:\xampplite\apache\logs\error.log
ansehen sowie C:\xampplite\xampp-portcheck.exe
. Oder C:\xampplite\apache_start.bat
testen.
Updated 12. Mai 2009
Mehr zu mir: Simon Brüchner