SlideShare a Scribd company logo
Top ten of php 7.4
Andrea Giannantonio
Team Leader in Immobiliare.it
@JellyBellyDev
RELEASE DATE PHP 7.4
•Alpha1 - 13 Jun 2019
•Beta1 - 25 Jul 2019
•RC1 - 5 Sep 2019
•RC2 - 19 Sep 2019
•RC3 - 03 Oct 2019
•RC4 - 18 Oct 2019
•RC5 - 31 Oct 2019
•RC6 - 14 Nov 2019
•7.4.0 - 28 Nov 2019 (GA)
•7.4.1 - 18 Dec 2019 (GA)
•7.4.2 - 23 Jan 2020 (GA)
TOP TEN
•Typed Properties
•Arrow Functions
•Null Coalescing Assignment Operator
•Spread Operator in Array
•Foreign Function Interface
•Weak References
•Covariant Returns and Contravariant Parameters
•Preloading
•Deprecate left-associative ternary operator
•Performance of PHP 7.4
ONE
Typed Properties
PARAM AND RETURN TYPES: PHP 7.1
Allowed: bool, int, float, string, array, object,
iterable, self, parent, any class or interface
name, and nullable types (?type)
Not Allowed: void and callable
TYPED PROPERTIES: PHP 7.4
TYPED PROPERTIES: NULL
TYPED PROPERTIES: STRICT_TYPES OFF
TYPED PROPERTIES: INVARIANT
Property types (public and protected) are invariant
TWO
Arrow Functions
ARROW FUNCTIONS
ARROW FUNCTIONS
ARROW FUNCTIONS
Syntax: fn(parameter_list) => expr
Note: fn is a reserved word in PHP 7.4
THREE
Spread Operator in Array
SPREAD OPERATOR
Note that this only works with arrays with numerical keys.
SPREAD OPERATOR
It also works on Traversable objects
FOUR
Null Coalescing Assignment Operator
NULL COALESCING ASSIGNMENT OPERATOR
Note that, while the coalesce operator `??` is a comparison operator, `??=` is an assignment operator.
FIVE
Foreign Function Interface
FOREIGN FUNCTION INTERFACE
•Enables the execution of C code directly from PHP
•Provides a FFI class to manage the bridge between C and PHP
•A C function can be executed as a PHP method of FFI class
•php.ini: `ffi.enable=false`
FFI: EXAMPLE 1
FFI: EXAMPLE 2
FFI: PHP TENSORFLOW
Dmitry Stogov has developed an experimental binding
of TensorFlow library in PHP using FFI:
dstogov/php-tensorflow
SIX
Weak References
WEAK REFERENCES
Weak References allow the programmer to retain a reference to an object which does not prevent the
object from being destroyed; They are useful for implementing cache like structures. 
SEVEN
Covariant Returns and Contravariant
Parameters
COVARIANT RETURNS AND CONTRAVARIANT PARAMETERS
Variance is a property of class hierarchies describing how the types of a type constructor
affect subtypes.
•Invariant: if the type of the super-type constrain the type of the subtype.
•Covariant: if the ordering of types is preserved (types are ordered from
more specific to more generic).
•Contravariant: if it reverses the order (types are ordered from more
generic to more specific).
Currently, PHP has mostly invariant parameter and return types, with few exceptions. This
RFC proposes to allow covariance and contravariance on parameter types and return types.
In general, a type constructor can be:
COVARIANT RETURN TYPE: EXAMPLE
CONTRAVARIANT PARAMETER TYPE: EXAMPLE
EIGHT
Preloading
OPCACHE
PRELOADING
"On server startup – before any application code is run – we may load a
certain set of PHP files into memory – and make their contents
“permanently available” to all subsequent requests that will be served by
that server. All the functions and classes defined in these files will be
available to requests out of the box, exactly like internal entities."
Dmitry Stogov
PRELOADING
• Preloading is controlled by a specific php.ini directive: opcache.preload
• This directive specifies a PHP script to be compiled and executed at server start-up
• Each file to cache, should be added in this script using opcache_compile_file()
PRELOADING: COMPOSITION
opcache.preload=“/tmp/preload.php”
OPCache Preloading in Symfony
opcache.preload=/path/to/project/var/cache/prod/App_KernelProdContainer.preload.php
PRELOADING: BENCHMARKS
• Preloading disabled
• Naive preloading - all Laravel and application code
I found this benchmark by stitcher.io on Laravel project
• Preloading Optimised - dumped all classes used by `get_declared_classes()`
Scenarios:
PRELOADING: BENCHMARKS
Requests per second Time per request
That's around a 25% performance gain compared to not using
preloading, and an 8% gain compared to using the naive approach.
PRELOADING: CONS
• Restart the web server to update opcache.preload
• Not compatible with host running multiple applications, or multiple
versions of applications
NINE
Deprecate left-associative ternary operator
DEPRECATE LEFT-ASSOCIATIVE TERNARY OPERATOR
Unlike most other languages, the ternary operator in PHP is left-associative rather than right-associative.
Not only being uncommon, it is also confusing for programmers who switch between different languages.
PHP 7.4 proposes to remove the left-associativity and requires the use of parentheses instead.
• Starting from PHP 7.4, nested ternaries without explicit use of parentheses will throw a deprecation warning.
• Starting from PHP 8.0, there will be a compile runtime error.
TEN
Performance of PHP 7.4
PERFORMANCE OF PHP 7.4
• He compared the execution time of PHP7.4RC1 with PHP 7.1, 7.2 and 7.3
• He used Zendbench.php script as benchmark
I found this benchmark on PHP 7.X by Enrico Zimuel
• He took the total execution time
• Full experiment report here
PERFORMANCE OF PHP 7.4: RESULTS
PHP ver. Exec. time (in sec)
7.1.32 455
7.2.22 437
7.3.9 373
7.4RC1 334
PERFORMANCE OF PHP 7.4: RESULTS
PHP 7.4 IS THE FASTEST!
• 7.4RC1 is 26% faster than 7.1.32
• 7.4RC1 is 22% faster than 7.2.22
• 7.4RC1 is 10% faster than 7.3.9
LET’S GO CODING IN PHP 7.4
Thanks for the attention
Andrea Giannantonio
@JellyBellyDev
REFERENCES
• https://www.php.net
• https://wiki.php.net/rfc#php_74
• https://www.zimuel.it/slides/pugtorino/php74#/
• https://www.zimuel.it/blog/benchmarking_PHP74
• https://medium.com/@daniel.dan/whats-new-in-php-7-4-top-10-features-that-you-need-to-know-e0acc3191f0a
• https://kinsta.com/blog/php-7-4/
• https://stitcher.io/blog/new-in-php-74
• https://stitcher.io/blog/php-preload-benchmarks
• https://support.cloud.engineyard.com/hc/en-us/articles/205411888-PHP-Performance-I-Everything-You-Need-to-
Know-About-OpCode-Caches
• https://carbon.now.sh/

