SlideShare une entreprise Scribd logo
1  sur  26
Don't code, bake. 
An introduction to CakePHP
Welcome! 
#TeamRichard
Introduction 
PHP Developer 
at UK Web Media 
in Weyhill 
http://www.ukwm.co.uk 
Cyberstalk me! 
https://twitter.com/YellDavid 
https://github.com/davidyell 
http://careers.stackoverflow.com/davidyell 
http://uk.linkedin.com/in/davidyell 
#cakephp on Freenode IRC
CakePHP eh? 
Framework 
2005! 
Docs
Why is Cake good? 
Convention over configuration 
Less of this More of this
What is CakePHP? 
CakePHP makes building web applications simpler, faster and require less code. 
RAD 
Rapid Application 
Development 
MVC 
Model View Controller
Why should I use it? 
CakePHP makes building web applications simpler, faster and require less code. 
Do work. 
Make people happy. 
??? 
Profit!
Bake for 5 minutes
Model 
The knower of things 
● Eats lots of cake and loves being fat 
● Loves to play with the Datasource 
● Serves up tasty data 
● Varied behaviour 
2.x 
app/Model/Post.php 
3.x 
src/Model/Table/PostsTable.php 
src/Model/Entity/Post.php
Behaviors 
Share the love 
● Refactor shared model 
methods 
● Reusable code 
● Complex data operations 
● Callbacks 
● Dynamic attachment 
Models 
Shared 
Logic 
Behavior
Controller 
The brain 
● Dad for the day 
● Bosses the Model 
● Herds the View 
● Looks after the request 
● Callbacks 
Request 
Routing 
Controller 
Model 
View
Components 
Share the love 
● Refactor shared controller 
methods 
● Reusable code 
● Callbacks 
● Dynamic attachment 
Controllers 
Shared 
Logic 
Component
Views 
The pretty bit 
● Response 
● Works with the Controller 
● Shiny veneer 
Data 
Layout 
Template 
View 
2.x 
app/View/<Plural>/index.ctp 
3.x 
src/Template/<Plural>/index.ctp
Helpers 
Share the love 
● Give views some brains 
● Wrap up complex 
functionality 
● Reusable 
Form 
Html 
Number View 
Paginator 
Text 
Time
An extra slice of views 
● Build complex views 
● Reusable markup 
● Dynamic shared content 
Elements 
BBlloocckkss 
View Cells 
View 
3.x
Freebies! 
Behaviors 
● Containable 
● Translate 
● Tree 
Components 
● Pagination 
● Sessions 
● Authentication 
● Security 
● Request handling 
● Cookies 
Helpers 
● Cache 
● Form 
● Html 
● Number 
● Paginator 
● RSS 
● Session 
● Text 
● Time 
Utilities 
● Caching 
● Email 
● File & Folder 
● Hash 
● HttpSocket 
● Inflector 
● Internationalisation 
and localisation 
● Logging 
● CakeNumber 
● Router 
● Security 
● String 
● CakeTime 
● Xml 
3.x 
Behaviors 
● Timestamp 
● CounterCache 
Components 
● Flash Component 
● CSRF Component 
Helpers 
● URL Helper 
● Flash Helper
Plugins 
● Applications in applications 
● Can wrap anything 
● Distributable 
● Self contained 
● Single responsibility 
functionality
The journey from 2.x to 3.x 
5.4 
ORM 
16x Improvement in routing 
Simpler configuration External libraries
So which version should I use? 
2.x 
● Running in production 
● Want to use existing plugins 
● Prefer stable and secure 
3.x 
● Running locally or internally 
● Happy to migrate plugins 
● Prefer newer features 
● Learning from scratch or for fun
The book 
CakeBot: Book is http://book.cakephp.org the answer to life, the universe and all your bun making needs.
Convinced?
Blog tutorial 
2.x 
● 2.0 Book 
● Tutorials & Examples 
● Blog Tutorial 
http://book.cakephp.org/2.0/en/tutorials-and-examples/blog/blog.html 
3.x 
● 3.0 Book 
● Quick Start Guide 
● Blog Tutorial 
http://book.cakephp.org/3.0/en/quickstart.html#blog-tutorial
Ecosystem 
● Cakephp.org 
https://github.com/cakephp 
● Book - book.cakephp.org 
● Plugins – plugins.cakephp.org 
Friends of Cake – www.friendsofcake.com 
Check the core teams repos for more stuff
Further reading 
https://www.packtpub.com/all/?search=cakephp http://josediazgonzalez.com/cakephp-book/
Thanks! 
Questions? 
Feedback? 
https://joind.in/12118
The deadly live demo

Contenu connexe

Tendances

Full stack development
Full stack developmentFull stack development
Full stack developmentArnav Gupta
 
Blazor - An Introduction
Blazor - An IntroductionBlazor - An Introduction
Blazor - An IntroductionJamieTaylor112
 
Jaggery Introductory Webinar
Jaggery Introductory WebinarJaggery Introductory Webinar
Jaggery Introductory WebinarNuwan Bandara
 
