CakePHP 3.x: first impressions

cake-logo

Having a pint at Octoberfest with Leonid, we have an interesting discussion about recent CakeFest held in Madrid. Apart of crazy stories about haircuts, and alcohol consumption that hotel had to witness those days, CakePHP 3.x was shortly introduced between the pints.

Since, I’ve been heavily using this framework in the last 3-4 years, and some heavy projects are still running on it, I’ve decided to have a look, to get the notion of what to expect, once the 3.x branch get to stable mode.

First impression was merely same as flood victim: in less then a split of a second, you realise how much you’ll have to re-write to comply with 3.x structure. It’s a lot! Almost a full re-write. Damn!

tumblr_inline_nczuo9C9ov1raprkq

 

Major improvements and redesigns affected:

  • ORM of Cake
  • Namespaces (namespaces, namespaces, names…)
  • Request/Response are defacto standards
  • Core became smaller, moving towards plug-ins architecture.
  • Composer-friendly.

I guess it’s the time to plan an upgrade, as not much time left for the release of stable 3.0.0 version.

For those of you willing to participate, get your coding kung-fu on the issue tracker in GitHub repo.

Ruby Sinatra in less than 999B of code

%w.rack tilt date INT TERM..map{|l|trap(l){$r.stop}rescue require l};$u=Date;$z=($u.new.year + 145).abs;puts "== Almost Sinatra/No Version has taken the stage on #$z for development with backup from Webrick"
$n=Module.new{extend Rack;a,D,S,q=Rack::Builder.new,Object.method(:define_method),/@@ *([^\n]+)\n(((?!@@)[^\n]*\n)*)/m
%w[get post put delete].map{|m|D.(m){|u,&b|a.map(u){run->(e){[200,{"Content-Type"=>"text/html"},[a.instance_eval(&b)]]}}}}
Tilt.mappings.map{|k,v|D.(k){|n,*o|$t||=(h=$u._jisx0301("hash, please");File.read(caller[0][/^[^:]+/]).scan(S){|a,b|h[a]=b};h);v[0].new(*o){n=="#{n}"?n:$t[n.to_s]}.render(a,o[0].try(:[],:locals)||{})}}
%w[set enable disable configure helpers use register].map{|m|D.(m){|*_,&b|b.try :[]}};END{Rack::Handler.get("webrick").run(a,Port:$z){|s|$r=s}}
%w[params session].map{|m|D.(m){q.send m}};a.use Rack::Session::Cookie;a.use Rack::Lock;D.(:before){|&b|a.use Rack::Config,&b};before{|e|q=Rack::Request.new e;q.params.dup.map{|k,v|params[k.to_sym]=v}}}

That’s a wow! That’s what I call a minimal Web Framework. Full description of the code can be found here.