CakeFest 2012 – Conferences Day Summary Round 2

Second day here in Manchester, UK on the CakeFest Conference. Just like yesterday I will be adding during the day the summary of the conferences that I have been part of on the post. Check Twitter for a bunch of other updates about CakeFest. Yesterday CakeFest was the #1 topic in Twitter in the UK.

The first part of this post is at:

Simple Search with Elastic Search with Mark Story

  • Some details for Elastic Search
    • not an Amazon service
    • java based
    • lucene powered
    • document oriented database
    • easy to use and setup
    • super search solution
  • Similar to databases with multiple indexes types
  • A type is a mapping (schema) and the other part is all your data
  • document based REST api – yeay we can use cURL
  • one node is one server but you can have infinite number of nodes and indexes
  • by default the elastic search is on port 9200
  • there is no confirmation, so be careful when using delete – another thing, there is no authentication on production, so you have come with your own auth method
  • conflict resolution is by version numbers
  • commands: XGET, XDELETE, XPOST
  • for searching you can do both simple and advanced searches. You can build query strings for simple searches and contentby for advanced searches
    • query strings support boolean operators
  • down sides:
    • partial update is possible but complex
    • no joins (but you can search multiple indexes at the same time)
    • no map reduce
    • cannot replace all other datasources
  • read documentation for more info on all the query types that can be done – cool thing is that it handles geo-data in a very cool way
  • can search between types and indexes multiple times – use _ALL for retrieving all indexes about a given type
  • over a 1.5 GB of data a search can be as fast as 30 milisecs
  • a simple way for objects that have a lot joins, de-normalize the tables into a single one and place that new object on the elastic search
  • you can highlight search keywords (nice to see results in comand line) – the result is already a JSON formatted object
  • Facets – Elastic Search make’s it very easy to retrieve this facets by simply adjusting the config to return the facets that you are looking for per type
    • term counts
    • tag system
    • ranges
    • geo distance facets
  • declare all the mappings before you do the database – Elastic Search can be a bit of a pain if you don’t do this (for example, removing all data if you declare a mapping that doesn’t match the internal automatic mapping already created)
    • mappings can be string, intege, float, boolean, null and object where object is the standard
    • it has geo_point for lat/lon values – enables piles of search options and attachments between others
  • Shards and Replicas
    • define how many nodes you want to split your data accross
    • if a node goes down you still have some of your data
    • can use routing to control how data is shared
    • more shards distributes work and improves performance
  • Multi-Tenancy
    • one tenant per index (can be painful with a lot of indexes and multiple shards)
    • The work around is to use a filter condition but it is more error prune since you are using a filter with the benefit to shard between replicas and scales to many tenants. Just make suer that tenant id is not searchable
  • There are some plugins that you can use with it
  • Integration with CakePHP
    • easiest is to use cURL with json_encode
    • David Kullman ElasticSearch Datasource (github)
    • Kevin von Zonneveld Plugin (github) – similar to Sphinx

BDD for CakePHP Applications with Keinichiro Kishida

  • behaviour driven development (not beer driven development lol)
  • BDD is not testing it is a comunication framework so usually there is a story and specs manager to create the stories
  • making application for a better interaction with the client
  • better way to comunicate
  • match agile development
  • Frameworks
    • step frameworks and scneario frameworks
    • user story
    • fail step and scenario (story)
    • success step and scenario
    • refactoring for step and scenario
  • Spec Frameworks can be found on GitHub, some of them are pecs, spectrum, speciphy, PHPSpec and Spec for PHP. PHPSpec would be extended on the class as a namespace; Specify would use a DSL and Spec for PHP would be similar to a Ruby declaration
  • checkout
  • Story framework – he gave some examples but I lost the link will get them later
  • Feature is a way to tell the masses what is on my mind as a user. Example: II want to read articles on the site.
  • Scenario is a given, when then process.
  • Integration with CakePHP
    • The BDD plugin uses PHPSpec or Behat with the requirement of PHPUnit, CakePHP 2.x and some depencencies
    • all the testing specification is under a spec framework and story testing is  under behat
  • Interesting way to test your application by considering scenarios as a fail test and not code as failure
  • There are lot of examples so be sure to check @sizuhiko github