Integrating grunt and bower with maven
Integrating grunt and bower with mavenIntegrating grunt and bower with maven
Integrating grunt and bower with mavenRahul Nanwani
 
Django Deployer
Django DeployerDjango Deployer
Django DeployerColin Su
 
Using Composer to create manageable WordPress websites
Using Composer to create manageable WordPress websitesUsing Composer to create manageable WordPress websites
Using Composer to create manageable WordPress websitesAnna Ladoshkina
 
Css,javascript,php,mysql
Css,javascript,php,mysqlCss,javascript,php,mysql
Css,javascript,php,mysqlvurimi prasad
 
Automate your WordPress Workflow with Grunt.js
Automate your WordPress Workflow with Grunt.jsAutomate your WordPress Workflow with Grunt.js
Automate your WordPress Workflow with Grunt.jsJosh Lee
 
Introduction to git & WordPress
Introduction to git & WordPressIntroduction to git & WordPress
Introduction to git & WordPressJosh Lee
 
WordPress as a Headless CMS - Bronson Quick
WordPress as a Headless CMS - Bronson QuickWordPress as a Headless CMS - Bronson Quick
WordPress as a Headless CMS - Bronson QuickWordCamp Sydney
 
Softshake 2013 - Let's take this offline
Softshake 2013 - Let's take this offlineSoftshake 2013 - Let's take this offline
Softshake 2013 - Let's take this offlineClaire Reynaud
 
Develop faster on Magento 2 using code generation tools
Develop faster on Magento 2 using code generation toolsDevelop faster on Magento 2 using code generation tools
Develop faster on Magento 2 using code generation toolsJuan Alonso
 
How to make your ruby code faster with multithreading
How to make your ruby code faster with multithreadingHow to make your ruby code faster with multithreading
How to make your ruby code faster with multithreadingSun-Li Beatteay
 
Simple Web Services with PHP
Simple Web Services with PHPSimple Web Services with PHP
Simple Web Services with PHPJohn Paul Ada
 
Node & Express as Workflow Tools
Node & Express as Workflow ToolsNode & Express as Workflow Tools
Node & Express as Workflow ToolsFITC
 
Making websites with WordPress
Making websites with WordPressMaking websites with WordPress
Making websites with WordPressJosh Lee
 
Headless approach and acquia - case study | Codesushi
Headless approach and acquia  - case study | CodesushiHeadless approach and acquia  - case study | Codesushi
Headless approach and acquia - case study | CodesushiKrzysztof (Chris) Ozog
 

Tendances (20)

Full stack development
Full stack developmentFull stack development
Full stack development
 
Blazor - An Introduction
Blazor - An IntroductionBlazor - An Introduction
Blazor - An Introduction
 
Jaggery Introductory Webinar
Jaggery Introductory WebinarJaggery Introductory Webinar
Jaggery Introductory Webinar
 
Blazor v1.1
Blazor v1.1Blazor v1.1
Blazor v1.1
 
Integrating grunt and bower with maven
Integrating grunt and bower with mavenIntegrating grunt and bower with maven
Integrating grunt and bower with maven
 
DevDay 2018 - Blazor
DevDay 2018 - BlazorDevDay 2018 - Blazor
DevDay 2018 - Blazor
 
Django Deployer
Django DeployerDjango Deployer
Django Deployer
 
Using Composer to create manageable WordPress websites
Using Composer to create manageable WordPress websitesUsing Composer to create manageable WordPress websites
Using Composer to create manageable WordPress websites
 
Css,javascript,php,mysql
Css,javascript,php,mysqlCss,javascript,php,mysql
Css,javascript,php,mysql
 
Automate your WordPress Workflow with Grunt.js
Automate your WordPress Workflow with Grunt.jsAutomate your WordPress Workflow with Grunt.js
Automate your WordPress Workflow with Grunt.js
 
Introduction to git & WordPress
Introduction to git & WordPressIntroduction to git & WordPress
Introduction to git & WordPress
 
WordPress as a Headless CMS - Bronson Quick
WordPress as a Headless CMS - Bronson QuickWordPress as a Headless CMS - Bronson Quick
WordPress as a Headless CMS - Bronson Quick
 
Softshake 2013 - Let's take this offline
Softshake 2013 - Let's take this offlineSoftshake 2013 - Let's take this offline
Softshake 2013 - Let's take this offline
 
Blazor Full-Stack
Blazor Full-StackBlazor Full-Stack
Blazor Full-Stack
 
Develop faster on Magento 2 using code generation tools
Develop faster on Magento 2 using code generation toolsDevelop faster on Magento 2 using code generation tools
Develop faster on Magento 2 using code generation tools
 
How to make your ruby code faster with multithreading
How to make your ruby code faster with multithreadingHow to make your ruby code faster with multithreading
How to make your ruby code faster with multithreading
 
Simple Web Services with PHP
Simple Web Services with PHPSimple Web Services with PHP
Simple Web Services with PHP
 
Node & Express as Workflow Tools
Node & Express as Workflow ToolsNode & Express as Workflow Tools
Node & Express as Workflow Tools
 
Making websites with WordPress
Making websites with WordPressMaking websites with WordPress
Making websites with WordPress
 
