Caketwit - Twitter Like Service using CakePHP
-
Upload
missional-digerati -
Category
Documents
-
view
1.608 -
download
0
description
Transcript of Caketwit - Twitter Like Service using CakePHP
CakeTwitJohnathan Pulos @ Missional Digerati
Image by Blog.SpoonGraphics.co.uk
About MeBackground
PHP - 9 Yrs.
Ruby - 4 Yrs.
iOS - 2 Yrs.
Twitter: @jpulosGithub: codemisEmail: [email protected]
Missional Digerati
Community of thinkers, designers and developers committed to leveraging technology to advance the pace of reaching every person on earth with the good news
of Jesus Christ.
Twitter: @M_Digerati Github: MissionalDigerati
Website: MissionalDigerati.org
Basic Ingredients
Model View Controller
Model - classes that handle business logic of data.
Controller - traffic cop between models and view.
View - renders a presentation of modeled data.
http://goo.gl/yRDaa
Convention Over Configuration
http://goo.gl/N2Nh0
DB TABLES
ex. cars, user_scores
plural + underscored
MODELS
ex. Car, UserScore
singular + CamelCased
CONTROLLERS
ex. CarsController, UserScoresController
plural + CamelCased + ending in “Controller”
VIEWS
ex. add, view_user
action name + underscored
Create Read Update DeleteImage by IconEden.com
<?phpApp::uses('AppController', 'Controller');
class TweetsController extends AppController {
public function index() { /** * Show All Tweets */ }
public function view($id = null) { /** * Show an Existing Tweet */ }
public function add() { /** * Add a New Tweet */ }
public function edit($id = null) { /** * Edit an Existing Tweet */ }
public function delete($id = null) { /** * Delete an Existing Tweet */ }}
CakeTwit
XPMac OSX LionMAMP 2.1.1 (mamp.info)
PHP 5.4.4Apache 2.2.22MySQL 5.5.25
Sequel Pro (sequelpro.com)Textmate (macromates.com)Terminal
Windows XPWAMP 2.2E (wampserver.com)
PHP 5.4.3Apache 2.2.2MySQL 5.5.24
PHPMyAdmin 3.5.1Sublime Text (sublimetext.com)Command Line
Development Environments
Image by Blog.SpoonGraphics.co.uk & Icons by PinkMoustache.net
CakeTwitOff Screen Preparation
http://goo.gl/lKoOtXP
http://goo.gl/om8K6
Get CakePHP 2.3 Beta - https://github.com/cakephp/cakephp/tags
Create a Virtual Host
Enable Mod Rewrite
Create a Database
Add PHP to System Path
Image by Blog.SpoonGraphics.co.uk & Icons by PinkMoustache.net
Go Green!Image by DryIcons.com
NOTICENotice (1024): Please change the value of 'Security.salt' in
app/Config/core.php to a salt value specific to your application [CORE/Cake/Utility/Debugger.php, line 835]
CakeTwitGo Green!
Image by Blog.SpoonGraphics.co.uk
<?php/** * File: app/Config/core.php * Line: 187 *//** * A random string used in security hashing methods. */ Configure::write('Security.salt', 'DYhG93b0qyJfIxfs2guVoUubWwvniR2G0FgaC9mi');
Change to Random Alphanumeric String
NOTICENotice (1024): Please change the value of 'Security.cipherSeed' in
app/Config/core.php to a numeric (digits only) seed value specific to your application [CORE/Cake/Utility/Debugger.php, line 839]
CakeTwitGo Green!
Image by Blog.SpoonGraphics.co.uk
<?php/** * File: app/Config/core.php * Line: 192 *//** * A random numeric string (digits only) used to encrypt/decrypt strings. */ Configure::write('Security.cipherSeed', '76859309657453542496749683645');
Change to Random Numeric String (Digits Only)
NOTICE
Your database configuration file is NOT present.
CakeTwitGo Green!
Image by Blog.SpoonGraphics.co.uk & Icons by PinkMoustache.net
app/Config/database.php.default app/Config/database.php
NOTICE
Your database configuration file is NOT present.
CakeTwitGo Green!
Image by Blog.SpoonGraphics.co.uk
<?php/** * File: app/Config/database.php */class DATABASE_CONFIG {
public $default = array( 'datasource' => 'Database/Mysql', 'persistent' => false, 'host' => 'localhost', 'login' => 'user', 'password' => 'password', 'database' => 'database_name', 'prefix' => '', //'encoding' => 'utf8', );}
Set Your MySql Settings
Call Me Betty CrockerImage by DryIcons.com
CakeTwitNaming Convention for Tweets
Image by Blog.SpoonGraphics.co.uk & Icons by PinkMoustache.net
DB TABLE
tweets
MODEL
Tweet
CONTROLLER
TweetController
CakeTwitTweets Database Table
Image by Blog.SpoonGraphics.co.uk
Import SQL into Database - http://goo.gl/4MHJj
CREATE TABLE `tweets` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`post` varchar(255) DEFAULT NULL,
`author` varchar(255) DEFAULT NULL,
`created` datetime DEFAULT NULL,
`modified` datetime DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
INSERT INTO `tweets` (`id`, `post`, `author`, `created`, `modified`)
VALUES
(1,'I LUV CakeTwit!!!','A Random Poet','2012-12-24 08:00:00','2012-12-24 08:00:00'),
(2,'Give me another piece of Cake, Twit that is!','Poetic Justice','2012-12-23 08:00:00','2012-12-23 08:00:00');
CakeTwit
XP
Bake the Tweet’s Model
Image by Blog.SpoonGraphics.co.uk & Icons by PinkMoustache.net
In Terminal`cd` into the working directory
Select “M” for modelFollow the interactive console
For displayField select postAdd a validation to post as “notempty”
on Command Line`cd` into the working directory
Select “M” for modelFollow the interactive console
For displayField select postAdd a validation to post as “notempty”
> app/Console/cake bake > app\Console\cake bake
CakeTwit
XP
Bake the Tweet’s Controller
Image by Blog.SpoonGraphics.co.uk & Icons by PinkMoustache.net
In Terminal`cd` into the working directory
Follow the interactive consoleBuild the controller interactively
No dynamic scaffolding
Use basic class methods
on Command Line`cd` into the working directory
Follow the interactive consoleBuild the controller interactively
No dynamic scaffolding
Use basic class methods
> app/Console/cake bake Controller > app\Console\cake bake Controller
CakeTwit
XP
Bake the Tweet’s Views
Image by Blog.SpoonGraphics.co.uk & Icons by PinkMoustache.net
In Terminal`cd` into the working directory
Follow the interactive console
on Command Line`cd` into the working directory
Follow the interactive console
> app/Console/cake bake View > app\Console\cake bake View
The Real Van GoghImage by DryIcons.com
Visit your local website, and see your master piece!
Other Benefits
http://goo.gl/dXzjq
Model DataSource Data
DataSourcesThe link between models and the source of data that models represent.
MySql Sqlite Postgres Sqlserver
Icons by PinkMoustache.net & DefaultIcon.com
http://goo.gl/17M6G + http://goo.gl/44OhY
BehaviorsReusable logic for the models. A mixin with callbacks.
Access Control List
Containable
Translate
Tree
Icons by PinkMoustache.net
Models Behavior
http://goo.gl/Mp2NO + http://goo.gl/i53PM
ComponentsReusable logic for controllers.
SecuritySessionsAccess Control ListsEmails
CookiesAuthenticationRequest HandlingPagination
Icons by PinkMoustache.net
Controllers Components
http://goo.gl/8Gl8c + http://goo.gl/F2Ju5
HelpersPresentational logic shared among views, elements, and layouts.CacheFormHTMLJavascript (JS)
Pagination (Paginator)
RSSSession
TextTime
Icons by PinkMoustache.net
Views
Helpers
Elements
Layouts