Avoiding surprises with Chef and Vagrant with Andy Gale

  • your dev environment and your production environment are not the same
    • different os
    • different php
    • different packages
  • so to solve the famous issue of: It works on my local you have to use some solution to have a consistency between the dev environment and the production
    • developing with a virtual machine would solve this issue. Avoids the consistency issue and it brings the benefit of starters to get up and running at the moment when they get on the corp
  • there are a bunch of issues to use virtual machine, so a solution for this is to use Vagrant
    • all you need is virtual box, a vagrant package (all O.S.) and configuring vagrant
  • To automating the providing and management of your servers you can use Chef. You use recipe to install, manage, restart, etc your servers. In blog there is a nice post for deploying chef with capistrano.
  • Setting vagrant on github you can simply clone the repository and then run vagrant up and it will automatically build up your virtual server
  • You can also set chef with vagrant so it can run some recipes to install cakephp and / or your application with the latest from github
  • Example and base tutorial in Github salgo/cakefest-vagrant-chef.git

Pluginize all things with Jose Diaz

  • Popular sites
    • or you can do Google Alerts to be up to date with the plugins that and Twitter by following the hashtag #cakephp
    • online guides
  • Plugin requirements
    • does it actually work (does what you need, breaks often). If is broken, dont fix it – most likely is a abandoned project
    • codebase (can you read it, syntax usage, proper implementation, easy to install – number of dependecies)
    • userbase (github forks/watches, how fast issues are solved, positive feedback)
    • documentation (wiki make a poor readme – no excuses :p, explicit usage docs, well formatted – easy to read)
    • development: development cycle is really good – few or decreasing issues – indicators to check a healthy codebase and the developer is easy to reach
  • Remember that pull-requests might take a bit more time (we have day-jobs too)
    • Test all things
    • Include documentation
  • Use Github and always include a Readme (with btw github includes automatically with each new repo, easy to edit)
  • Have at least one test
  • Use COMPOSER for releases
  • Finally submit to
  • Common good useful plugins (references to github):
    • oAuth – uzyn/cakephp-opauth
    • upload – josegonzalez/upload
    • Resque  – kamisama/cake-resque (for background work – jobs)
    • Assets Compress – markstory/asset_compress
    • Migrations – cakedc/migrations
    • Elastic Search – dkullman/elastic-search
    • PDF Generation – ceeram/cakepdf

Building PDF’s with CakePDF with Jelle Henkens

  • uses CakePDF plugin that can generate pdf documents from HTML
  • CakePDF was built because there is massive distinctions between pdf libraries
  • it has a nice 4 built-in pdf render engines (wkhtmltopdf, dompdf, mpdf, tcpdf)
  • configuration
    • add in bootstrap
    • requires the request handler component
    • there is a small issue with cake 2.1.x that requires a bootstrap change and a route change
  • You can do global settings (what engine to use, etc) and you can define document specific settings on the controller (controller overrites default)
  • You can use it as a parser for the .pdf view extension or as a stand-alone raw pdf that you can attach on email, offline processing, etc
  • The encryption uses 128 bit encryption that allows you to encrypt new and existing documents.
    • owner password (cant be the same as the user password)
    • user password
    • the use of the encryption on the plugin is very simple, mostly is part of the configuration to render the pdfs
  • As a personal note, this was by far the simplest and best plugins for cakephp PDF generation I have seen
  • github plugin /ceeram/cakepdf