Headless approach and acquia - case study | Codesushi
Headless approach and acquia  - case study | CodesushiHeadless approach and acquia  - case study | Codesushi
Headless approach and acquia - case study | Codesushi
 

Similaire à Don't Code, Bake. An introduction to CakePHP ~PHP Hampshire Oct 2014

PHP South Coast - Don't code bake, an introduction to CakePHP 3
PHP South Coast - Don't code bake, an introduction to CakePHP 3PHP South Coast - Don't code bake, an introduction to CakePHP 3
PHP South Coast - Don't code bake, an introduction to CakePHP 3David Yell
 
PHP Berkshire October 2015
PHP Berkshire October 2015PHP Berkshire October 2015
PHP Berkshire October 2015David Yell
 
JS digest. Decemebr 2017
JS digest. Decemebr 2017JS digest. Decemebr 2017
JS digest. Decemebr 2017ElifTech
 
Making sense of the front-end, for PHP developers
Making sense of the front-end, for PHP developersMaking sense of the front-end, for PHP developers
Making sense of the front-end, for PHP developersLewiz
 
Becoming A Drupal Master Builder
Becoming A Drupal Master BuilderBecoming A Drupal Master Builder
Becoming A Drupal Master BuilderPhilip Norton
 
Multiplier Effect: Case Studies in Distributions for Publishers
Multiplier Effect: Case Studies in Distributions for PublishersMultiplier Effect: Case Studies in Distributions for Publishers
Multiplier Effect: Case Studies in Distributions for PublishersJon Peck
 
Chef - Administration for programmers
Chef - Administration for programmersChef - Administration for programmers
Chef - Administration for programmersmrsabo
 
PyGrunn2013 High Performance Web Applications with TurboGears
PyGrunn2013  High Performance Web Applications with TurboGearsPyGrunn2013  High Performance Web Applications with TurboGears
PyGrunn2013 High Performance Web Applications with TurboGearsAlessandro Molina
 
The Professional Programmer
The Professional ProgrammerThe Professional Programmer
The Professional ProgrammerDave Cross
 
Test all the things! Automated testing with Drupal 8
Test all the things! Automated testing with Drupal 8Test all the things! Automated testing with Drupal 8
Test all the things! Automated testing with Drupal 8Sam Becker
 
Go with the Flow - A Guide to a WordPress Workflow
Go with the Flow - A Guide to a WordPress WorkflowGo with the Flow - A Guide to a WordPress Workflow
Go with the Flow - A Guide to a WordPress WorkflowAnn Cascarano
 
You Can Work on the Web Patform! (GOSIM 2023)
You Can Work on the Web Patform! (GOSIM 2023)You Can Work on the Web Patform! (GOSIM 2023)
You Can Work on the Web Patform! (GOSIM 2023)Igalia
 
Scraping the web with Laravel, Dusk, Docker, and PHP
Scraping the web with Laravel, Dusk, Docker, and PHPScraping the web with Laravel, Dusk, Docker, and PHP
Scraping the web with Laravel, Dusk, Docker, and PHPPaul Redmond
 
They why behind php frameworks
They why behind php frameworksThey why behind php frameworks
They why behind php frameworksKirk Madera
 
DevOps for TYPO3 Teams and Projects
DevOps for TYPO3 Teams and ProjectsDevOps for TYPO3 Teams and Projects
DevOps for TYPO3 Teams and ProjectsFedir RYKHTIK
 
Go with the Flow - A Guide to a WordPress Workflow
Go with the Flow - A Guide to a WordPress WorkflowGo with the Flow - A Guide to a WordPress Workflow
Go with the Flow - A Guide to a WordPress WorkflowAnn Cascarano
 
EuroPython 2013 - Python3 TurboGears Training
EuroPython 2013 - Python3 TurboGears TrainingEuroPython 2013 - Python3 TurboGears Training
EuroPython 2013 - Python3 TurboGears TrainingAlessandro Molina
 
Intro to XPages for Administrators (DanNotes, November 28, 2012)
Intro to XPages for Administrators (DanNotes, November 28, 2012)Intro to XPages for Administrators (DanNotes, November 28, 2012)
Intro to XPages for Administrators (DanNotes, November 28, 2012)Per Henrik Lausten
 

Similaire à Don't Code, Bake. An introduction to CakePHP ~PHP Hampshire Oct 2014 (20)

PHP South Coast - Don't code bake, an introduction to CakePHP 3
PHP South Coast - Don't code bake, an introduction to CakePHP 3PHP South Coast - Don't code bake, an introduction to CakePHP 3
PHP South Coast - Don't code bake, an introduction to CakePHP 3
 
PHP Berkshire October 2015
PHP Berkshire October 2015PHP Berkshire October 2015
PHP Berkshire October 2015
 
JS digest. Decemebr 2017
JS digest. Decemebr 2017JS digest. Decemebr 2017
JS digest. Decemebr 2017
 
Making sense of the front-end, for PHP developers
Making sense of the front-end, for PHP developersMaking sense of the front-end, for PHP developers
Making sense of the front-end, for PHP developers
 