More Related Content

What's hot

Functional programming with Java 8
Functional programming with Java 8Functional programming with Java 8
Functional programming with Java 8
Talha Ocakçı
 
Zen and the Art of REST API documentation - MuCon London 2015
Zen and the Art of REST API documentation - MuCon London 2015Zen and the Art of REST API documentation - MuCon London 2015
Zen and the Art of REST API documentation - MuCon London 2015
Steve Judd
 
C-Sharp 6.0 ver2
C-Sharp 6.0 ver2C-Sharp 6.0 ver2
C-Sharp 6.0 ver2
Tome Tomovski
 
Intro dotnet
Intro dotnetIntro dotnet
java8-patterns
java8-patternsjava8-patterns
java8-patterns
Justin Lin
 
Using Aspects for Language Portability (SCAM 2010)
Using Aspects for Language Portability (SCAM 2010)Using Aspects for Language Portability (SCAM 2010)
Using Aspects for Language Portability (SCAM 2010)
lennartkats
 
CPAN Curation
CPAN CurationCPAN Curation
CPAN Curation
neilbowers
 
C# 9 and 10 - What's cool?
C# 9 and 10 - What's cool?C# 9 and 10 - What's cool?
C# 9 and 10 - What's cool?
Christian Nagel
 
Java 8 concurrency abstractions
Java 8 concurrency abstractionsJava 8 concurrency abstractions
Java 8 concurrency abstractions
Nawazish Mohammad Khan
 
JDT Embraces Lambda Expressions - EclipseCon North America 2014
JDT Embraces Lambda Expressions - EclipseCon North America 2014JDT Embraces Lambda Expressions - EclipseCon North America 2014
JDT Embraces Lambda Expressions - EclipseCon North America 2014
Noopur Gupta
 
Highly Surmountable Challenges in Ruby+OMR JIT Compilation
Highly Surmountable Challenges in Ruby+OMR JIT CompilationHighly Surmountable Challenges in Ruby+OMR JIT Compilation
Highly Surmountable Challenges in Ruby+OMR JIT Compilation
Matthew Gaudet
 
Coldfusion
ColdfusionColdfusion
Coldfusion
Ram
 
The Behaviour-Driven Programmer
The Behaviour-Driven ProgrammerThe Behaviour-Driven Programmer
The Behaviour-Driven Programmer
Julien Biezemans
 
Gdg dev fest 2107 to kotlin, with love
Gdg dev fest 2107   to kotlin, with loveGdg dev fest 2107   to kotlin, with love
Gdg dev fest 2107 to kotlin, with love
Ayman Mahfouz
 
High Performance Solution for PHP7
High Performance Solution for PHP7High Performance Solution for PHP7
High Performance Solution for PHP7
Xinchen Hui
 
ARB_gl_spirv implementation in Mesa: status update (XDC 2018)
ARB_gl_spirv implementation in Mesa: status update (XDC 2018)ARB_gl_spirv implementation in Mesa: status update (XDC 2018)
ARB_gl_spirv implementation in Mesa: status update (XDC 2018)
Igalia
 
The Spoofax Language Workbench (SPLASH 2010)
The Spoofax Language Workbench (SPLASH 2010)The Spoofax Language Workbench (SPLASH 2010)
The Spoofax Language Workbench (SPLASH 2010)
lennartkats
 
The compilation process
The compilation processThe compilation process
The compilation process
Alexander Bollbach
 
Static analysis for perl
Static analysis for perlStatic analysis for perl
Static analysis for perl
moznion
 
Eclipse and Java 8 - Eclipse Day India 2013
Eclipse and Java 8 - Eclipse Day India 2013Eclipse and Java 8 - Eclipse Day India 2013
Eclipse and Java 8 - Eclipse Day India 2013
Noopur Gupta
 

What's hot (20)

Functional programming with Java 8
Functional programming with Java 8Functional programming with Java 8
Functional programming with Java 8
 
Zen and the Art of REST API documentation - MuCon London 2015
Zen and the Art of REST API documentation - MuCon London 2015Zen and the Art of REST API documentation - MuCon London 2015
Zen and the Art of REST API documentation - MuCon London 2015
 
C-Sharp 6.0 ver2
C-Sharp 6.0 ver2C-Sharp 6.0 ver2
C-Sharp 6.0 ver2
 
Intro dotnet
Intro dotnetIntro dotnet
Intro dotnet
 
java8-patterns
java8-patternsjava8-patterns
java8-patterns
 
Using Aspects for Language Portability (SCAM 2010)
Using Aspects for Language Portability (SCAM 2010)Using Aspects for Language Portability (SCAM 2010)
Using Aspects for Language Portability (SCAM 2010)
 
CPAN Curation
CPAN CurationCPAN Curation
CPAN Curation
 
C# 9 and 10 - What's cool?
C# 9 and 10 - What's cool?C# 9 and 10 - What's cool?
C# 9 and 10 - What's cool?
 
Java 8 concurrency abstractions
Java 8 concurrency abstractionsJava 8 concurrency abstractions
Java 8 concurrency abstractions
 
JDT Embraces Lambda Expressions - EclipseCon North America 2014
JDT Embraces Lambda Expressions - EclipseCon North America 2014JDT Embraces Lambda Expressions - EclipseCon North America 2014
JDT Embraces Lambda Expressions - EclipseCon North America 2014
 
Highly Surmountable Challenges in Ruby+OMR JIT Compilation
Highly Surmountable Challenges in Ruby+OMR JIT CompilationHighly Surmountable Challenges in Ruby+OMR JIT Compilation
Highly Surmountable Challenges in Ruby+OMR JIT Compilation
 
Coldfusion
ColdfusionColdfusion
Coldfusion
 
The Behaviour-Driven Programmer
The Behaviour-Driven ProgrammerThe Behaviour-Driven Programmer
The Behaviour-Driven Programmer
 
Gdg dev fest 2107 to kotlin, with love
Gdg dev fest 2107   to kotlin, with loveGdg dev fest 2107   to kotlin, with love
Gdg dev fest 2107 to kotlin, with love
 
High Performance Solution for PHP7
High Performance Solution for PHP7High Performance Solution for PHP7
High Performance Solution for PHP7
 
ARB_gl_spirv implementation in Mesa: status update (XDC 2018)
ARB_gl_spirv implementation in Mesa: status update (XDC 2018)ARB_gl_spirv implementation in Mesa: status update (XDC 2018)
ARB_gl_spirv implementation in Mesa: status update (XDC 2018)
 
The Spoofax Language Workbench (SPLASH 2010)
The Spoofax Language Workbench (SPLASH 2010)The Spoofax Language Workbench (SPLASH 2010)
The Spoofax Language Workbench (SPLASH 2010)
 
The compilation process
The compilation processThe compilation process
The compilation process
 
Static analysis for perl
Static analysis for perlStatic analysis for perl
Static analysis for perl
 
Eclipse and Java 8 - Eclipse Day India 2013
Eclipse and Java 8 - Eclipse Day India 2013Eclipse and Java 8 - Eclipse Day India 2013
Eclipse and Java 8 - Eclipse Day India 2013
 

Similar to Top ten of PHP 7.4

Modern Frontend Technology
Modern Frontend TechnologyModern Frontend Technology
Modern Frontend Technology
Ship Hsu
 
WorkinOnTheRailsRoad
WorkinOnTheRailsRoadWorkinOnTheRailsRoad
WorkinOnTheRailsRoad
webuploader
 
Workin ontherailsroad
Workin ontherailsroadWorkin ontherailsroad
Workin ontherailsroad
Jim Jones
 
Object Oriented Programming with Laravel - Session 2
Object Oriented Programming with Laravel - Session 2Object Oriented Programming with Laravel - Session 2
Object Oriented Programming with Laravel - Session 2
Shahrzad Peyman
 
reactive_programming_for_java_developers.pdf
reactive_programming_for_java_developers.pdfreactive_programming_for_java_developers.pdf
reactive_programming_for_java_developers.pdf
Akshitkumar437417
 
PHP 7X New Features
PHP 7X New FeaturesPHP 7X New Features
PHP 7X New Features
Thanh Tai
 
Cakephp vs. laravel
Cakephp vs. laravelCakephp vs. laravel
Cakephp vs. laravel
GirnarSoft
 
Php Tutorial
Php TutorialPhp Tutorial
Php Tutorial
pratik tambekar
 
High Availability for OpenStack
High Availability for OpenStackHigh Availability for OpenStack
High Availability for OpenStack
Kamesh Pemmaraju
 
Php 5.6 vs Php 7 performance comparison
Php 5.6 vs Php 7 performance comparisonPhp 5.6 vs Php 7 performance comparison
Php 5.6 vs Php 7 performance comparison
Tu Pham
 
Laravel, beyond the framework
Laravel, beyond the frameworkLaravel, beyond the framework
Laravel, beyond the framework
Ramesh Mhetre
 
Laravel vs ASP.NET Framework .pdf
Laravel vs ASP.NET Framework .pdfLaravel vs ASP.NET Framework .pdf
Laravel vs ASP.NET Framework .pdf
WPWeb Infotech
 
Php 7 - YNS
Php 7 - YNSPhp 7 - YNS
Php 7 - YNS
Alex Amistad
 
Ratpack Web Framework
Ratpack Web FrameworkRatpack Web Framework
Ratpack Web Framework
Daniel Woods
 
RESTful Services
RESTful ServicesRESTful Services
RESTful Services
Jason Gerard
 
Chapter 9 & chapter 10 solutions
Chapter 9 & chapter 10 solutionsChapter 9 & chapter 10 solutions
Chapter 9 & chapter 10 solutions
Saeed Iqbal
 
Making the Most of Modern PHP in Drupal 7
Making the Most of Modern PHP in Drupal 7Making the Most of Modern PHP in Drupal 7
Making the Most of Modern PHP in Drupal 7
Ryan Szrama
 
Ruby on Rails : First Mile
Ruby on Rails : First MileRuby on Rails : First Mile
Ruby on Rails : First Mile
Gourab Mitra
 
Building a Better Mousetrap for the Cloud
Building a Better Mousetrap for the CloudBuilding a Better Mousetrap for the Cloud
Building a Better Mousetrap for the Cloud
elliando dias
 
Why Laravel?
Why Laravel?Why Laravel?
Why Laravel?
Jonathan Goode
 

Similar to Top ten of PHP 7.4 (20)

Modern Frontend Technology
Modern Frontend TechnologyModern Frontend Technology
Modern Frontend Technology
 
WorkinOnTheRailsRoad
WorkinOnTheRailsRoadWorkinOnTheRailsRoad
WorkinOnTheRailsRoad
 
Workin ontherailsroad
Workin ontherailsroadWorkin ontherailsroad
Workin ontherailsroad
 
Object Oriented Programming with Laravel - Session 2
Object Oriented Programming with Laravel - Session 2Object Oriented Programming with Laravel - Session 2
Object Oriented Programming with Laravel - Session 2
 
reactive_programming_for_java_developers.pdf
reactive_programming_for_java_developers.pdfreactive_programming_for_java_developers.pdf
reactive_programming_for_java_developers.pdf
 
PHP 7X New Features
PHP 7X New FeaturesPHP 7X New Features
PHP 7X New Features
 
Cakephp vs. laravel
Cakephp vs. laravelCakephp vs. laravel
Cakephp vs. laravel
 
Php Tutorial
Php TutorialPhp Tutorial
Php Tutorial
 