Composer with Rafael Dohms

  • focused on building dependencies for a given project
  • pear project that works as a central repository
  • problem: team and my deployments to use consistent versions of dependencies of my project
    • pera doesn’t work (very wide spread – doesn’t work)
    • svn externals (why!? – doesn’t work)
    • git submodules (eh… also doesn’t help)
    • symphony management script (very limited – neh)
    • composer (yeay works)
  • Composer allows to declare a consist list of dependencies and versions for your application that can be shared with the team
  • First steps
    • Installing: local (embed) or global – local is better if you are building a project and sharing or waiting for contributors
    • to check if it is working just run a
      php composer.phar --version
    • to composer to work you need to create a json configuration file for composer where you tell what project needs what dependency. Adjust the minium stability as dev. Most likely most of the libs will be under dev level.
  • It checks on the dependencies that your projet needs but it also check on the dependencies of your dependency and update them
  • it does suggestions for a package to be look at
  • you can create skeletons so when it runs for the 1st time it will already create a skeleton of your project so you can start coding right away
  • very useful if you are contributing to a open source project – having composer you will already have the skeleton + development packages + the dependencies
  • composer generates an autoload file for all your dependencies or you can create an autoload config where you define psr-0, classmap and/or files that always required
  • Installing, configuring and moving on
    • composer.json – metadata and list of dependencies
    • composer.lock – existing dependencies and current commit hashes
    • update command will read composer.json and resolve of that and after it will write the composer.lock file
    • install command reads composer.json and compares to the composer.lock first and only get that version that is defined the lock file
  • commit composer.lock file into the repository and use composer install – just remember that 1 person should take care of the update of the lock file
  • it allows you to manage what php version is expected as minimum to exist prior installing the lib / vendor
  • upgrading to maestro
    • to avoid commit hell, add a hash tag with the commit number so it wont go further than that commit
    • you can also use the @ modifiers to get a specific version: i.e. @dev @stable @beta, etc
    • scripts allows you to run scripts at given moments
  • to use a library that is not on composer
    • use the type package where you declare on the fly all the information from the package so composer can install it on the fly
  • composer wraps PEAR so you can add the channels that you need and add the prefix / name of the package
  • useful commands
    • alias
    • replace – use package A in replace of package B
    • provide – this packages provides … (caching, etc)
  • finding a tune
    • use packagist to filter packages that you need
    • satis – indexes the libraries that are private to you (not open source)
  • it is still pretty new, so check the documentation and the #composer channel

Automated Deployment with a dash of Phyton with Mark Story

  • Deployment is:
    • all activities involved launching
    • making an application live
    • placing files on a server
    • should be secure, fast and easy
  • what is involved: release, install, update, rollback, uninstall, decommissioning and automation (imagine how fun is to deploy a bad release and have to rollback)
  • Release – when development is done – packaging, cleanup, version tagging, etc
  • Install – placement of executable files (php files for us), dependencies, software available
  • Upgrade – re-place app and dependencies
  • Rollback – detect errors and revert to prior release
  • Uninstall – remove all your code / dependencies from an server and move to another
  • Decommissioning – most forgotten step – removes all files and versions / cleanup
  • Automation – no humans allowed – find a way to automate it – deploying faster means that you can deploy more often and bringing value to your customers and clients
    • deployment is a scary thing to do so there is always fear so don’t forget that all deployments have some risk and make the whole process as simple as possible and always have a small test scenario
  • Proposed solution
    • deploy from vcs: commit -> merge -> automatic goes to server
    • uses a basic phyton module for deployments with a bit of fabric
    • copy task happens after the delete task
    • the config file is a simple json file where you tell what and where things will be – including what branch you will use for the deployment
    • when you run fabric it always logs into a remote machine an runs there
    • use fab -l to get a list of tasks you can run
  • example application that uses this process:
  • it makes the deployment script so easy that even a junior developer is able to do the deployments
  • integrate to systems like Jenkins can gain a lot of advantage for the deployment process
  • one trick with phyton: dont mix tab’s and spaces on the same file (lol)

Pecha Kucha Talks

  • Similar to yesterday Lightning talks but every presenter have to show a 5 minutes presentation divided in 20 secs each slide (yeah, slides required) and the slides are not controlled by the presenter – this will be fun to watch :P.


  • Check for the hash tag #cakefest on twitter to find a bunch of useful info like slides for the presentations, trolls, mentions, links, etc.

About mcloide

Making things simpler, just check: View all posts by mcloide

One response to “CakeFest 2012 – Conferences Day Summary Round 2

Leave a Reply

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

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

Google+ photo

You are commenting using your Google+ 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 )


Connecting to %s

%d bloggers like this: