SlideShare une entreprise Scribd logo
1  sur  44
Télécharger pour lire hors ligne
New in CakePHP 3
March 22, 2015
3.0.0 is released
Frequent Releases
Bugfixes every 2-4 weeks
PHP 5.4 +
Soon to be PHP 5.5+
All the PSRs
Zero through Four
Clean up
Rabid conventions removed.
Standalone
Components
We have a few.
I18n
// Message formatting
echo __("Hello, my name is {0}, I'm {1} years old",
['Sara', 12]);
>>> Hello, my name is Sara, I’m 12 years old
// Decimals and integers
echo __('You have traveled {0,number,decimal}
kilometers in {1,number,integer} weeks',
[5423.344, 5.1]);
>>> You have traveled 5,423.34 kilometers in 5 weeks
Messages
echo __('{0,plural,
=0{No records found}
=1{Found 1 record}
other{Found # records}}',
[1]);
>>> Found 1 record
// Simpler message ids.
echo __('records.found', [1]);
>>> Found 1 record
Plurals
msgid "One file removed"
msgid_plural "{0} files removed"
msgstr[0] "jednom datotekom je uklonjen"
msgstr[1] "{0} datoteke uklonjenih"
msgstr[2] "{0} slika uklonjenih"
Catalog Files
use CakeI18nTime;
use CakeI18nNumber;
$date = new Time('2015-04-05 23:00:00');
echo $date;
>>> 05/04/2015 23:00
echo Number::format(524.23);
>>> 524.23
Numbers & Dates
Locale::setDefault(‘fr-FR’);
$date = new Time('2015-04-05 23:00:00');
echo $date;
>>> 5 avril 2015 23:00:00 UTC
echo Number::format(524.23);
>>> 524,23
Numbers & Dates
Use Alone
Use the i18n libs anywhere with composer.
Routing
Router::scope(‘/u‘, function ($routes) {
$routes->connect(‘/name/:username’, [‘controller’ => ‘Users’, ’action’ => ‘show’]);
});
// Use namespace prefixed controllers.
Router::prefix(‘admin’, function ($routes) {
$routes->connect(‘/articles/:action’, [‘controller’ => ‘Articles’]);
});
Routing Scopes
// Classic array format.
echo $this->Url->build([
‘controller’ => ‘Users’,
‘action’ => ‘show’,
‘username’ => ‘thewoz’
]);
>>> /u/name/thewoz
echo $this->Url->build([
‘prefix’ => ‘Admin’,
‘controller’ => ‘Articles’,
‘action’ => ‘index’
]);
>>> /admin/articles/index
Reverse Routing
Router::scope(‘/u‘, function ($routes) {
// Explicit name
$routes->connect(‘/friends’, [‘controller’ => ‘Friends’], [‘_name’ => ‘u:friends’]);
});
echo $this->Url->build([‘_name’ => ‘u:friends’]);
>>> /u/friends
Named Routes
Router::scope('/', function ($routes) {
$routes->extensions(['json']);
$routes->resources('Articles');
});
>>> /articles and /articles/:id are now connected.
// Generate nested resources
Router::scope('/', function ($routes) {
$routes->extensions([‘json’]);
$routes->resources('Articles', function ($routes) {
$routes->resources('Comments');
});
});
>>> /articles/:article_id/comments is now connected.
Resource Routing
Collections
Jose Lorenzo
Rodriguez
Iterator Master
Immutable
Mutator methods make new collections.
$items = ['a' => 1, 'b' => 2, 'c' => 3];
$collection = new Collection($items);
// Create a new collection containing elements
// with a value greater than one.
$big = $collection->filter(function ($value, $key, $iterator) {
return $value > 1;
});
// Search data in memory. match() makes a new iterator
$collection = new Collection($comments);
$commentsFromMark = $collection->match(['user.name' => 'Mark']);
Improved Arrays
$people = new Collection($peopleData);
// Find all the non-blondes
$notBlond = $people->reject(function ($p) {
return $p->hair_colour === ‘blond’;
});
// Get all the people named jose
$joses = $notBlond->filter(function ($p) {
return strtolower($p->first_name) === ‘jose’;
});
// Count by their hair colour
$counts = $joses->countBy(function ($p) {
return $p->hair_colour;
});
Pipeline Example
class JoseFinder {
public function __invoke($person) {
return strtolower($person->first_name) === ‘jose’;
}
}
$joses = $people->filter(new JoseFinder());
$notBlond = $people->reject(new NotBlondFilter());
Pipeline ++
Use Alone
Collections can be used in any project.
ORM
It is not 2005
anymore
ActiveRecord Datamapper
// Get a table gateway/mapper.
$connection = ConnectionManager::get(‘default’);
$articles = new ArticlesTable([‘connection’ => $connection]);
// Basic query building
$query = $articles->find()
->where([‘Articles.author_id’ => $userid])
->order([‘Articles.created’ => ‘DESC’]);
// Find some published, promoted articles
$query = $articles->find(‘promoted’)
->find(‘published’);
Finding Records
// Find articles and eager load relations (1 query)
$query = $articles->find()
->contain([‘Authors’, ‘Categories’]);
// Load deeply nested relations (2 queries)
$query = $articles->find()
->contain([‘Authors.RecentActivities’]);
Eager Loading
// Find all the articles tagged with ‘Cat’
$query = $articles->find()->matching(‘Tags’, function ($q) {
return $q->where([‘Tags.name’ => ‘Cat’]);
});
// Find all the articles without the tag ‘Cat’
$query = $articles->find()->notMatching(‘Tags’, function ($q) {
return $q->where([‘Tags.name’ => ‘Cat’]);
});
Matching
// Do extraction and transformations
$result = $articles->find()
->all()
->extract(‘title’)
->map(function ($item) { return strtoupper($item); });
// Extract and reduce
$query = $articles->find()->contain([‘Tags’]);
$uniqueTags = $articles->all()
->extract(‘tags.{*}.name’)
->reduce(function ($out, $tag) {
if (!in_array($tag, $out) {
$out[] = $tag;
}
return $out;
}, []);
Collections+
Entities
Just vanilla PHP objects for the most part.
namespace AppModelEntity;
use CakeORMEntity;
class Article extends Entity
{
protected $_accessible = [‘title’, ‘body’, ‘author_id’];
}
Article Entity
namespace AppModelEntity;
use CakeORMEntity;
class User extends Entity
{
protected function _getFullName()
{
return $this->_properties['first_name'] . ' ' .
$this->_properties['last_name'];
}
}
echo $user->full_name;
Virtual Fields
Inspired By
SQLAlchemy
The best ORM I’ve ever used.
No Proxies,
No Annotations,
No Identity Map,
No Runtime Reflection
No Lazy Loading
Use alone
Use the ORM anywhere with composer.
What’s Next?
What’s Next
• New DateTime library, replacing Carbon
• Polymorphic Associations
• PSR7 Support
• Value Objects
Thank You.
https://joind.in/14774
Twitter - mark_story
Github - markstory

Contenu connexe

Tendances

Dependency Injection IPC 201
Dependency Injection IPC 201Dependency Injection IPC 201
Dependency Injection IPC 201Fabien Potencier
 
PHP Data Objects
PHP Data ObjectsPHP Data Objects
PHP Data ObjectsWez Furlong
 
Tips of CakePHP and MongoDB - Cakefest2011 ichikaway
Tips of CakePHP and MongoDB - Cakefest2011 ichikaway Tips of CakePHP and MongoDB - Cakefest2011 ichikaway
Tips of CakePHP and MongoDB - Cakefest2011 ichikaway ichikaway
 
Internationalizing CakePHP Applications
Internationalizing CakePHP ApplicationsInternationalizing CakePHP Applications
Internationalizing CakePHP ApplicationsPierre MARTIN
 
Building Lithium Apps
Building Lithium AppsBuilding Lithium Apps
Building Lithium AppsNate Abele
 
PHP 5.3 and Lithium: the most rad php framework
PHP 5.3 and Lithium: the most rad php frameworkPHP 5.3 and Lithium: the most rad php framework
PHP 5.3 and Lithium: the most rad php frameworkG Woo
 
The State of Lithium
The State of LithiumThe State of Lithium
The State of LithiumNate Abele
 
News of the Symfony2 World
News of the Symfony2 WorldNews of the Symfony2 World
News of the Symfony2 WorldFabien Potencier
 
Lithium: The Framework for People Who Hate Frameworks, Tokyo Edition
Lithium: The Framework for People Who Hate Frameworks, Tokyo EditionLithium: The Framework for People Who Hate Frameworks, Tokyo Edition
Lithium: The Framework for People Who Hate Frameworks, Tokyo EditionNate Abele
 
Introducing CakeEntity
Introducing CakeEntityIntroducing CakeEntity
Introducing CakeEntityBasuke Suzuki
 
Introducing CakeEntity
Introducing CakeEntityIntroducing CakeEntity
Introducing CakeEntityBasuke Suzuki
 
Dependency Injection
Dependency InjectionDependency Injection
Dependency InjectionRifat Nabi
 
Unit and Functional Testing with Symfony2
Unit and Functional Testing with Symfony2Unit and Functional Testing with Symfony2
Unit and Functional Testing with Symfony2Fabien Potencier
 
Php unit the-mostunknownparts
Php unit the-mostunknownpartsPhp unit the-mostunknownparts
Php unit the-mostunknownpartsBastian Feder
 
Corephpcomponentpresentation 1211425966721657-8
Corephpcomponentpresentation 1211425966721657-8Corephpcomponentpresentation 1211425966721657-8
Corephpcomponentpresentation 1211425966721657-8PrinceGuru MS
 
international PHP2011_Bastian Feder_jQuery's Secrets
international PHP2011_Bastian Feder_jQuery's Secretsinternational PHP2011_Bastian Feder_jQuery's Secrets
international PHP2011_Bastian Feder_jQuery's Secretssmueller_sandsmedia
 
Doctrine MongoDB ODM (PDXPHP)
Doctrine MongoDB ODM (PDXPHP)Doctrine MongoDB ODM (PDXPHP)
Doctrine MongoDB ODM (PDXPHP)Kris Wallsmith
 

Tendances (20)

Dependency Injection IPC 201
Dependency Injection IPC 201Dependency Injection IPC 201
Dependency Injection IPC 201
 
PHP Data Objects
PHP Data ObjectsPHP Data Objects
PHP Data Objects
 
Tips of CakePHP and MongoDB - Cakefest2011 ichikaway
Tips of CakePHP and MongoDB - Cakefest2011 ichikaway Tips of CakePHP and MongoDB - Cakefest2011 ichikaway
Tips of CakePHP and MongoDB - Cakefest2011 ichikaway
 
Internationalizing CakePHP Applications
Internationalizing CakePHP ApplicationsInternationalizing CakePHP Applications
Internationalizing CakePHP Applications
 
Building Lithium Apps
Building Lithium AppsBuilding Lithium Apps
Building Lithium Apps
 
PHP 5.3 and Lithium: the most rad php framework
PHP 5.3 and Lithium: the most rad php frameworkPHP 5.3 and Lithium: the most rad php framework
PHP 5.3 and Lithium: the most rad php framework
 
The State of Lithium
The State of LithiumThe State of Lithium
The State of Lithium
 
News of the Symfony2 World
News of the Symfony2 WorldNews of the Symfony2 World
News of the Symfony2 World
 
Lithium: The Framework for People Who Hate Frameworks, Tokyo Edition
Lithium: The Framework for People Who Hate Frameworks, Tokyo EditionLithium: The Framework for People Who Hate Frameworks, Tokyo Edition
Lithium: The Framework for People Who Hate Frameworks, Tokyo Edition
 
Quebec pdo
Quebec pdoQuebec pdo
Quebec pdo
 
Introducing CakeEntity
Introducing CakeEntityIntroducing CakeEntity
Introducing CakeEntity
 
Symfony2 - WebExpo 2010
Symfony2 - WebExpo 2010Symfony2 - WebExpo 2010
Symfony2 - WebExpo 2010
 
Introducing CakeEntity
Introducing CakeEntityIntroducing CakeEntity
Introducing CakeEntity
 
Dependency Injection
Dependency InjectionDependency Injection
Dependency Injection
 
Unit and Functional Testing with Symfony2
Unit and Functional Testing with Symfony2Unit and Functional Testing with Symfony2
Unit and Functional Testing with Symfony2
 
Php unit the-mostunknownparts
Php unit the-mostunknownpartsPhp unit the-mostunknownparts
Php unit the-mostunknownparts
 
Corephpcomponentpresentation 1211425966721657-8
Corephpcomponentpresentation 1211425966721657-8Corephpcomponentpresentation 1211425966721657-8
Corephpcomponentpresentation 1211425966721657-8
 
Lithium Best
Lithium Best Lithium Best
Lithium Best
 
international PHP2011_Bastian Feder_jQuery's Secrets
international PHP2011_Bastian Feder_jQuery's Secretsinternational PHP2011_Bastian Feder_jQuery's Secrets
international PHP2011_Bastian Feder_jQuery's Secrets
 
Doctrine MongoDB ODM (PDXPHP)
Doctrine MongoDB ODM (PDXPHP)Doctrine MongoDB ODM (PDXPHP)
Doctrine MongoDB ODM (PDXPHP)
 

Similaire à New in cakephp3

Aura Project for PHP
Aura Project for PHPAura Project for PHP
Aura Project for PHPHari K T
 
[WLDN] Supercharging word press development in 2018
[WLDN] Supercharging word press development in 2018[WLDN] Supercharging word press development in 2018
[WLDN] Supercharging word press development in 2018Adam Tomat
 
Resource Routing in ExpressionEngine
Resource Routing in ExpressionEngineResource Routing in ExpressionEngine
Resource Routing in ExpressionEngineMichaelRog
 
Rails 3 overview
Rails 3 overviewRails 3 overview
Rails 3 overviewYehuda Katz
 
Rails 3: Dashing to the Finish
Rails 3: Dashing to the FinishRails 3: Dashing to the Finish
Rails 3: Dashing to the FinishYehuda Katz
 
Why Hacking WordPress Search Isn't Some Big Scary Thing
Why Hacking WordPress Search Isn't Some Big Scary ThingWhy Hacking WordPress Search Isn't Some Big Scary Thing
Why Hacking WordPress Search Isn't Some Big Scary ThingChris Reynolds
 
Doctrine For Beginners
Doctrine For BeginnersDoctrine For Beginners
Doctrine For BeginnersJonathan Wage
 
Advanced symfony Techniques
Advanced symfony TechniquesAdvanced symfony Techniques
Advanced symfony TechniquesKris Wallsmith
 
Workshop quality assurance for php projects - phpbelfast
Workshop quality assurance for php projects - phpbelfastWorkshop quality assurance for php projects - phpbelfast
Workshop quality assurance for php projects - phpbelfastMichelangelo van Dam
 
Workshop quality assurance for php projects - ZendCon 2013
Workshop quality assurance for php projects - ZendCon 2013Workshop quality assurance for php projects - ZendCon 2013
Workshop quality assurance for php projects - ZendCon 2013Michelangelo van Dam
 
What's new in the Drupal 7 API?
What's new in the Drupal 7 API?What's new in the Drupal 7 API?
What's new in the Drupal 7 API?Alexandru Badiu
 
SPL: The Missing Link in Development
SPL: The Missing Link in DevelopmentSPL: The Missing Link in Development
SPL: The Missing Link in Developmentjsmith92
 
WordPress for developers - phpday 2011
WordPress for developers -  phpday 2011WordPress for developers -  phpday 2011
WordPress for developers - phpday 2011Maurizio Pelizzone
 
20 modules i haven't yet talked about
20 modules i haven't yet talked about20 modules i haven't yet talked about
20 modules i haven't yet talked aboutTatsuhiko Miyagawa
 
You code sucks, let's fix it
You code sucks, let's fix itYou code sucks, let's fix it
You code sucks, let's fix itRafael Dohms
 

Similaire à New in cakephp3 (20)

Aura Project for PHP
Aura Project for PHPAura Project for PHP
Aura Project for PHP
 
[WLDN] Supercharging word press development in 2018
[WLDN] Supercharging word press development in 2018[WLDN] Supercharging word press development in 2018
[WLDN] Supercharging word press development in 2018
 
Resource Routing in ExpressionEngine
Resource Routing in ExpressionEngineResource Routing in ExpressionEngine
Resource Routing in ExpressionEngine
 
Rails 3 overview
Rails 3 overviewRails 3 overview
Rails 3 overview
 
Rails 3: Dashing to the Finish
Rails 3: Dashing to the FinishRails 3: Dashing to the Finish
Rails 3: Dashing to the Finish
 
Add loop shortcode
Add loop shortcodeAdd loop shortcode
Add loop shortcode
 
Why Hacking WordPress Search Isn't Some Big Scary Thing
Why Hacking WordPress Search Isn't Some Big Scary ThingWhy Hacking WordPress Search Isn't Some Big Scary Thing
Why Hacking WordPress Search Isn't Some Big Scary Thing
 
Doctrine For Beginners
Doctrine For BeginnersDoctrine For Beginners
Doctrine For Beginners
 
Advanced symfony Techniques
Advanced symfony TechniquesAdvanced symfony Techniques
Advanced symfony Techniques
 
Workshop quality assurance for php projects - phpbelfast
Workshop quality assurance for php projects - phpbelfastWorkshop quality assurance for php projects - phpbelfast
Workshop quality assurance for php projects - phpbelfast
 
Separation of concerns - DPC12
Separation of concerns - DPC12Separation of concerns - DPC12
Separation of concerns - DPC12
 
Workshop quality assurance for php projects - ZendCon 2013
Workshop quality assurance for php projects - ZendCon 2013Workshop quality assurance for php projects - ZendCon 2013
Workshop quality assurance for php projects - ZendCon 2013
 
Laravel 101
Laravel 101Laravel 101
Laravel 101
 
What's new in the Drupal 7 API?
What's new in the Drupal 7 API?What's new in the Drupal 7 API?
What's new in the Drupal 7 API?
 
SPL: The Missing Link in Development
SPL: The Missing Link in DevelopmentSPL: The Missing Link in Development
SPL: The Missing Link in Development
 
WordPress for developers - phpday 2011
WordPress for developers -  phpday 2011WordPress for developers -  phpday 2011
WordPress for developers - phpday 2011
 
PHP API
PHP APIPHP API
PHP API
 
Intermediate PHP
Intermediate PHPIntermediate PHP
Intermediate PHP
 
20 modules i haven't yet talked about
20 modules i haven't yet talked about20 modules i haven't yet talked about
20 modules i haven't yet talked about
 
You code sucks, let's fix it
You code sucks, let's fix itYou code sucks, let's fix it
You code sucks, let's fix it
 

Plus de markstory

Dependency injection in CakePHP
Dependency injection in CakePHPDependency injection in CakePHP
Dependency injection in CakePHPmarkstory
 
Safer, More Helpful CakePHP
Safer, More Helpful CakePHPSafer, More Helpful CakePHP
Safer, More Helpful CakePHPmarkstory
 
CakePHP - The Road Ahead
CakePHP - The Road AheadCakePHP - The Road Ahead
CakePHP - The Road Aheadmarkstory
 
CakePHP mistakes made 2015
CakePHP mistakes made 2015CakePHP mistakes made 2015
CakePHP mistakes made 2015markstory
 
CakePHP 3.0 and beyond
CakePHP 3.0 and beyondCakePHP 3.0 and beyond
CakePHP 3.0 and beyondmarkstory
 
CakePHP mistakes made confoo 2015
CakePHP mistakes made confoo 2015CakePHP mistakes made confoo 2015
CakePHP mistakes made confoo 2015markstory
 
CakePHP mistakes made
CakePHP mistakes madeCakePHP mistakes made
CakePHP mistakes mademarkstory
 
Performance and optimization CakeFest 2014
Performance and optimization CakeFest 2014Performance and optimization CakeFest 2014
Performance and optimization CakeFest 2014markstory
 
Road to CakePHP 3.0
Road to CakePHP 3.0Road to CakePHP 3.0
Road to CakePHP 3.0markstory
 
Performance and optimization
Performance and optimizationPerformance and optimization
Performance and optimizationmarkstory
 
OWASP Top 10 2013
OWASP Top 10 2013OWASP Top 10 2013
OWASP Top 10 2013markstory
 
CakePHP the yum & yuck
CakePHP the yum & yuckCakePHP the yum & yuck
CakePHP the yum & yuckmarkstory
 
Introduction to Twig
Introduction to TwigIntroduction to Twig
Introduction to Twigmarkstory
 
Owasp top 10
Owasp top 10Owasp top 10
Owasp top 10markstory
 
Simple search with elastic search
Simple search with elastic searchSimple search with elastic search
Simple search with elastic searchmarkstory
 
Making the most of 2.2
Making the most of 2.2Making the most of 2.2
Making the most of 2.2markstory
 
Intro to continuous integration
Intro to continuous integration Intro to continuous integration
Intro to continuous integration markstory
 
Evented applications with RabbitMQ and CakePHP
Evented applications with RabbitMQ and CakePHPEvented applications with RabbitMQ and CakePHP
Evented applications with RabbitMQ and CakePHPmarkstory
 
Ch ch-changes cake php2
Ch ch-changes cake php2Ch ch-changes cake php2
Ch ch-changes cake php2markstory
 

Plus de markstory (20)

Dependency injection in CakePHP
Dependency injection in CakePHPDependency injection in CakePHP
Dependency injection in CakePHP
 
Safer, More Helpful CakePHP
Safer, More Helpful CakePHPSafer, More Helpful CakePHP
Safer, More Helpful CakePHP
 
CakePHP - The Road Ahead
CakePHP - The Road AheadCakePHP - The Road Ahead
CakePHP - The Road Ahead
 
CakePHP mistakes made 2015
CakePHP mistakes made 2015CakePHP mistakes made 2015
CakePHP mistakes made 2015
 
PHP WTF
PHP WTFPHP WTF
PHP WTF
 
CakePHP 3.0 and beyond
CakePHP 3.0 and beyondCakePHP 3.0 and beyond
CakePHP 3.0 and beyond
 
CakePHP mistakes made confoo 2015
CakePHP mistakes made confoo 2015CakePHP mistakes made confoo 2015
CakePHP mistakes made confoo 2015
 
CakePHP mistakes made
CakePHP mistakes madeCakePHP mistakes made
CakePHP mistakes made
 
Performance and optimization CakeFest 2014
Performance and optimization CakeFest 2014Performance and optimization CakeFest 2014
Performance and optimization CakeFest 2014
 
Road to CakePHP 3.0
Road to CakePHP 3.0Road to CakePHP 3.0
Road to CakePHP 3.0
 
Performance and optimization
Performance and optimizationPerformance and optimization
Performance and optimization
 
OWASP Top 10 2013
OWASP Top 10 2013OWASP Top 10 2013
OWASP Top 10 2013
 
CakePHP the yum & yuck
CakePHP the yum & yuckCakePHP the yum & yuck
CakePHP the yum & yuck
 
Introduction to Twig
Introduction to TwigIntroduction to Twig
Introduction to Twig
 
Owasp top 10
Owasp top 10Owasp top 10
Owasp top 10
 
Simple search with elastic search
Simple search with elastic searchSimple search with elastic search
Simple search with elastic search
 
Making the most of 2.2
Making the most of 2.2Making the most of 2.2
Making the most of 2.2
 
Intro to continuous integration
Intro to continuous integration Intro to continuous integration
Intro to continuous integration
 
Evented applications with RabbitMQ and CakePHP
Evented applications with RabbitMQ and CakePHPEvented applications with RabbitMQ and CakePHP
Evented applications with RabbitMQ and CakePHP
 
Ch ch-changes cake php2
Ch ch-changes cake php2Ch ch-changes cake php2
Ch ch-changes cake php2
 

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
 
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
 
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full Recording
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full RecordingOpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full Recording
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full RecordingShane Coughlan
 
Introduction to Firebase Workshop Slides
Introduction to Firebase Workshop SlidesIntroduction to Firebase Workshop Slides
Introduction to Firebase Workshop Slidesvaideheekore1
 
Enhancing Supply Chain Visibility with Cargo Cloud Solutions.pdf
Enhancing Supply Chain Visibility with Cargo Cloud Solutions.pdfEnhancing Supply Chain Visibility with Cargo Cloud Solutions.pdf
Enhancing Supply Chain Visibility with Cargo Cloud Solutions.pdfRTS corp
 
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
 
Strategies for using alternative queries to mitigate zero results
Strategies for using alternative queries to mitigate zero resultsStrategies for using alternative queries to mitigate zero results
Strategies for using alternative queries to mitigate zero resultsJean Silva
 
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
 
Effectively Troubleshoot 9 Types of OutOfMemoryError
Effectively Troubleshoot 9 Types of OutOfMemoryErrorEffectively Troubleshoot 9 Types of OutOfMemoryError
Effectively Troubleshoot 9 Types of OutOfMemoryErrorTier1 app
 
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
 
Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...
Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...
Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...OnePlan Solutions
 
Best Angular 17 Classroom & Online training - Naresh IT
Best Angular 17 Classroom & Online training - Naresh ITBest Angular 17 Classroom & Online training - Naresh IT
Best Angular 17 Classroom & Online training - Naresh ITmanoharjgpsolutions
 
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
 
Ronisha Informatics Private Limited Catalogue
Ronisha Informatics Private Limited CatalogueRonisha Informatics Private Limited Catalogue
Ronisha Informatics Private Limited Catalogueitservices996
 
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
 
Zer0con 2024 final share short version.pdf
Zer0con 2024 final share short version.pdfZer0con 2024 final share short version.pdf
Zer0con 2024 final share short version.pdfmaor17
 
Leveraging AI for Mobile App Testing on Real Devices | Applitools + Kobiton
Leveraging AI for Mobile App Testing on Real Devices | Applitools + KobitonLeveraging AI for Mobile App Testing on Real Devices | Applitools + Kobiton
Leveraging AI for Mobile App Testing on Real Devices | Applitools + KobitonApplitools
 
[ CNCF Q1 2024 ] Intro to Continuous Profiling and Grafana Pyroscope.pdf
[ CNCF Q1 2024 ] Intro to Continuous Profiling and Grafana Pyroscope.pdf[ CNCF Q1 2024 ] Intro to Continuous Profiling and Grafana Pyroscope.pdf
[ CNCF Q1 2024 ] Intro to Continuous Profiling and Grafana Pyroscope.pdfSteve Caron
 
Mastering Project Planning with Microsoft Project 2016.pptx
Mastering Project Planning with Microsoft Project 2016.pptxMastering Project Planning with Microsoft Project 2016.pptx
Mastering Project Planning with Microsoft Project 2016.pptxAS Design & AST.
 
The Ultimate Guide to Performance Testing in Low-Code, No-Code Environments (...
The Ultimate Guide to Performance Testing in Low-Code, No-Code Environments (...The Ultimate Guide to Performance Testing in Low-Code, No-Code Environments (...
The Ultimate Guide to Performance Testing in Low-Code, No-Code Environments (...kalichargn70th171
 

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
 
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...
 
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full Recording
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full RecordingOpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full Recording
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full Recording
 
Introduction to Firebase Workshop Slides
Introduction to Firebase Workshop SlidesIntroduction to Firebase Workshop Slides
Introduction to Firebase Workshop Slides
 
Enhancing Supply Chain Visibility with Cargo Cloud Solutions.pdf
Enhancing Supply Chain Visibility with Cargo Cloud Solutions.pdfEnhancing Supply Chain Visibility with Cargo Cloud Solutions.pdf
Enhancing Supply Chain Visibility with Cargo Cloud Solutions.pdf
 
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...
 
Strategies for using alternative queries to mitigate zero results
Strategies for using alternative queries to mitigate zero resultsStrategies for using alternative queries to mitigate zero results
Strategies for using alternative queries to mitigate zero results
 
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
 
Effectively Troubleshoot 9 Types of OutOfMemoryError
Effectively Troubleshoot 9 Types of OutOfMemoryErrorEffectively Troubleshoot 9 Types of OutOfMemoryError
Effectively Troubleshoot 9 Types of OutOfMemoryError
 
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
 
Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...
Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...
Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...
 
Best Angular 17 Classroom & Online training - Naresh IT
Best Angular 17 Classroom & Online training - Naresh ITBest Angular 17 Classroom & Online training - Naresh IT
Best Angular 17 Classroom & Online training - Naresh IT
 
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
 
Ronisha Informatics Private Limited Catalogue
Ronisha Informatics Private Limited CatalogueRonisha Informatics Private Limited Catalogue
Ronisha Informatics Private Limited Catalogue
 
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 ?
 
Zer0con 2024 final share short version.pdf
Zer0con 2024 final share short version.pdfZer0con 2024 final share short version.pdf
Zer0con 2024 final share short version.pdf
 
Leveraging AI for Mobile App Testing on Real Devices | Applitools + Kobiton
Leveraging AI for Mobile App Testing on Real Devices | Applitools + KobitonLeveraging AI for Mobile App Testing on Real Devices | Applitools + Kobiton
Leveraging AI for Mobile App Testing on Real Devices | Applitools + Kobiton
 
[ CNCF Q1 2024 ] Intro to Continuous Profiling and Grafana Pyroscope.pdf
[ CNCF Q1 2024 ] Intro to Continuous Profiling and Grafana Pyroscope.pdf[ CNCF Q1 2024 ] Intro to Continuous Profiling and Grafana Pyroscope.pdf
[ CNCF Q1 2024 ] Intro to Continuous Profiling and Grafana Pyroscope.pdf
 
Mastering Project Planning with Microsoft Project 2016.pptx
Mastering Project Planning with Microsoft Project 2016.pptxMastering Project Planning with Microsoft Project 2016.pptx
Mastering Project Planning with Microsoft Project 2016.pptx
 
The Ultimate Guide to Performance Testing in Low-Code, No-Code Environments (...
The Ultimate Guide to Performance Testing in Low-Code, No-Code Environments (...The Ultimate Guide to Performance Testing in Low-Code, No-Code Environments (...
The Ultimate Guide to Performance Testing in Low-Code, No-Code Environments (...
 

New in cakephp3

  • 2.
  • 3. March 22, 2015 3.0.0 is released
  • 5. PHP 5.4 + Soon to be PHP 5.5+
  • 6. All the PSRs Zero through Four
  • 10. // Message formatting echo __("Hello, my name is {0}, I'm {1} years old", ['Sara', 12]); >>> Hello, my name is Sara, I’m 12 years old // Decimals and integers echo __('You have traveled {0,number,decimal} kilometers in {1,number,integer} weeks', [5423.344, 5.1]); >>> You have traveled 5,423.34 kilometers in 5 weeks Messages
  • 11. echo __('{0,plural, =0{No records found} =1{Found 1 record} other{Found # records}}', [1]); >>> Found 1 record // Simpler message ids. echo __('records.found', [1]); >>> Found 1 record Plurals
  • 12. msgid "One file removed" msgid_plural "{0} files removed" msgstr[0] "jednom datotekom je uklonjen" msgstr[1] "{0} datoteke uklonjenih" msgstr[2] "{0} slika uklonjenih" Catalog Files
  • 13. use CakeI18nTime; use CakeI18nNumber; $date = new Time('2015-04-05 23:00:00'); echo $date; >>> 05/04/2015 23:00 echo Number::format(524.23); >>> 524.23 Numbers & Dates
  • 14. Locale::setDefault(‘fr-FR’); $date = new Time('2015-04-05 23:00:00'); echo $date; >>> 5 avril 2015 23:00:00 UTC echo Number::format(524.23); >>> 524,23 Numbers & Dates
  • 15. Use Alone Use the i18n libs anywhere with composer.
  • 17. Router::scope(‘/u‘, function ($routes) { $routes->connect(‘/name/:username’, [‘controller’ => ‘Users’, ’action’ => ‘show’]); }); // Use namespace prefixed controllers. Router::prefix(‘admin’, function ($routes) { $routes->connect(‘/articles/:action’, [‘controller’ => ‘Articles’]); }); Routing Scopes
  • 18. // Classic array format. echo $this->Url->build([ ‘controller’ => ‘Users’, ‘action’ => ‘show’, ‘username’ => ‘thewoz’ ]); >>> /u/name/thewoz echo $this->Url->build([ ‘prefix’ => ‘Admin’, ‘controller’ => ‘Articles’, ‘action’ => ‘index’ ]); >>> /admin/articles/index Reverse Routing
  • 19. Router::scope(‘/u‘, function ($routes) { // Explicit name $routes->connect(‘/friends’, [‘controller’ => ‘Friends’], [‘_name’ => ‘u:friends’]); }); echo $this->Url->build([‘_name’ => ‘u:friends’]); >>> /u/friends Named Routes
  • 20. Router::scope('/', function ($routes) { $routes->extensions(['json']); $routes->resources('Articles'); }); >>> /articles and /articles/:id are now connected. // Generate nested resources Router::scope('/', function ($routes) { $routes->extensions([‘json’]); $routes->resources('Articles', function ($routes) { $routes->resources('Comments'); }); }); >>> /articles/:article_id/comments is now connected. Resource Routing
  • 23. Immutable Mutator methods make new collections.
  • 24. $items = ['a' => 1, 'b' => 2, 'c' => 3]; $collection = new Collection($items); // Create a new collection containing elements // with a value greater than one. $big = $collection->filter(function ($value, $key, $iterator) { return $value > 1; }); // Search data in memory. match() makes a new iterator $collection = new Collection($comments); $commentsFromMark = $collection->match(['user.name' => 'Mark']); Improved Arrays
  • 25. $people = new Collection($peopleData); // Find all the non-blondes $notBlond = $people->reject(function ($p) { return $p->hair_colour === ‘blond’; }); // Get all the people named jose $joses = $notBlond->filter(function ($p) { return strtolower($p->first_name) === ‘jose’; }); // Count by their hair colour $counts = $joses->countBy(function ($p) { return $p->hair_colour; }); Pipeline Example
  • 26. class JoseFinder { public function __invoke($person) { return strtolower($person->first_name) === ‘jose’; } } $joses = $people->filter(new JoseFinder()); $notBlond = $people->reject(new NotBlondFilter()); Pipeline ++
  • 27. Use Alone Collections can be used in any project.
  • 28. ORM
  • 29. It is not 2005 anymore
  • 31. // Get a table gateway/mapper. $connection = ConnectionManager::get(‘default’); $articles = new ArticlesTable([‘connection’ => $connection]); // Basic query building $query = $articles->find() ->where([‘Articles.author_id’ => $userid]) ->order([‘Articles.created’ => ‘DESC’]); // Find some published, promoted articles $query = $articles->find(‘promoted’) ->find(‘published’); Finding Records
  • 32. // Find articles and eager load relations (1 query) $query = $articles->find() ->contain([‘Authors’, ‘Categories’]); // Load deeply nested relations (2 queries) $query = $articles->find() ->contain([‘Authors.RecentActivities’]); Eager Loading
  • 33. // Find all the articles tagged with ‘Cat’ $query = $articles->find()->matching(‘Tags’, function ($q) { return $q->where([‘Tags.name’ => ‘Cat’]); }); // Find all the articles without the tag ‘Cat’ $query = $articles->find()->notMatching(‘Tags’, function ($q) { return $q->where([‘Tags.name’ => ‘Cat’]); }); Matching
  • 34. // Do extraction and transformations $result = $articles->find() ->all() ->extract(‘title’) ->map(function ($item) { return strtoupper($item); }); // Extract and reduce $query = $articles->find()->contain([‘Tags’]); $uniqueTags = $articles->all() ->extract(‘tags.{*}.name’) ->reduce(function ($out, $tag) { if (!in_array($tag, $out) { $out[] = $tag; } return $out; }, []); Collections+
  • 35. Entities Just vanilla PHP objects for the most part.
  • 36. namespace AppModelEntity; use CakeORMEntity; class Article extends Entity { protected $_accessible = [‘title’, ‘body’, ‘author_id’]; } Article Entity
  • 37. namespace AppModelEntity; use CakeORMEntity; class User extends Entity { protected function _getFullName() { return $this->_properties['first_name'] . ' ' . $this->_properties['last_name']; } } echo $user->full_name; Virtual Fields
  • 38. Inspired By SQLAlchemy The best ORM I’ve ever used.
  • 39. No Proxies, No Annotations, No Identity Map, No Runtime Reflection
  • 41. Use alone Use the ORM anywhere with composer.
  • 43. What’s Next • New DateTime library, replacing Carbon • Polymorphic Associations • PSR7 Support • Value Objects
  • 44. Thank You. https://joind.in/14774 Twitter - mark_story Github - markstory