High Availability for OpenStack
High Availability for OpenStackHigh Availability for OpenStack
High Availability for OpenStack
 
Php 5.6 vs Php 7 performance comparison
Php 5.6 vs Php 7 performance comparisonPhp 5.6 vs Php 7 performance comparison
Php 5.6 vs Php 7 performance comparison
 
Laravel, beyond the framework
Laravel, beyond the frameworkLaravel, beyond the framework
Laravel, beyond the framework
 
Laravel vs ASP.NET Framework .pdf
Laravel vs ASP.NET Framework .pdfLaravel vs ASP.NET Framework .pdf
Laravel vs ASP.NET Framework .pdf
 
Php 7 - YNS
Php 7 - YNSPhp 7 - YNS
Php 7 - YNS
 
Ratpack Web Framework
Ratpack Web FrameworkRatpack Web Framework
Ratpack Web Framework
 
RESTful Services
RESTful ServicesRESTful Services
RESTful Services
 
Chapter 9 & chapter 10 solutions
Chapter 9 & chapter 10 solutionsChapter 9 & chapter 10 solutions
Chapter 9 & chapter 10 solutions
 
Making the Most of Modern PHP in Drupal 7
Making the Most of Modern PHP in Drupal 7Making the Most of Modern PHP in Drupal 7
Making the Most of Modern PHP in Drupal 7
 
Ruby on Rails : First Mile
Ruby on Rails : First MileRuby on Rails : First Mile
Ruby on Rails : First Mile
 
Building a Better Mousetrap for the Cloud
Building a Better Mousetrap for the CloudBuilding a Better Mousetrap for the Cloud
Building a Better Mousetrap for the Cloud
 
Why Laravel?
Why Laravel?Why Laravel?
Why Laravel?
 

Recently uploaded

Best Skills to Learn for Freelancing.pdf
Best Skills to Learn for Freelancing.pdfBest Skills to Learn for Freelancing.pdf
Best Skills to Learn for Freelancing.pdf
Million-$-Knowledge {Million Dollar Knowledge}
 
DASH, presented by Elly Tawhai at PacNOG 33
DASH, presented by Elly Tawhai at PacNOG 33DASH, presented by Elly Tawhai at PacNOG 33
DASH, presented by Elly Tawhai at PacNOG 33
APNIC
 
University of California, Riverside diploma
University of California, Riverside diplomaUniversity of California, Riverside diploma
University of California, Riverside diploma
eufdev
 
Saint Louis University diploma
Saint Louis University diplomaSaint Louis University diploma
Saint Louis University diploma
eufdev
 
Mobile SEO India | Mobile SEO Service | Mobile SEO Company
Mobile SEO India | Mobile SEO Service | Mobile SEO CompanyMobile SEO India | Mobile SEO Service | Mobile SEO Company
Mobile SEO India | Mobile SEO Service | Mobile SEO Company
SIB Infotech
 
202254.com香蕉影视,沙丘2在线播放,沙丘2线上看,最新电影沙丘2在线,热门电影推荐,2024最新科幻片推荐。
202254.com香蕉影视,沙丘2在线播放,沙丘2线上看,最新电影沙丘2在线,热门电影推荐,2024最新科幻片推荐。202254.com香蕉影视,沙丘2在线播放,沙丘2线上看,最新电影沙丘2在线,热门电影推荐,2024最新科幻片推荐。
202254.com香蕉影视,沙丘2在线播放,沙丘2线上看,最新电影沙丘2在线,热门电影推荐,2024最新科幻片推荐。
yilin01100
 
New York Institute of Technology degree Cert diploma offer
New York Institute of Technology degree Cert diploma offerNew York Institute of Technology degree Cert diploma offer
New York Institute of Technology degree Cert diploma offer
ubovu
 
Effective Tips for Creating the Best Rich Media Ads .pptx
Effective Tips for Creating the Best Rich Media Ads .pptxEffective Tips for Creating the Best Rich Media Ads .pptx
Effective Tips for Creating the Best Rich Media Ads .pptx
AirtoryInc
 
Rent remote desktop server mangohost .net
Rent remote desktop server mangohost .netRent remote desktop server mangohost .net
Rent remote desktop server mangohost .net
pdfsubmission50
 
Trump Assassination Shirt Trump Assassination Shirt
Trump Assassination Shirt Trump Assassination ShirtTrump Assassination Shirt Trump Assassination Shirt
Trump Assassination Shirt Trump Assassination Shirt
exgf28
 
Career Development Advice for Network Engineers across the Pacific, presented...
Career Development Advice for Network Engineers across the Pacific, presented...Career Development Advice for Network Engineers across the Pacific, presented...
Career Development Advice for Network Engineers across the Pacific, presented...
APNIC
 
Digital ethnography of the Polish darknet drug trade community
Digital ethnography of the Polish darknet drug trade communityDigital ethnography of the Polish darknet drug trade community
Digital ethnography of the Polish darknet drug trade community
Piotr Siuda
 
How God led me to DTS? Through many different signs and connections that I c...
How God led me to DTS? Through many different signs and connections that  I c...How God led me to DTS? Through many different signs and connections that  I c...
How God led me to DTS? Through many different signs and connections that I c...
AshishMohan57
 
Top 50 Telephone Conversation Sample Examples For IT Industries.pdf
Top 50 Telephone Conversation Sample Examples For IT Industries.pdfTop 50 Telephone Conversation Sample Examples For IT Industries.pdf
Top 50 Telephone Conversation Sample Examples For IT Industries.pdf
Krishna L
 
Open Source TCP or Netflow Log Server Using Graylog
Open Source TCP or Netflow Log Server Using GraylogOpen Source TCP or Netflow Log Server Using Graylog
Open Source TCP or Netflow Log Server Using Graylog
Bangladesh Network Operators Group
 
Software Defined Networking, Concepts and Practical Implementations
Software Defined Networking, Concepts and Practical ImplementationsSoftware Defined Networking, Concepts and Practical Implementations
Software Defined Networking, Concepts and Practical Implementations
Bangladesh Network Operators Group
 
SisAi World - Software is AI - Providing AI as Software - Protecting the Inte...
SisAi World - Software is AI - Providing AI as Software - Protecting the Inte...SisAi World - Software is AI - Providing AI as Software - Protecting the Inte...
SisAi World - Software is AI - Providing AI as Software - Protecting the Inte...
QingjieDu1
 
Trump fist pump t shirts Trump fist pump t shirts
Trump fist pump t shirts Trump fist pump t shirtsTrump fist pump t shirts Trump fist pump t shirts
Trump fist pump t shirts Trump fist pump t shirts
exgf28
 
upgrade to zabbix-7 0 como atualiza lts1
upgrade to zabbix-7 0 como atualiza lts1upgrade to zabbix-7 0 como atualiza lts1
upgrade to zabbix-7 0 como atualiza lts1
diogolsew
 
Ontology for the semantic enhancement, database definition and management and...
Ontology for the semantic enhancement, database definition and management and...Ontology for the semantic enhancement, database definition and management and...
Ontology for the semantic enhancement, database definition and management and...
Edward Blurock
 

Recently uploaded (20)

Best Skills to Learn for Freelancing.pdf
Best Skills to Learn for Freelancing.pdfBest Skills to Learn for Freelancing.pdf
Best Skills to Learn for Freelancing.pdf
 
DASH, presented by Elly Tawhai at PacNOG 33
DASH, presented by Elly Tawhai at PacNOG 33DASH, presented by Elly Tawhai at PacNOG 33
DASH, presented by Elly Tawhai at PacNOG 33
 
University of California, Riverside diploma
University of California, Riverside diplomaUniversity of California, Riverside diploma
University of California, Riverside diploma
 
Saint Louis University diploma
Saint Louis University diplomaSaint Louis University diploma
Saint Louis University diploma
 
Mobile SEO India | Mobile SEO Service | Mobile SEO Company
Mobile SEO India | Mobile SEO Service | Mobile SEO CompanyMobile SEO India | Mobile SEO Service | Mobile SEO Company
Mobile SEO India | Mobile SEO Service | Mobile SEO Company
 
202254.com香蕉影视,沙丘2在线播放,沙丘2线上看,最新电影沙丘2在线,热门电影推荐,2024最新科幻片推荐。
202254.com香蕉影视,沙丘2在线播放,沙丘2线上看,最新电影沙丘2在线,热门电影推荐,2024最新科幻片推荐。202254.com香蕉影视,沙丘2在线播放,沙丘2线上看,最新电影沙丘2在线,热门电影推荐,2024最新科幻片推荐。
202254.com香蕉影视,沙丘2在线播放,沙丘2线上看,最新电影沙丘2在线,热门电影推荐,2024最新科幻片推荐。
 
New York Institute of Technology degree Cert diploma offer
New York Institute of Technology degree Cert diploma offerNew York Institute of Technology degree Cert diploma offer
New York Institute of Technology degree Cert diploma offer
 
Effective Tips for Creating the Best Rich Media Ads .pptx
Effective Tips for Creating the Best Rich Media Ads .pptxEffective Tips for Creating the Best Rich Media Ads .pptx
Effective Tips for Creating the Best Rich Media Ads .pptx
 
