cmf: a pain in the f @ phpday 05-14-2011
DESCRIPTION
TRANSCRIPT
Long story short, a true tale about an hopeless DevTeam
CMF: a pain in the F
David Funaro & Alessandro NadalinMay, 14 2011
domenica 15 maggio 2011
let us introduce
The Problem™
domenica 15 maggio 2011
There comes the boss< there's a new project
domenica 15 maggio 2011
There comes the boss
< seems easy, let's use Joomla!
domenica 15 maggio 2011
Don't open that door!
domenica 15 maggio 2011
The 80/20 dilemma
CMS
domenica 15 maggio 2011
80% is cool at all
domenica 15 maggio 2011
but as
the requirements grows
domenica 15 maggio 2011
(you always knew that)
domenica 15 maggio 2011
the project becomes a mess
domenica 15 maggio 2011
There comes the boss< can I haz fotonic menthal scanner in the website
domenica 15 maggio 2011
There comes the boss
< can't do boss Joomla! is not meant...
domenica 15 maggio 2011
There comes the boss< STFU NOOB DO THAT OR BLA BLA BLA
domenica 15 maggio 2011
what if
domenica 15 maggio 2011
There comes the boss
< seems complex,no Joomla this time,
let's use a framework!
domenica 15 maggio 2011
There comes the boss< STFU NOOB WE SHOULD GO LIVE NEXT WEEK BLA BLA
domenica 15 maggio 2011
The 20/80 dilemma
Framework
domenica 15 maggio 2011
20% is cool at all
domenica 15 maggio 2011
the 80%is reallyfunny
domenica 15 maggio 2011
but has a cost
Time To Market
domenica 15 maggio 2011
again, what if
domenica 15 maggio 2011
There comes the boss
< seems complex,no Joomla this time,
when should it go live?
domenica 15 maggio 2011
There comes the boss< salesguy just told the client tomorrow
domenica 15 maggio 2011
There comes the boss
< ok, let's use a CMF
domenica 15 maggio 2011
unfortunately, there is no stableCMF in the PHP ecosystem
domenica 15 maggio 2011
so it has a cost
initial development
domenica 15 maggio 2011
investment=
know how (team) + quality (framework) +
velocity (that customers pretend)
=
CMF
domenica 15 maggio 2011
"Our" CMF
domenica 15 maggio 2011
Should be able to manage a site editing pages with
different elements.
Target: End User/Site admin
Easily, like a CMS.
domenica 15 maggio 2011
Target: Developer
should be able to plug the CMF with NO PAIN,using the kick-ass framework at the bottom of the CMF.
domenica 15 maggio 2011
domenica 15 maggio 2011
2things
domenica 15 maggio 2011
Pages
• main structure of a web site • organized as a tree• a way to express our contents• usually composed by a series of
containers ( that we'll refer to as boxes )
domenica 15 maggio 2011
Boxes
domenica 15 maggio 2011
Boxes
The way to separate single elements of a page
Loosely coupled HMVC structures
domenica 15 maggio 2011
Entities Pages
domenica 15 maggio 2011
Entities
Boxes {Bridge}
Pages
Boxes let entities be shown inside webpages
domenica 15 maggio 2011
Boxes
We dispose of different types of boxes:• Common• DSL
domenica 15 maggio 2011
Common Box
• Simple o Input field o Textareao Videoo Imageo File o Richtext
• Compositeo Input field + imageo input field + image + richetexo textarea + video
domenica 15 maggio 2011
what about the DSL?
domenica 15 maggio 2011
Domain Specific Language
DSL = ! (Website 1 Website 2 )
domenica 15 maggio 2011
Event
News Users
Books Review
Page
Widget
Event
News
UsersCars
Contract
Widget
Page
Example: Identify DSL
domenica 15 maggio 2011
domenica 15 maggio 2011
News
Page
Widget
domenica 15 maggio 2011
News
Page
Widget
Web Elements = CMF Entities
domenica 15 maggio 2011
Cars
Contract
Books
Review
News
Page
Widget
Web Elements = CMF Entities
domenica 15 maggio 2011
Cars
Contract
Books
Review
News
Page
Widget
DSL
Web Elements = CMF Entities
domenica 15 maggio 2011
back to the CMF
domenica 15 maggio 2011
CMF Stack
• Framework: symfony, for example• CMF entities: Site, Pages, Menus, Users ...• DSL entities: cars, contracts (for Hertz)• Common Boxes : Textarea, image, video, ...• Dsl boxes: Cars image gallery
domenica 15 maggio 2011
Common Boxes + DSL Boxes=
The main tool for the developer to build a page with the CMF
domenica 15 maggio 2011
Example : page & box compositionm
ost s
old
prod
uct
Richtext
Main product Image
domenica 15 maggio 2011
Example : page & box compositionm
ost s
old
prod
uct
Richtext
Main product Image
Dsl Boxes
domenica 15 maggio 2011
Example : page & box compositionm
ost s
old
prod
uct
Richtext
Main product Image
Dsl Boxes
Common Boxes
domenica 15 maggio 2011
Example : page & box compositionm
ost s
old
prod
uct
Richtext
Main product Image
Dsl Boxes
Common Boxes
domenica 15 maggio 2011
Example : page & box compositionm
ost s
old
prod
uct
Richtext
Main product Image
Dsl Boxes
Common Boxes
domenica 15 maggio 2011
Example : page & box compositionm
ost s
old
prod
uct
Richtext
Main product Image
Dsl Boxes
Common Boxes
domenica 15 maggio 2011
Example : page & box compositionm
ost s
old
prod
uct
Richtext
Main product Image
Dsl Boxes
Common Boxes
domenica 15 maggio 2011
The Page-Box Binding Storage
Data can change its structure fastly, according to the domain model.
We need a technology supporting this fast change.
Since we have N box type, to compose a page we shouldlook for a few tables.
We need a technology supporting this kind of lookups.
domenica 15 maggio 2011
so,How will we
manage the data?
domenica 15 maggio 2011
RDBMS, of course
domenica 15 maggio 2011
because different data always have
the same need
domenica 15 maggio 2011
one size fits all
domenica 15 maggio 2011
We tend to think at the way we should store data
not how we're gonna use it
domenica 15 maggio 2011
and we think that the
shit-it-always-happens migration
will be easy
domenica 15 maggio 2011
also if that column is useful for one and one only row
domenica 15 maggio 2011
among milions
domenica 15 maggio 2011
so we know we're gonna facea few well-known problems...
domenica 15 maggio 2011
Data Mapping
Data Structure RDBMS
we have to find a way to re-organize the data-structre to insert our tree inside a table.But is really different! Tree find a node in O(nlogn)
id
name
parent_id
domenica 15 maggio 2011
Data Mapping
Data Structure RDBMS
is better than before, but isn't the best way
domenica 15 maggio 2011
Data Mapping
Data Structure RDBMS
... and NOW??????
?
domenica 15 maggio 2011
The Alien
BUT you always find
something that as a different Behaviour
spend more time to normalize your models
domenica 15 maggio 2011
Unpredictable Tomorrow
User Story evolve continous
Worse than the Alien
domenica 15 maggio 2011
EAVformerly known as:
normalization WTF?!?!?!
or:how to do 70k joins to retrieve an entity of you model
domenica 15 maggio 2011
Overnormalized
user_id | mail_iduser_id | phone_id
user_id | address_id
user_id | mail | phone | address
Large schema is broken into smaller ones
domenica 15 maggio 2011
Overnormalized
user_id | address_id
user_id | phone_id
user_id | mail_id
...
...
...
...
...
LEFT JOIN
LEFT JOIN
LEFT JOIN
domenica 15 maggio 2011
Overnormalized
Users ListLEFT JOIN
LEFT JOIN
LEFT JOIN
LEFT JOINLEFT JOIN
LEFT JOINLEFT JOIN
domenica 15 maggio 2011
Overnormalized
LEFT JOIN
LEFT JOIN
LEFT JOINLEFT JOIN
LEFT JOIN
LEFT JOIN
LEFT JOINLEFT JOINLEFT JOIN
LEFT JOINLEFT JOIN
LEFT JOIN
LEFT JOIN
LEFT JOINLEFT JOIN
LEFT JOIN
LEFT JOINLEFT JOIN
What if you need to show only a single primary address?
Users List
domenica 15 maggio 2011
back to the CMF
domenica 15 maggio 2011
Bind Page with Boxes
Foreing Key -> TextareaBox
domenica 15 maggio 2011
Bind Page with Boxes
Foreing Key -> ?
AND NOW ???
domenica 15 maggio 2011
Mantain the RI#1
domenica 15 maggio 2011
Not Mantain the RI#2
domenica 15 maggio 2011
Maintain or not Maintain the RI; that is the
question
domenica 15 maggio 2011
we have to choose
domenica 15 maggio 2011
have you ever thought
"there should beanother way!"
?
domenica 15 maggio 2011
Can someone help us ?
domenica 15 maggio 2011
NoSQLlets try
world
domenica 15 maggio 2011
• Written in: C/C++ • Main point: Blazing fast• Protocol: Telnet-like• Disk-backed in-memory database, • but since 2.0, it can swap to disk. • Master-slave replication • Simple keys and values, • but complex operations like
ZREVRANGEBYSCORE • INCR• Values can be set to expire (as in a cache)
$ redis-cli set mykey "my binary safe value" => OK $ redis-cli get mykey => my binary safe value
domenica 15 maggio 2011
Best used: • rapidly changing data with
a foreseeable database size (should fit mostly in memory)
For example: • analytics• real-time data collection• caching• MQ• log
http://kkovacs.eu/cassandra-vs-mongodb-vs-couchdb-vs-redis
domenica 15 maggio 2011
very fast
domenica 15 maggio 2011
very fast
Object != key->value
domenica 15 maggio 2011
Not reliable
very fast
Object != key->value
domenica 15 maggio 2011
Not reliable
very fast
Object != key->value
Can I haz otha nozql?
domenica 15 maggio 2011
> j = { name : 'david', surname : 'funaro' };
{ "name" : "david", "surname" : "funaro" }
> db.things.save(t);
> db.things.find();
{ "_id" : ObjectId("4c2209f9f3924d31102bd84a"), "name" : "mongo" }
• Written in: C++ • Main point: Retains some friendly properties
of SQL• Protocol: Custom, binary (BSON) • Master/slave replication • speaks JavaScript• Built-in sharding• Performance over features • After crash, it needs to repair tables
domenica 15 maggio 2011
Best used:• you need dynamic queries• you prefer to define indexes,
not map/reduce functions• you need good performance on
a big DB
For example: • all things that you would do
with MySQL or PostgreSQL, but having predefined columns really holds you back
http://kkovacs.eu/cassandra-vs-mongodb-vs-couchdb-vs-redis
domenica 15 maggio 2011
Document Oriented
domenica 15 maggio 2011
Document Oriented
Schema Free
domenica 15 maggio 2011
Document Oriented
Schema Free
Navigate Object
domenica 15 maggio 2011
Document Oriented
Schema Free
Navigate Object
Can I haz otha nozql?
domenica 15 maggio 2011
• Written in: Erlang • Main point: DB consistency, ease of use• Protocol: HTTP, some say REST• Bi-directional replication => master-master• conflict detection ( 409 Conflict )• MVCC: write operations do not block reads • Previous versions of documents are available • Crash-only (reliable) design • Needs compacting from time to time • Views: embedded map/reduce• jQuery library included
curl -d '{"keys":["bar"]}' -X POST http://host:port/foo/_all_docs?include_docs=true
domenica 15 maggio 2011
Best used: • accumulating occasionally-
changing data• pre-defined queries• versioning is king
For example: • CRM/CMS systems• API
http://kkovacs.eu/cassandra-vs-mongodb-vs-couchdb-vs-redis
domenica 15 maggio 2011
Reliable
domenica 15 maggio 2011
Document Oriented
Reliable
domenica 15 maggio 2011
Document Oriented
Schema Free
Reliable
domenica 15 maggio 2011
Document Oriented
Schema Free
Navigate Object
Reliable
domenica 15 maggio 2011
Document Oriented
Schema Free
Navigate Object
Reliable
Can I haz otha nozql?
domenica 15 maggio 2011
Why do we so hardlyneed a GraphDBlike OrientDB?
domenica 15 maggio 2011
"GraphDBs don't avoid relations but they embrace them in a way that they are not a computational problem anymore, by making them explicit instead of implicit through joins."
Claudio Martella( http://blog.acaro.org/entry/somebody-is-going-to-hate-me-nosparql )
domenica 15 maggio 2011
Easy joins
select from users where city.country.continent = 'Oceania'
domenica 15 maggio 2011
Same link semantics,different objects
select links from menu >> 28:1, 17:5
domenica 15 maggio 2011
Same link semantics,different objects
select from [28:1, 17:5]
28:1
ExternalLinkurl: http://www.google.com
17:5
ProductLinkid: 4
domenica 15 maggio 2011
28:1
ExternalLinkurl: http://www.google.com
17:5
ProductLinkid: 4
$link->render()
domenica 15 maggio 2011
• Written in: Java• Main point: Graph• Protocol: Binary or HTTP• ACID• Disk-persisted or in-memory,• Cluster• 150k inserts per second• Schema-less, *-full, *-mixed• Speaks JSON• Integrated GUI• Documental• SQL commands
curl -X PUT '127.0.0.1:2480/document/demo/1:2' --data "{'@rid': '1:2'}"
domenica 15 maggio 2011
Reliable
domenica 15 maggio 2011
Graph - Documental
Reliable
domenica 15 maggio 2011
Graph - Documental
Schema-*
Reliable
domenica 15 maggio 2011
Graph - Documental
Schema-*
Reliable
Easy traversal
domenica 15 maggio 2011
Graph - Documental
Schema-*
Reliable
Easy traversal
SQL-friendly
domenica 15 maggio 2011
Graph - Documental
Schema-*
Reliable
Easy traversal
SQL-friendly
UberFast ( binary protocol )
domenica 15 maggio 2011
Graph - Documental
Schema-*
Reliable
Easy traversal
SQL-friendly
UberFast ( binary protocol )
Universal ( HTTP protocol )
domenica 15 maggio 2011
is so cool
domenica 15 maggio 2011
but has a problem...
domenica 15 maggio 2011
ver 1.0
domenica 15 maggio 2011
rc1
domenica 15 maggio 2011
but has a couple problems...
domenica 15 maggio 2011
JAVA
domenica 15 maggio 2011
but somebody
domenica 15 maggio 2011
started writing the binary-protocol binding
https://github.com/AntonTerekhov/OrientDB-PHP( beta, 28 April 2010 )
domenica 15 maggio 2011
and others
domenica 15 maggio 2011
domenica 15 maggio 2011
wrote the HTTP one
https://github.com/odino/Orient
domenica 15 maggio 2011
$driver = new Orient\Http\Client\Curl();$orient = new Orient\Foundation\Binding( $driver, '127.0.0.1', '2480', 'admin', 'admin', 'demo');
$response = $orient->query("select from fellas where any() traverse(0,-1) ( @rid = 1:1 )");
$output = json_decode($response->getBody());foreach ($output->result as $friend){ echo $friend->name;
// other fun...}
domenica 15 maggio 2011
you can start playing with a pure
GraphDB now
domenica 15 maggio 2011
High-level PHP Component?
domenica 15 maggio 2011
No
domenica 15 maggio 2011
but we know that ;)
domenica 15 maggio 2011
that's why in DNSEE we will build a basic
Object Graph Mapperfor OrientDB
domenica 15 maggio 2011
...because...
domenica 15 maggio 2011
hey, you remember about our CMF?
domenica 15 maggio 2011
codename:
domenica 15 maggio 2011
codename:
ConGoW
domenica 15 maggio 2011
codename:
contents gone wild
( don't ask why )
ConGoW
domenica 15 maggio 2011
ConGoW
domenica 15 maggio 2011
• soon the real kickstart
ConGoW
domenica 15 maggio 2011
• soon the real kickstart• 10 devs at the starting point
ConGoW
domenica 15 maggio 2011
• soon the real kickstart• 10 devs at the starting point• OSS on GitHub
ConGoW
domenica 15 maggio 2011
• soon the real kickstart• 10 devs at the starting point• OSS on GitHub• Stack
ConGoW
domenica 15 maggio 2011
• soon the real kickstart• 10 devs at the starting point• OSS on GitHub• Stack
oSymfony2
ConGoW
domenica 15 maggio 2011
• soon the real kickstart• 10 devs at the starting point• OSS on GitHub• Stack
oSymfony2oOrient
ConGoW
domenica 15 maggio 2011
• soon the real kickstart• 10 devs at the starting point• OSS on GitHub• Stack
oSymfony2oOrientoDoctrine2
ConGoW
domenica 15 maggio 2011
"My only friend, the end"
domenica 15 maggio 2011
"My only friend, the end"
David Funaro@ingdavidinohttp://davidfunaro.com
domenica 15 maggio 2011
"My only friend, the end"
David Funaro@ingdavidinohttp://davidfunaro.com
Alessandro Nadalin@_odino_
http://odino.org
domenica 15 maggio 2011
"My only friend, the end"
David Funaro@ingdavidinohttp://davidfunaro.com
Alessandro Nadalin@_odino_
http://odino.org
domenica 15 maggio 2011
"My only friend, the end"
David Funaro@ingdavidinohttp://davidfunaro.com
Alessandro Nadalin@_odino_
http://odino.org
http://joind.in/talk/view/3008
domenica 15 maggio 2011
Creditshttp://www.flickr.com/photos/pagedooley/5313217918/sizes/l/in/photostream/
http://www.flickr.com/photos/zoetnet/5520594473/sizes/l/in/photostream/http://www.flickr.com/photos/mhxbhd/3962410821/sizes/o/in/photostream/
http://www.flickr.com/photos/labyrinthx/1955594336/sizes/z/in/photostream/http://kkovacs.eu/cassandra-vs-mongodb-vs-couchdb-vs-redis
http://www.flickr.com/photos/salim/19426192/sizes/o/in/photostream/http://www.flickr.com/photos/mybluevan/3780363712/sizes/l/in/photostream/
http://farm4.static.flickr.com/3064/3086258014_f1925639e0.jpg
domenica 15 maggio 2011