Becoming A Drupal Master Builder
Becoming A Drupal Master BuilderBecoming A Drupal Master Builder
Becoming A Drupal Master Builder
 
Multiplier Effect: Case Studies in Distributions for Publishers
Multiplier Effect: Case Studies in Distributions for PublishersMultiplier Effect: Case Studies in Distributions for Publishers
Multiplier Effect: Case Studies in Distributions for Publishers
 
Itb2018 integrating mvc into legacy
Itb2018   integrating mvc into legacyItb2018   integrating mvc into legacy
Itb2018 integrating mvc into legacy
 
Chef - Administration for programmers
Chef - Administration for programmersChef - Administration for programmers
Chef - Administration for programmers
 
Web Applications
Web ApplicationsWeb Applications
Web Applications
 
PyGrunn2013 High Performance Web Applications with TurboGears
PyGrunn2013  High Performance Web Applications with TurboGearsPyGrunn2013  High Performance Web Applications with TurboGears
PyGrunn2013 High Performance Web Applications with TurboGears
 
The Professional Programmer
The Professional ProgrammerThe Professional Programmer
The Professional Programmer
 
Test all the things! Automated testing with Drupal 8
Test all the things! Automated testing with Drupal 8Test all the things! Automated testing with Drupal 8
Test all the things! Automated testing with Drupal 8
 
Go with the Flow - A Guide to a WordPress Workflow
Go with the Flow - A Guide to a WordPress WorkflowGo with the Flow - A Guide to a WordPress Workflow
Go with the Flow - A Guide to a WordPress Workflow
 
You Can Work on the Web Patform! (GOSIM 2023)
You Can Work on the Web Patform! (GOSIM 2023)You Can Work on the Web Patform! (GOSIM 2023)
You Can Work on the Web Patform! (GOSIM 2023)
 
Scraping the web with Laravel, Dusk, Docker, and PHP
Scraping the web with Laravel, Dusk, Docker, and PHPScraping the web with Laravel, Dusk, Docker, and PHP
Scraping the web with Laravel, Dusk, Docker, and PHP
 
They why behind php frameworks
They why behind php frameworksThey why behind php frameworks
They why behind php frameworks
 
DevOps for TYPO3 Teams and Projects
DevOps for TYPO3 Teams and ProjectsDevOps for TYPO3 Teams and Projects
DevOps for TYPO3 Teams and Projects
 
Go with the Flow - A Guide to a WordPress Workflow
Go with the Flow - A Guide to a WordPress WorkflowGo with the Flow - A Guide to a WordPress Workflow
Go with the Flow - A Guide to a WordPress Workflow
 
EuroPython 2013 - Python3 TurboGears Training
EuroPython 2013 - Python3 TurboGears TrainingEuroPython 2013 - Python3 TurboGears Training
EuroPython 2013 - Python3 TurboGears Training
 
Intro to XPages for Administrators (DanNotes, November 28, 2012)
Intro to XPages for Administrators (DanNotes, November 28, 2012)Intro to XPages for Administrators (DanNotes, November 28, 2012)
Intro to XPages for Administrators (DanNotes, November 28, 2012)
 

Dernier

What’s New in VictoriaMetrics: Q1 2024 Updates
What’s New in VictoriaMetrics: Q1 2024 UpdatesWhat’s New in VictoriaMetrics: Q1 2024 Updates
What’s New in VictoriaMetrics: Q1 2024 UpdatesVictoriaMetrics
 
Post Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on IdentityPost Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on Identityteam-WIBU
 
Not a Kubernetes fan? The state of PaaS in 2024
Not a Kubernetes fan? The state of PaaS in 2024Not a Kubernetes fan? The state of PaaS in 2024
Not a Kubernetes fan? The state of PaaS in 2024Anthony Dahanne
 
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptx
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptxReal-time Tracking and Monitoring with Cargo Cloud Solutions.pptx
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptxRTS corp
 
VictoriaMetrics Q1 Meet Up '24 - Community & News Update
VictoriaMetrics Q1 Meet Up '24 - Community & News UpdateVictoriaMetrics Q1 Meet Up '24 - Community & News Update
VictoriaMetrics Q1 Meet Up '24 - Community & News UpdateVictoriaMetrics
 
SoftTeco - Software Development Company Profile
SoftTeco - Software Development Company ProfileSoftTeco - Software Development Company Profile
SoftTeco - Software Development Company Profileakrivarotava
 
Salesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZSalesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZABSYZ Inc
 
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...confluent
 
SAM Training Session - How to use EXCEL ?
SAM Training Session - How to use EXCEL ?SAM Training Session - How to use EXCEL ?
SAM Training Session - How to use EXCEL ?Alexandre Beguel
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtimeandrehoraa
 
Keeping your build tool updated in a multi repository world
Keeping your build tool updated in a multi repository worldKeeping your build tool updated in a multi repository world
Keeping your build tool updated in a multi repository worldRoberto Pérez Alcolea
 
Large Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and RepairLarge Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and RepairLionel Briand
 
Amazon Bedrock in Action - presentation of the Bedrock's capabilities
Amazon Bedrock in Action - presentation of the Bedrock's capabilitiesAmazon Bedrock in Action - presentation of the Bedrock's capabilities
Amazon Bedrock in Action - presentation of the Bedrock's capabilitiesKrzysztofKkol1
 
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsSensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsChristian Birchler
 
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...Bert Jan Schrijver
 
Powering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsPowering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsSafe Software
 
Osi security architecture in network.pptx
Osi security architecture in network.pptxOsi security architecture in network.pptx
Osi security architecture in network.pptxVinzoCenzo
 
Patterns for automating API delivery. API conference
Patterns for automating API delivery. API conferencePatterns for automating API delivery. API conference
Patterns for automating API delivery. API conferencessuser9e7c64
 
Ronisha Informatics Private Limited Catalogue
Ronisha Informatics Private Limited CatalogueRonisha Informatics Private Limited Catalogue
Ronisha Informatics Private Limited Catalogueitservices996
 
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...OnePlan Solutions
 

Dernier (20)

What’s New in VictoriaMetrics: Q1 2024 Updates
What’s New in VictoriaMetrics: Q1 2024 UpdatesWhat’s New in VictoriaMetrics: Q1 2024 Updates
What’s New in VictoriaMetrics: Q1 2024 Updates
 
Post Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on IdentityPost Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on Identity
 
Not a Kubernetes fan? The state of PaaS in 2024
Not a Kubernetes fan? The state of PaaS in 2024Not a Kubernetes fan? The state of PaaS in 2024
Not a Kubernetes fan? The state of PaaS in 2024
 
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptx
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptxReal-time Tracking and Monitoring with Cargo Cloud Solutions.pptx
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptx
 
VictoriaMetrics Q1 Meet Up '24 - Community & News Update
VictoriaMetrics Q1 Meet Up '24 - Community & News UpdateVictoriaMetrics Q1 Meet Up '24 - Community & News Update
VictoriaMetrics Q1 Meet Up '24 - Community & News Update
 
SoftTeco - Software Development Company Profile
SoftTeco - Software Development Company ProfileSoftTeco - Software Development Company Profile
SoftTeco - Software Development Company Profile
 
Salesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZSalesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZ
 
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
 
SAM Training Session - How to use EXCEL ?
SAM Training Session - How to use EXCEL ?SAM Training Session - How to use EXCEL ?
SAM Training Session - How to use EXCEL ?
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtime
 
Keeping your build tool updated in a multi repository world
Keeping your build tool updated in a multi repository worldKeeping your build tool updated in a multi repository world
Keeping your build tool updated in a multi repository world
 
Large Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and RepairLarge Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and Repair
 
Amazon Bedrock in Action - presentation of the Bedrock's capabilities
Amazon Bedrock in Action - presentation of the Bedrock's capabilitiesAmazon Bedrock in Action - presentation of the Bedrock's capabilities
Amazon Bedrock in Action - presentation of the Bedrock's capabilities
 
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsSensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
 
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...
 
Powering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsPowering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data Streams
 
Osi security architecture in network.pptx
Osi security architecture in network.pptxOsi security architecture in network.pptx
Osi security architecture in network.pptx
 
Patterns for automating API delivery. API conference
Patterns for automating API delivery. API conferencePatterns for automating API delivery. API conference
Patterns for automating API delivery. API conference
 
Ronisha Informatics Private Limited Catalogue
Ronisha Informatics Private Limited CatalogueRonisha Informatics Private Limited Catalogue
Ronisha Informatics Private Limited Catalogue
 
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
 