Rent remote desktop server mangohost .net
Rent remote desktop server mangohost .netRent remote desktop server mangohost .net
Rent remote desktop server mangohost .net
 
Trump Assassination Shirt Trump Assassination Shirt
Trump Assassination Shirt Trump Assassination ShirtTrump Assassination Shirt Trump Assassination Shirt
Trump Assassination Shirt Trump Assassination Shirt
 
Career Development Advice for Network Engineers across the Pacific, presented...
Career Development Advice for Network Engineers across the Pacific, presented...Career Development Advice for Network Engineers across the Pacific, presented...
Career Development Advice for Network Engineers across the Pacific, presented...
 
Digital ethnography of the Polish darknet drug trade community
Digital ethnography of the Polish darknet drug trade communityDigital ethnography of the Polish darknet drug trade community
Digital ethnography of the Polish darknet drug trade community
 
How God led me to DTS? Through many different signs and connections that I c...
How God led me to DTS? Through many different signs and connections that  I c...How God led me to DTS? Through many different signs and connections that  I c...
How God led me to DTS? Through many different signs and connections that I c...
 
Top 50 Telephone Conversation Sample Examples For IT Industries.pdf
Top 50 Telephone Conversation Sample Examples For IT Industries.pdfTop 50 Telephone Conversation Sample Examples For IT Industries.pdf
Top 50 Telephone Conversation Sample Examples For IT Industries.pdf
 
Open Source TCP or Netflow Log Server Using Graylog
Open Source TCP or Netflow Log Server Using GraylogOpen Source TCP or Netflow Log Server Using Graylog
Open Source TCP or Netflow Log Server Using Graylog
 
Software Defined Networking, Concepts and Practical Implementations
Software Defined Networking, Concepts and Practical ImplementationsSoftware Defined Networking, Concepts and Practical Implementations
Software Defined Networking, Concepts and Practical Implementations
 
SisAi World - Software is AI - Providing AI as Software - Protecting the Inte...
SisAi World - Software is AI - Providing AI as Software - Protecting the Inte...SisAi World - Software is AI - Providing AI as Software - Protecting the Inte...
SisAi World - Software is AI - Providing AI as Software - Protecting the Inte...
 
Trump fist pump t shirts Trump fist pump t shirts
Trump fist pump t shirts Trump fist pump t shirtsTrump fist pump t shirts Trump fist pump t shirts
Trump fist pump t shirts Trump fist pump t shirts
 
upgrade to zabbix-7 0 como atualiza lts1
upgrade to zabbix-7 0 como atualiza lts1upgrade to zabbix-7 0 como atualiza lts1
upgrade to zabbix-7 0 como atualiza lts1
 
Ontology for the semantic enhancement, database definition and management and...
Ontology for the semantic enhancement, database definition and management and...Ontology for the semantic enhancement, database definition and management and...
Ontology for the semantic enhancement, database definition and management and...
 

