CakePHP Setting up your system to Bake
Tuesday, February 1st, 2011http://i.justrealized.com/2009/02/16/how-to-run-xampps-php-cli-and-cakephp-console/
start baking:
C:\xampp\htdocs\project\app>”../cake/console/cake” bake
http://i.justrealized.com/2009/02/16/how-to-run-xampps-php-cli-and-cakephp-console/
start baking:
C:\xampp\htdocs\project\app>”../cake/console/cake” bake
download the current release:
cakephp.org
unzip, copy/rename folder as desired
check apache file permissions
app/tmp – 0777
app/config
core.php – change Security.salt to new value
database.php.default – remove .default, and configure values according to your database
done
URL will trigger controller
example:
http://appname.com/data_users
in app/controllers:
data_users_controller.php
in there:
class DataUsersController extends Controller {
}
this should be the same as the table it will reference:
data_users
in app/models:
data_user.php
class data_user extends AppModel {
}
in app/views/data_users:
function.ctp
First of all, in the controller, add it to the $helpers array:
var $helpers = array(‘Html’, ‘Form’, ‘Time’);
Then in the corresponding view, call it like this:
<p>Date Published: <?=$time->nice($post[‘Post’][‘date’]);?></p>
which effectively (in this case from the database in this example) turns this: 2010-01-02 21:54:00
into this: Sat, Jan 2nd 2010, 21:54
—- note: —-
without the Time helper we could of course do this specific thing with the plain ‘ol PHP date function this way:
<?=date(‘M jS Y, g:i a’,strtotime($post[‘Post’][‘date’]));?>
—-
$post[‘Post’][‘date’] is the value of the object Time will beautify, in this case
sent by the following function in the controller:
function view($id = null) {
if (!$id) {
$this->Session->setFlash(__(‘Invalid Post.’, true));
$this->redirect(array(‘action’=>’index’));
}
$this->set(‘post’, $this->Post->read(null, $id));
}
need to see inside that specified array?
to be remembered:
app/views/posts/view.ctp
<? debug($post); ?>
which will also display records from associated models!
http://i.justrealized.com/2009/02/16/how-to-run-xampps-php-cli-and-cakephp-console/
start baking:
C:\xampp\htdocs\project\app>”../cake/console/cake” bake