Don't Code, Bake. An introduction to CakePHP ~PHP Hampshire Oct 2014

  • 1. Don't code, bake. An introduction to CakePHP
  • 3. Introduction PHP Developer at UK Web Media in Weyhill http://www.ukwm.co.uk Cyberstalk me! https://twitter.com/YellDavid https://github.com/davidyell http://careers.stackoverflow.com/davidyell http://uk.linkedin.com/in/davidyell #cakephp on Freenode IRC
  • 5. Why is Cake good? Convention over configuration Less of this More of this
  • 6. What is CakePHP? CakePHP makes building web applications simpler, faster and require less code. RAD Rapid Application Development MVC Model View Controller
  • 7. Why should I use it? CakePHP makes building web applications simpler, faster and require less code. Do work. Make people happy. ??? Profit!
  • 8. Bake for 5 minutes
  • 9. Model The knower of things ● Eats lots of cake and loves being fat ● Loves to play with the Datasource ● Serves up tasty data ● Varied behaviour 2.x app/Model/Post.php 3.x src/Model/Table/PostsTable.php src/Model/Entity/Post.php
  • 10. Behaviors Share the love ● Refactor shared model methods ● Reusable code ● Complex data operations ● Callbacks ● Dynamic attachment Models Shared Logic Behavior
  • 11. Controller The brain ● Dad for the day ● Bosses the Model ● Herds the View ● Looks after the request ● Callbacks Request Routing Controller Model View
  • 12. Components Share the love ● Refactor shared controller methods ● Reusable code ● Callbacks ● Dynamic attachment Controllers Shared Logic Component
  • 13. Views The pretty bit ● Response ● Works with the Controller ● Shiny veneer Data Layout Template View 2.x app/View/<Plural>/index.ctp 3.x src/Template/<Plural>/index.ctp
  • 14. Helpers Share the love ● Give views some brains ● Wrap up complex functionality ● Reusable Form Html Number View Paginator Text Time
  • 15. An extra slice of views ● Build complex views ● Reusable markup ● Dynamic shared content Elements BBlloocckkss View Cells View 3.x
  • 16. Freebies! Behaviors ● Containable ● Translate ● Tree Components ● Pagination ● Sessions ● Authentication ● Security ● Request handling ● Cookies Helpers ● Cache ● Form ● Html ● Number ● Paginator ● RSS ● Session ● Text ● Time Utilities ● Caching ● Email ● File & Folder ● Hash ● HttpSocket ● Inflector ● Internationalisation and localisation ● Logging ● CakeNumber ● Router ● Security ● String ● CakeTime ● Xml 3.x Behaviors ● Timestamp ● CounterCache Components ● Flash Component ● CSRF Component Helpers ● URL Helper ● Flash Helper
  • 17. Plugins ● Applications in applications ● Can wrap anything ● Distributable ● Self contained ● Single responsibility functionality
  • 18. The journey from 2.x to 3.x 5.4 ORM 16x Improvement in routing Simpler configuration External libraries
  • 19. So which version should I use? 2.x ● Running in production ● Want to use existing plugins ● Prefer stable and secure 3.x ● Running locally or internally ● Happy to migrate plugins ● Prefer newer features ● Learning from scratch or for fun
  • 20. The book CakeBot: Book is http://book.cakephp.org the answer to life, the universe and all your bun making needs.
  • 22. Blog tutorial 2.x ● 2.0 Book ● Tutorials & Examples ● Blog Tutorial http://book.cakephp.org/2.0/en/tutorials-and-examples/blog/blog.html 3.x ● 3.0 Book ● Quick Start Guide ● Blog Tutorial http://book.cakephp.org/3.0/en/quickstart.html#blog-tutorial
  • 23. Ecosystem ● Cakephp.org https://github.com/cakephp ● Book - book.cakephp.org ● Plugins – plugins.cakephp.org Friends of Cake – www.friendsofcake.com Check the core teams repos for more stuff
  • 24. Further reading https://www.packtpub.com/all/?search=cakephp http://josediazgonzalez.com/cakephp-book/
  • 25. Thanks! Questions? Feedback? https://joind.in/12118