Top ten of PHP 7.4

  • 1. Top ten of php 7.4 Andrea Giannantonio Team Leader in Immobiliare.it @JellyBellyDev
  • 2. RELEASE DATE PHP 7.4 •Alpha1 - 13 Jun 2019 •Beta1 - 25 Jul 2019 •RC1 - 5 Sep 2019 •RC2 - 19 Sep 2019 •RC3 - 03 Oct 2019 •RC4 - 18 Oct 2019 •RC5 - 31 Oct 2019 •RC6 - 14 Nov 2019 •7.4.0 - 28 Nov 2019 (GA) •7.4.1 - 18 Dec 2019 (GA) •7.4.2 - 23 Jan 2020 (GA)
  • 3. TOP TEN •Typed Properties •Arrow Functions •Null Coalescing Assignment Operator •Spread Operator in Array •Foreign Function Interface •Weak References •Covariant Returns and Contravariant Parameters •Preloading •Deprecate left-associative ternary operator •Performance of PHP 7.4
  • 5. PARAM AND RETURN TYPES: PHP 7.1
  • 6. Allowed: bool, int, float, string, array, object, iterable, self, parent, any class or interface name, and nullable types (?type) Not Allowed: void and callable TYPED PROPERTIES: PHP 7.4
  • 9. TYPED PROPERTIES: INVARIANT Property types (public and protected) are invariant
  • 13. ARROW FUNCTIONS Syntax: fn(parameter_list) => expr Note: fn is a reserved word in PHP 7.4
  • 15. SPREAD OPERATOR Note that this only works with arrays with numerical keys.
  • 16. SPREAD OPERATOR It also works on Traversable objects
  • 18. NULL COALESCING ASSIGNMENT OPERATOR Note that, while the coalesce operator `??` is a comparison operator, `??=` is an assignment operator.
  • 20. FOREIGN FUNCTION INTERFACE •Enables the execution of C code directly from PHP •Provides a FFI class to manage the bridge between C and PHP •A C function can be executed as a PHP method of FFI class •php.ini: `ffi.enable=false`
  • 23. FFI: PHP TENSORFLOW Dmitry Stogov has developed an experimental binding of TensorFlow library in PHP using FFI: dstogov/php-tensorflow
  • 25. WEAK REFERENCES Weak References allow the programmer to retain a reference to an object which does not prevent the object from being destroyed; They are useful for implementing cache like structures. 
  • 26. SEVEN Covariant Returns and Contravariant Parameters
  • 27. COVARIANT RETURNS AND CONTRAVARIANT PARAMETERS Variance is a property of class hierarchies describing how the types of a type constructor affect subtypes. •Invariant: if the type of the super-type constrain the type of the subtype. •Covariant: if the ordering of types is preserved (types are ordered from more specific to more generic). •Contravariant: if it reverses the order (types are ordered from more generic to more specific). Currently, PHP has mostly invariant parameter and return types, with few exceptions. This RFC proposes to allow covariance and contravariance on parameter types and return types. In general, a type constructor can be:
  • 32. PRELOADING "On server startup – before any application code is run – we may load a certain set of PHP files into memory – and make their contents “permanently available” to all subsequent requests that will be served by that server. All the functions and classes defined in these files will be available to requests out of the box, exactly like internal entities." Dmitry Stogov
  • 33. PRELOADING • Preloading is controlled by a specific php.ini directive: opcache.preload • This directive specifies a PHP script to be compiled and executed at server start-up • Each file to cache, should be added in this script using opcache_compile_file()
  • 34. PRELOADING: COMPOSITION opcache.preload=“/tmp/preload.php” OPCache Preloading in Symfony opcache.preload=/path/to/project/var/cache/prod/App_KernelProdContainer.preload.php
  • 35. PRELOADING: BENCHMARKS • Preloading disabled • Naive preloading - all Laravel and application code I found this benchmark by stitcher.io on Laravel project • Preloading Optimised - dumped all classes used by `get_declared_classes()` Scenarios:
  • 36. PRELOADING: BENCHMARKS Requests per second Time per request That's around a 25% performance gain compared to not using preloading, and an 8% gain compared to using the naive approach.
  • 37. PRELOADING: CONS • Restart the web server to update opcache.preload • Not compatible with host running multiple applications, or multiple versions of applications
  • 39. DEPRECATE LEFT-ASSOCIATIVE TERNARY OPERATOR Unlike most other languages, the ternary operator in PHP is left-associative rather than right-associative. Not only being uncommon, it is also confusing for programmers who switch between different languages. PHP 7.4 proposes to remove the left-associativity and requires the use of parentheses instead. • Starting from PHP 7.4, nested ternaries without explicit use of parentheses will throw a deprecation warning. • Starting from PHP 8.0, there will be a compile runtime error.
  • 41. PERFORMANCE OF PHP 7.4 • He compared the execution time of PHP7.4RC1 with PHP 7.1, 7.2 and 7.3 • He used Zendbench.php script as benchmark I found this benchmark on PHP 7.X by Enrico Zimuel • He took the total execution time • Full experiment report here
  • 42. PERFORMANCE OF PHP 7.4: RESULTS PHP ver. Exec. time (in sec) 7.1.32 455 7.2.22 437 7.3.9 373 7.4RC1 334
  • 43. PERFORMANCE OF PHP 7.4: RESULTS PHP 7.4 IS THE FASTEST! • 7.4RC1 is 26% faster than 7.1.32 • 7.4RC1 is 22% faster than 7.2.22 • 7.4RC1 is 10% faster than 7.3.9
  • 44. LET’S GO CODING IN PHP 7.4
  • 45. Thanks for the attention Andrea Giannantonio @JellyBellyDev
  • 46. REFERENCES • https://www.php.net • https://wiki.php.net/rfc#php_74 • https://www.zimuel.it/slides/pugtorino/php74#/ • https://www.zimuel.it/blog/benchmarking_PHP74 • https://medium.com/@daniel.dan/whats-new-in-php-7-4-top-10-features-that-you-need-to-know-e0acc3191f0a • https://kinsta.com/blog/php-7-4/ • https://stitcher.io/blog/new-in-php-74 • https://stitcher.io/blog/php-preload-benchmarks • https://support.cloud.engineyard.com/hc/en-us/articles/205411888-PHP-Performance-I-Everything-You-Need-to- Know-About-OpCode-Caches • https://carbon.now.sh/