SlideShare a Scribd company logo
From CakePHP to Laravel 
A look at PHP Frameworks
JMac
JMac != framework expert
Talk about the Talk 
• “Hello php[world]!” using the Top 5 frameworks 
• Code 
• Pros/Cons 
• Performance 
• Deciding on a Framework 
• Understanding the Hype Curve 
• Checking the Pulse 
• Tips for future-proofing
PHP is obsessed with frameworks
From CakePHP to Laravel
Hello php[world]!
CakePHP
Model Controller 
<?php 
App::uses('Controller', 'Controller'); 
! 
class HelloController extends Controller { 
public $uses = array('Message'); 
! 
public function index() { 
$this->layout = false; 
$message = $this->Message->findById(2); 
$this->set('message', $message); 
} 
} 
<?php 
App::uses('Model', 'Model'); 
! 
class Message extends Model { 
} 
View 
<?php 
echo htmlspecialchars($message['Message']['message'], ENT_COMPAT, 'UTF-8');
+Pros and -Cons 
+ Shallow learning curve 
+ Convention over Configuration 
+ Several built-in components and helpers 
- Not modern PHP OOP 
- Arrays for all the things! 
- Code Smells 
- No Composer (2.x)
yii
Model Controller 
<?php 
namespace appcontrollers; 
! 
use Yii; 
use yiifiltersAccessControl; 
use yiiwebController; 
use yiifiltersVerbFilter; 
use appmodelsLoginForm; 
use appmodelsContactForm; 
use appmodelsMessage; 
! 
class SiteController extends Controller { 
public function actionHello() { 
$this->layout = false; 
! 
$message = Message::find() 
->where(['id' => 2]) 
->one(); 
! 
return $this->render('hello', [ 
'message' => $message 
]); 
} 
} 
<?php 
namespace appmodels; 
! 
use yiidbActiveRecord; 
! 
class Message extends ActiveRecord { 
public static function tableName() { 
return 'messages'; 
} 
} 
View 
<?php 
use yiihelpersHtml; 
! 
echo Html::encode($message->message);
+Pros and -Cons 
+ Very Trim 
+ Composer 
+ Modern PHP OOP with namespacing 
- Tight coupling between MVC 
- Disorganized documentation
Phalcon
Model 
<?php 
class Message extends PhalconMvcModel { 
Controller 
<?php 
class HelloController extends PhalconMvcController { 
public function indexAction() { 
$message = Message::findFirst(2); 
! 
$this->view->setVar('message', $message); 
} 
} 
public function getSource() { 
return 'messages'; 
} 
} 
View 
<?php 
echo htmlspecialchars($message->message, ENT_COMPAT, 'UTF-8');
From CakePHP to Laravel
+Pros and -Cons 
+ Very, very trim 
+ Modern PHP OOP with namespacing 
- Compile PHP extensions 
- Disorganized documentation
Laravel
Model Controller 
<?php 
class HomeController extends BaseController { 
public function showHello() { 
$message = Hello::find(2); 
! 
return View::make( 
‘message', 
compact(‘message') 
); 
} 
} 
<?php 
use IlluminateAuthUserTrait; 
use IlluminateAuthUserInterface; 
use IlluminateAuthRemindersRemindableTrait; 
use IlluminateAuthRemindersRemindableInterface; 
! 
class Hello extends Eloquent { 
protected $table = 'messages'; 
} 
View 
<?php 
echo htmlspecialchars($message->message, ENT_COMPAT, 'UTF-8');
+Pros and -Cons 
+ Composer 
+ Modern PHP OOP with namespacing 
+ Good Documentation 
+ Elegant Design Patterns 
- Custom ORM and templating engine 
- Heavy use of Reflection 
- Object Registry
Symfony 2
Model Controller 
<?php 
namespace JMacDemoBundleController; 
! 
use SymfonyBundleFrameworkBundleControllerController; 
! 
class HelloController extends Controller { 
public function indexAction() { 
$message = $this->getDoctrine() 
->getRepository('JMacDemoBundle:Message') 
->find(2); 
! 
return $this->render( 
'JMacDemoBundle:Hello:index.html.php', 
array('message' => $message) 
); 
} 
} 
<?php 
namespace JMacDemoBundleEntity; 
! 
use DoctrineORMMapping as ORM; 
! 
/** 
* Message 
* 
* @ORMTable(name="messages") 
* @ORMEntity 
*/ 
class Message 
{ 
/** 
* @var integer 
* 
* @ORMColumn(name="id", 
type="integer") 
* @ORMId 
* @ORM 
GeneratedValue(strategy="AUTO") 
*/ 
private $id; 
! 
/** 
* @var string 
* 
* @ORMColumn(name="message", 
View 
<?php 
echo $view->escape($message->getMessage());
+Pros and -Cons 
+ Excellent Documentation 
+ Composer 
+ All the Components 
- Overchoice (yml, xml, twig, etc) 
- Heavy use of Reflection 
- Steepest Learning Curve (terminology)
A point about performance
siege -br 100 -c 10 http://phalcon.local/hello/
Performance Benchmarks 
Request Per Second 
500 
375 
250 
125 
0 
Phalcon CakePHP Yii Laravel Symfony2 
Framework
Frameworks are slow
deciding which framework to use
the hype curve
laravel cakephp 
yii, phalcon 
symfony
Checking the pulse
From CakePHP to Laravel
From CakePHP to Laravel
From CakePHP to Laravel
From CakePHP to Laravel
From CakePHP to Laravel
When to jump ship… 
• Lack of feature development 
• Hurts more than it helps 
• End of Life (CodeIgnitor?)
“On a long enough timeline, 
the survival rate for everyone 
drops to zero.”
future-proofing your code
learn PHP
avoid custom components
fat models skinny controllers
service objects
service objects
why you don’t need a framework
<rant>
Performance Benchmarks 
Request Per Second 
4,000 
3,000 
2,000 
1,000 
0 
HTML PHP PHP + DB Phalcon CakePHP Yii Laravel Symfony2 
Framework
</rant>
Let’s talk! 
@gonedark 
jason@pureconcepts.net

More Related Content

PDF
Hack the Future
PDF
All Aboard for Laravel 5.1
PDF
Why Laravel?
PPTX
10 Laravel packages everyone should know
PDF
Knowing Laravel 5 : The most popular PHP framework
PDF
All the Laravel things: up and running to making $$
PDF
Adventures in Laravel 5 SunshinePHP 2016 Tutorial
PPTX
What's New in Laravel 5 (Laravel Meetup - 23th Apr 15, Yogyakarta, ID)
Hack the Future
All Aboard for Laravel 5.1
Why Laravel?
10 Laravel packages everyone should know
Knowing Laravel 5 : The most popular PHP framework
All the Laravel things: up and running to making $$
Adventures in Laravel 5 SunshinePHP 2016 Tutorial
What's New in Laravel 5 (Laravel Meetup - 23th Apr 15, Yogyakarta, ID)

What's hot (20)

PDF
Digpen 7: Why choose Laravel?
PPTX
Introduction to Laravel Framework (5.2)
PDF
Getting to know Laravel 5
PDF
Laravel 5 New Features
PDF
MidwestPHP 2016 - Adventures in Laravel 5
PDF
What's New In Laravel 5
PPTX
Workshop Laravel 5.2
PPTX
Intro to Laravel
PDF
Laravel 5.4
PPTX
Laravel for Web Artisans
PDF
Laravel Forge: Hello World to Hello Production
PDF
php[world] 2015 Training - Laravel from the Ground Up
PPTX
Laravel Beginners Tutorial 1
PPTX
Laravel 5
PDF
php[world] 2015 Laravel 5.1: From Homestead to the Cloud
PDF
Laravel 5 Annotations: RESTful API routing
PDF
Laravel Forge: Hello World to Hello Production
PDF
Web Development with Laravel 5
PPTX
A introduction to Laravel framework
PPT
Laravel Starter Kit | Laravel Admin Template-ChandraAdmin
Digpen 7: Why choose Laravel?
Introduction to Laravel Framework (5.2)
Getting to know Laravel 5
Laravel 5 New Features
MidwestPHP 2016 - Adventures in Laravel 5
What's New In Laravel 5
Workshop Laravel 5.2
Intro to Laravel
Laravel 5.4
Laravel for Web Artisans
Laravel Forge: Hello World to Hello Production
php[world] 2015 Training - Laravel from the Ground Up
Laravel Beginners Tutorial 1
Laravel 5
php[world] 2015 Laravel 5.1: From Homestead to the Cloud
Laravel 5 Annotations: RESTful API routing
Laravel Forge: Hello World to Hello Production
Web Development with Laravel 5
A introduction to Laravel framework
Laravel Starter Kit | Laravel Admin Template-ChandraAdmin
Ad

Similar to From CakePHP to Laravel (20)

PDF
Symfony2 San Francisco Meetup 2009
PDF
Symfony 2.0 on PHP 5.3
PPT
My cool new Slideshow!
PDF
Yii, frameworks and where PHP is heading to
PDF
Create Your Own Framework by Fabien Potencier
PDF
Build powerfull and smart web applications with Symfony2
PDF
PHP Web Development Frameworks & Advantages
PDF
Symfony 2 (PHP day 2009)
PDF
Php Conference Brazil - Phalcon Giant Killer
PPT
Php Frameworks
PDF
"Building Modern PHP Applications" - Jackson Murtha, South Dakota Code Camp 2012
PDF
PHP Frameworks and Symfony
PPTX
Comparing web frameworks
PPTX
Top 5 php framework
PDF
PHP Frameworks Review - Mar 19 2015
PDF
Symfony 2 (PHP Quebec 2009)
PDF
Symfony 2.0
PDF
A comparative study of laravel and symfony PHP frameworks
PPTX
Laravel vs CodeIgniter: Which Is the Best PHP Framework for 2025?
Symfony2 San Francisco Meetup 2009
Symfony 2.0 on PHP 5.3
My cool new Slideshow!
Yii, frameworks and where PHP is heading to
Create Your Own Framework by Fabien Potencier
Build powerfull and smart web applications with Symfony2
PHP Web Development Frameworks & Advantages
Symfony 2 (PHP day 2009)
Php Conference Brazil - Phalcon Giant Killer
Php Frameworks
"Building Modern PHP Applications" - Jackson Murtha, South Dakota Code Camp 2012
PHP Frameworks and Symfony
Comparing web frameworks
Top 5 php framework
PHP Frameworks Review - Mar 19 2015
Symfony 2 (PHP Quebec 2009)
Symfony 2.0
A comparative study of laravel and symfony PHP frameworks
Laravel vs CodeIgniter: Which Is the Best PHP Framework for 2025?
Ad

More from Jason McCreary (7)

PDF
Git Empowered
PDF
BDD in iOS with Cedar
PDF
Patterns, Code Smells, and The Pragmattic Programmer
PDF
Cache, Workers, and Queues
PDF
21 Ways to Make WordPress Fast
KEY
21 Ways to Make WordPress Fast
KEY
Configuring WordPress for Multiple Environments
Git Empowered
BDD in iOS with Cedar
Patterns, Code Smells, and The Pragmattic Programmer
Cache, Workers, and Queues
21 Ways to Make WordPress Fast
21 Ways to Make WordPress Fast
Configuring WordPress for Multiple Environments

Recently uploaded (20)

PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PDF
Empathic Computing: Creating Shared Understanding
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PPTX
sap open course for s4hana steps from ECC to s4
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PPTX
Spectroscopy.pptx food analysis technology
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
Unlocking AI with Model Context Protocol (MCP)
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
Encapsulation theory and applications.pdf
PPTX
MYSQL Presentation for SQL database connectivity
Chapter 3 Spatial Domain Image Processing.pdf
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
Empathic Computing: Creating Shared Understanding
Understanding_Digital_Forensics_Presentation.pptx
Advanced methodologies resolving dimensionality complications for autism neur...
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
Reach Out and Touch Someone: Haptics and Empathic Computing
sap open course for s4hana steps from ECC to s4
Per capita expenditure prediction using model stacking based on satellite ima...
Spectroscopy.pptx food analysis technology
Building Integrated photovoltaic BIPV_UPV.pdf
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
MIND Revenue Release Quarter 2 2025 Press Release
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Unlocking AI with Model Context Protocol (MCP)
The AUB Centre for AI in Media Proposal.docx
Encapsulation theory and applications.pdf
MYSQL Presentation for SQL database connectivity

From CakePHP to Laravel

  • 1. From CakePHP to Laravel A look at PHP Frameworks
  • 4. Talk about the Talk • “Hello php[world]!” using the Top 5 frameworks • Code • Pros/Cons • Performance • Deciding on a Framework • Understanding the Hype Curve • Checking the Pulse • Tips for future-proofing
  • 5. PHP is obsessed with frameworks
  • 9. Model Controller <?php App::uses('Controller', 'Controller'); ! class HelloController extends Controller { public $uses = array('Message'); ! public function index() { $this->layout = false; $message = $this->Message->findById(2); $this->set('message', $message); } } <?php App::uses('Model', 'Model'); ! class Message extends Model { } View <?php echo htmlspecialchars($message['Message']['message'], ENT_COMPAT, 'UTF-8');
  • 10. +Pros and -Cons + Shallow learning curve + Convention over Configuration + Several built-in components and helpers - Not modern PHP OOP - Arrays for all the things! - Code Smells - No Composer (2.x)
  • 11. yii
  • 12. Model Controller <?php namespace appcontrollers; ! use Yii; use yiifiltersAccessControl; use yiiwebController; use yiifiltersVerbFilter; use appmodelsLoginForm; use appmodelsContactForm; use appmodelsMessage; ! class SiteController extends Controller { public function actionHello() { $this->layout = false; ! $message = Message::find() ->where(['id' => 2]) ->one(); ! return $this->render('hello', [ 'message' => $message ]); } } <?php namespace appmodels; ! use yiidbActiveRecord; ! class Message extends ActiveRecord { public static function tableName() { return 'messages'; } } View <?php use yiihelpersHtml; ! echo Html::encode($message->message);
  • 13. +Pros and -Cons + Very Trim + Composer + Modern PHP OOP with namespacing - Tight coupling between MVC - Disorganized documentation
  • 15. Model <?php class Message extends PhalconMvcModel { Controller <?php class HelloController extends PhalconMvcController { public function indexAction() { $message = Message::findFirst(2); ! $this->view->setVar('message', $message); } } public function getSource() { return 'messages'; } } View <?php echo htmlspecialchars($message->message, ENT_COMPAT, 'UTF-8');
  • 17. +Pros and -Cons + Very, very trim + Modern PHP OOP with namespacing - Compile PHP extensions - Disorganized documentation
  • 19. Model Controller <?php class HomeController extends BaseController { public function showHello() { $message = Hello::find(2); ! return View::make( ‘message', compact(‘message') ); } } <?php use IlluminateAuthUserTrait; use IlluminateAuthUserInterface; use IlluminateAuthRemindersRemindableTrait; use IlluminateAuthRemindersRemindableInterface; ! class Hello extends Eloquent { protected $table = 'messages'; } View <?php echo htmlspecialchars($message->message, ENT_COMPAT, 'UTF-8');
  • 20. +Pros and -Cons + Composer + Modern PHP OOP with namespacing + Good Documentation + Elegant Design Patterns - Custom ORM and templating engine - Heavy use of Reflection - Object Registry
  • 22. Model Controller <?php namespace JMacDemoBundleController; ! use SymfonyBundleFrameworkBundleControllerController; ! class HelloController extends Controller { public function indexAction() { $message = $this->getDoctrine() ->getRepository('JMacDemoBundle:Message') ->find(2); ! return $this->render( 'JMacDemoBundle:Hello:index.html.php', array('message' => $message) ); } } <?php namespace JMacDemoBundleEntity; ! use DoctrineORMMapping as ORM; ! /** * Message * * @ORMTable(name="messages") * @ORMEntity */ class Message { /** * @var integer * * @ORMColumn(name="id", type="integer") * @ORMId * @ORM GeneratedValue(strategy="AUTO") */ private $id; ! /** * @var string * * @ORMColumn(name="message", View <?php echo $view->escape($message->getMessage());
  • 23. +Pros and -Cons + Excellent Documentation + Composer + All the Components - Overchoice (yml, xml, twig, etc) - Heavy use of Reflection - Steepest Learning Curve (terminology)
  • 24. A point about performance
  • 25. siege -br 100 -c 10 http://phalcon.local/hello/
  • 26. Performance Benchmarks Request Per Second 500 375 250 125 0 Phalcon CakePHP Yii Laravel Symfony2 Framework
  • 30. laravel cakephp yii, phalcon symfony
  • 37. When to jump ship… • Lack of feature development • Hurts more than it helps • End of Life (CodeIgnitor?)
  • 38. “On a long enough timeline, the survival rate for everyone drops to zero.”
  • 42. fat models skinny controllers
  • 45. why you don’t need a framework
  • 47. Performance Benchmarks Request Per Second 4,000 3,000 2,000 1,000 0 HTML PHP PHP + DB Phalcon CakePHP Yii Laravel Symfony2 Framework
  • 49. Let’s talk! @gonedark jason@pureconcepts.net