Notes de l'éditeur

  1. Thanks to PHP Hampshire for inviting me to talk! It&amp;apos;s my first proper talk so apologies in advance for any hilarious cock ups. Thanks to you guys, the attendees I appreciate you taking the time to come down and listen to my presentation. For those who don&amp;apos;t know, this is the Great British Bake Off team, I&amp;apos;m made to watch this by my girlfriend, obviously.
  2. Six years commercial experience, mostly agencies doing campaign work. Started with HTML on GeoCities. Self-taught myself PHP whilst building an arbiter for the Howling Rain alliance in Planetarion. UKWM do campaign and affiliate marketing work, we are recruiting for another developer so if this presentation sounds like something you&amp;apos;d be interested in let me know and I can hook you up. This is my first presentation so be gentle! I will hopefully have some time at the end for questions.
  3. CakePHP is a PHP based MVC RAD framework. The idea is to allow rapid development of applications but also be flexible enough to allow customisation and further development. In the top 5 most popular php frameworks Two released major versions, 1.3 and 2.x Version 3.x currently in beta1 (beta2 recently), under active development, nearly 7k commits to 3.x More than 8 million visitors to the framework website Over 31 million page views of the website Nearing 10 years of life! Completely open source, community driven development. Mention that anyone can contribute and is welcome to do so, it&amp;apos;s encouraged. Talk about the documentation being maintained and that people can also contribute back it quickly and easily, the &amp;apos;improve button&amp;apos; CakeFest 2014 had over 110 attendees from 22 different countries! CakePHP maintains a presence in social media, with twitter, facebook, google groups, youtube, podcast and active stack overflow community.
  4. Instead of configuring your application you can simply stick to conventions in the framework to have everything work out of the box. Of course you can override the conventions when and if you want to. For example you can have a Table reading from a db table with a different name if you want. Again, I&amp;apos;m lazy. I like not writing and validating YAML or XML. Anyone hate things not working when there is a missing character in your configuration? I do. 2.x Plural db tables, singular Model names, plural Controllers and plural View folders. 3.x Plural db tables, plural Table classes, singular Entities, plural Controllers and plural Template folders. For example a database table called &amp;apos;people&amp;apos; would have a model class called &amp;apos;Person&amp;apos; and use the &amp;apos;PeopleController&amp;apos; and have it&amp;apos;s views in the &amp;apos;people&amp;apos; folder. Cakes inflector will take care of pluralisation and singularisation of words. You can obviously add your own rules, but it currently understands things such as the example, and also fish and sheep.
  5. So I mentioned RAD and MVC. Everyone heard of these two principles? Wikipedia says “In general, RAD approaches to software development put less emphasis on planning tasks and more emphasis on development.” It&amp;apos;s worth noting that you do want to still do a little planning, mostly with your database. What information you want to store and how to store it. In essence it&amp;apos;s more about building stuff than chatting about building stuff. MVC is about creating separation of concerns and keeping code clean and DRY (don&amp;apos;t repeat yourself) which is related to refactoring for me at least, but that&amp;apos;s a bit off topic here.
  6. I want to be happy I want to make people happy. They might be my colleagues, clients or internal project stakeholders. I want you guys to be happy. Happiness breads motivation. It helps you guys get out of bed and build awesome applications every day. This mean delivering applications and functionality to project stakeholders on time and in budget. Using an MVC RAD framework you&amp;apos;re able to develop complex applications very quickly, iterate early, and fast, but still to a high standard. A framework helps to give a standardised basis of work for developers meaning that code becomes more transferrable and easier to maintain. The &amp;apos;profit&amp;apos; here might be happyness, it might be motivation, it might be a happy client, a great application, a fully passing test suite, green CI reports. All kinds of things. Make sure to pick the right tool for the job. Noone can claim that any one tool or framework is a blanket tool for all cases. I rebuilt my companies most profitable website from a legacy system to cakephp, due to a deadline, in one week and it&amp;apos;s still live and living happily. It even went live on a Friday of a bank holiday when I had the Tuesday off. I don&amp;apos;t test, but when I do, I do it in production!
  7. By using the convention over configuration we are able to leverage the automated coding tools in the shell to write out our basic code for us. The bake shell task allows rapid prototyping of features or for you to just build a whole site out to see how it&amp;apos;ll work. You can then proceed to customise the application as you need. The great thing with the bake shell specifically is that the code generated is based on a bake theme, which you can customise. So if you want to change anything that is being generated you can simply change the bake theme and rebake to get new code! I&amp;apos;ve actually built a plugin which has my own bake theme for generating my admin areas so that I can include all the customisations that I like, such as Twitter bootstrap right away. They always say that if you do something more than three times you should automate it, so why not the same with how you automatically generate your code? So here I have created an ERD in MySQL Workbench and used the forward engineer tool to build my database automatically. Then I can use the bake shell task to automatically build my application code. From here I can run it in my browser using the built in php server. By running &amp;apos;Console/cake server&amp;apos;. If you are using Vagrant for development, I&amp;apos;ll come onto that later in the presentation as there are some CakePHP tools setup for that. Let&amp;apos;s take a look at what&amp;apos;s being generated, how it fits together and how it&amp;apos;s organised.
  8. Anything to do with data should be in a model. Extends AppModel. Fat models are good, many functions can be refactored into models to keep your controllers thin and allow your controllers to access the methods through the model. A datasource actually does the heavy lifting against the data provider. So you can create any datasource you want and it remains transparent to the model. Can write a datasource for anything, mysql, mongo, api, etc Models store contain your data when it&amp;apos;s returned. In 2.x data is returned as arrays, however there is an object plugin if you prefer that. (https://github.com/josegonzalez/cakephp-entity) In 3.x you&amp;apos;ll get a query object instead which contains a collection of objects. Used to build relationships between objects in the application. Post hasMany Tag for example would be defined in the model. Deals with data validation in your forms using the rules defined in your models.
  9. Spelling. &amp;apos;murica Behaviours are essentially mixins for your models. In order to keep your fat models organised any shared logic or callbacks that you need to apply to multiple models can be refactored into a behaviour. This allows you to easily attach that behaviour to any model to give it access to that functionality. Example, you want to timestamp when a record changes. You&amp;apos;d go right in for the &amp;apos;beforeSave()&amp;apos; method to add a timestamp to the data. However you don&amp;apos;t want to write the same code in the same callback in each model. So why not make a Timestamp behaviour, which you can then attach to the models which you want to have timestamping. Simples! Examples: Containable, Linkable, Translate, Listable
  10. Extends AppController so there is inheritance. Dad for the day! It deals with both the incoming request object, preparing the response object and dispatching the view. The controller has a single responsibility. So an OrdersController deals with orders. A UsersController deals with Users. Contains public methods called actions, which are your &amp;apos;things which do things&amp;apos;. Such as Add, Edit, View and Delete. Has callbacks allowing you to change data and perform operations at various stages of the controller execution. BeforeFilter, beforeRender and afterFilter()
  11. Components are similar to Behaviours in that they are mixins for your Controllers. If you are writing the same logic in lots of controllers, stop! And think about refactoring the code into a component. Always keep code DRY. Don&amp;apos;t be tempted to put public controller actions into a component! Think more about actual php code that those methods might need and refactor that. Example, Session, Pagination, Security
  12. So our routing has found the controller, the controller has got the data from our model and has set it to the view. The V in MVC. Responsible for generating specific output required for the request. This could be HTML, Xml or Json depending on the request. It might even be a PDF or another file for download. By default, most views are HTML using the .ctp extension (cake template) which is just standard php+html. The framework has automatic Json and Xml views built in which can be used using the RequestHandlerComponent. This makes building API&amp;apos;s super easy as you don&amp;apos;t need to worry about building your api output. Layout file to implement our shared html. Layouts wrap views common markup should be in the layout. Eg, JS &amp; CSS Templates can be extended from each other, so if you want to break up your common view parts into views to inherit from you can do that. The actual view template should have no logic ideally, but you&amp;apos;ll end up with some foreachs in most cases. Refactoring view logic uses helpers which we&amp;apos;ll come onto shortly.
  13. Helpers are the component-like classes for the presentation layer of your application. They contain presentational logic that is shared between many views, elements, or layouts. As helpers are actual classes any complex functionality can be easily wrapped into a helper to prevent adding of logic to templates. Here are some of the core helpers. Form helper deals with generating form fields. The Time helper for example can do &amp;apos;time ago in words&amp;apos; and such. So anything which requires some logic. If you start writing PHP in your views, stop and think about using a helper instead. Helpers are portable. You can reuse them in different projects so it&amp;apos;s always worth making the code and output quite generic so that you can reuse them. For UKWM we have a php prices library for calculating prices, annual, monthly, averages, etc and I have wrapped this into a helper, so that I can, in my view, simply say $this-&amp;gt;Price-&amp;gt;monthly() and get a monthly price.
  14. In 2.x dynamic elements required requestAction() which was bad because it needed caching due to the dispatch cycle. In 3.x this has gone and Cells are in to replace it. Cells have their own controller and view file. They are ideal for reusable page parts which need logic, data and specific rendering. Cells do not dispatch sub-requests making them more efficient than requestAction(). Eg, data driven nav, sidebar with category counts. Elements which are shared static HTML which can be included in any view. This allows you to build a static navigation, sidebar or similar with only one place for the markup. Data can be passed into elements and they can be cached easily. Blocks allow for shared content in memory, but can be appended to from the view. Mostly used to for things like javascript and meta. So you can append javascript to the end of your whole page from the view.
  15. So we have covered off the layers of the Cake. So which bits do you get for free? All this is included! Think of all the things you could build with so many handy tools right at your fingertips! It&amp;apos;s worth mentioning Containable which helps to optimise finds with related data by giving you finer grained control over how those relations are fetched. Hash is another non-obvious utility class which is used to doing operations on arrays using X-Path notation. Such as stripping out all Posts with a certain tag from a set of data. The rest I&amp;apos;m sure you can work out what they do from their names. You&amp;apos;ll notice CakeNumber and CakeTime, these are the library classes which are wrapped into the Number and Time helpers, so you can use the functionality in models or controllers. In 3.x a number of these classes have been changed around, some, like the FlashComponent are due to refactoring elsewhere, in this case the SessionComponent. &amp;lt;Talk a bit about some of the various classes, email, security, etc&amp;gt;
  16. Plugins are essentially a Cake application. They can be linked and executed inside your cake application as if they were application code. A plugin could provide any functionality to your application, from a Users plugin for managing users, with full stack MVC layers, or it might be a single behaviour for attaching to a model. Any Cake elements which you would like to reuse in more than one application, think about refactoring it into a plugin. In most cases plugins generally contain Behaviours, Components and Helpers, as they provide the ability to add extra functionality to existing objects within your application.
  17. Now has full composer support. Updated to have a minimum requirement of php 5.4 The ORM (db layer) has been totally rewritten Routing api has been rewritten More consistent and now simpler to configure, now just one app.php file to setup your application, so less faff with Git and setup in production. Making more use of external libraries such as Carbon, Aura and Password Compat (for php5.4) Will cause the end of life of v1.3 then support will just follow 2.x and 3.x
  18. So you&amp;apos;re convinced right? This is awesome. It&amp;apos;s fast, it&amp;apos;s easy and best of all it does what you want and doesn&amp;apos;t get in your way when you want to do something different. So what is the first step? Where do I start? Got to blog tut slide -&amp;gt;
  19. Everything is on Github. The framework source code, the core developers, most of the plugins, pretty much everything. I&amp;apos;d recommend searching Github for anything you might need as a first port of call. There is also the &amp;apos;Community&amp;apos; menu on the Cake website, which has links to pretty much every community presence for CakePHP across the internet. I&amp;apos;ve included the two main sites here, book and plugins which I use on a daily basis. The Friends of Cake initiative was started by a few of the core team and has since branched out to include some of the community also. I am a member of this team. We have a bunch of useful plugins and tools available. If you would like to use Composer with the 2.x branch, we have that already setup here. We also have CakePHP Vagrant + Puppet boxes setup here if you want to try those. I would also recommend checking the core team members personal profiles on Github. Most of them spend time working on Cake plugins in their spare time and you&amp;apos;ll find that work in their own repos. It&amp;apos;s also worth following so that you can help out with projects that they are working on. The core team are all really nice people and they are usually happy to get feedbacks, ideas and pull requests for things they are working on.If in doubt, ask.
  20. Some recent books written by core developers on the framework if you prefer paper learning.