Search icon
Subscription
0
Cart icon
Close icon
You have no products in your basket yet
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
PHP 8 Programming Tips, Tricks and Best Practices

You're reading from  PHP 8 Programming Tips, Tricks and Best Practices

Product type Book
Published in Aug 2021
Publisher Packt
ISBN-13 9781801071871
Pages 528 pages
Edition 1st Edition
Languages
Author (1):
Doug Bierer Doug Bierer
Profile icon Doug Bierer

Table of Contents (17) Chapters

Preface 1. Section 1: PHP 8 Tips
2. Chapter 1: Introducing New PHP 8 OOP Features 3. Chapter 2: Learning about PHP 8's Functional Additions 4. Chapter 3: Taking Advantage of Error-Handling Enhancements 5. Chapter 4: Making Direct C-Language Calls 6. Section 2: PHP 8 Tricks
7. Chapter 5: Discovering Potential OOP Backward-Compatibility Breaks 8. Chapter 6: Understanding PHP 8 Functional Differences 9. Chapter 7: Avoiding Traps When Using PHP 8 Extensions 10. Chapter 8: Learning about PHP 8's Deprecated or Removed Functionality 11. Section 3: PHP 8 Best Practices
12. Chapter 9: Mastering PHP 8 Best Practices 13. Chapter 10: Improving Performance 14. Chapter 11: Migrating Existing PHP Apps to PHP 8 15. Chapter 12: Creating PHP 8 Applications Using Asynchronous Programming 16. Other Books You May Enjoy

What this book covers

Chapter 1, Introducing New PHP 8 OOP Features, introduces you to new PHP 8 features specific to Object-Oriented Programming (OOP). The chapter features plenty of short code examples that clearly illustrate the new features and concepts. This chapter is critical in helping you quickly take advantage of the power of PHP 8 and adapt the code examples to your own practice.

Chapter 2, Learning about PHP 8's Functional Additions, covers important additions and enhancements introduced to PHP 8 at the procedural level. It includes plenty of code examples that show new PHP 8 features and techniques to facilitate procedural programming. This chapter teaches you how to write faster and cleaner application code.

Chapter 3, Taking Advantage of Error-Handling Enhancements, explores one of the key improvements in PHP 8, its advanced error handling capabilities. In this chapter, you learn which Notices have been upgraded to Warnings, as well as which Warnings have now been promoted to Errors. This chapter will give you an excellent understanding of the background and intent of security enhancements allowing you to better control the use of your code. In addition, it's critical to be aware of error conditions that formerly only generated Warnings, but now generate Errors, so that you take measures to prevent your applications from failing following an upgrade to PHP 8.

Chapter 4, Making Direct C-Language Calls, helps you to learn what the Foreign Function Interface (FFI) is all about, what it's good for, and how to use it. The information in this chapter is important for developers interested in rapid custom prototyping using direct C language calls. This chapter shows you how to incorporate C language structures and functions directly into your code, opening the doors to an entire world of functionality hitherto unavailable to PHP.

Chapter 5, Discovering Potential OOP Backward-Compatibility Breaks, introduces you to new PHP 8 features specific to OOP. The chapter features plenty of short code examples that clearly illustrate the new features and concepts. This chapter is critical in helping you quickly take advantage of the power of PHP 8 by adapting the code examples into your own practice. In addition, this chapter highlights situations where object-oriented code might break after a PHP 8 migration.

Chapter 6, Understanding PHP 8 Functional Differences, covers potential backwards d-compatibility breaks at the PHP 8 command or functional level. This chapter presents important information that highlights potential pitfalls when migrating existing code to PHP 8. The information presented in this chapter enables you to produce reliable PHP code. After working through the concepts in this chapter, you'll be in a better position to write code that produces precise results and avoids inconsistencies.

Chapter 7, Avoiding Traps When Using PHP 8 Extensions, takes you through the major changes to extensions that have been made and how to avoid traps when updating an existing application to PHP 8. Once you finish reviewing the sample code and topics presented, you'll be able to prepare any existing PHP code for migration to PHP 8. In addition to learning about the changes to the various extensions, you'll also gain deep insight into their operation. This will allow you to make informed decisions when using extensions in PHP 8.

Chapter 8, Learning about PHP 8's Deprecated or Removed Functionality, walks you through functionality that has been deprecated or removed in PHP 8. After you have read the material in this chapter and followed the example application code, you will be able to detect and rewrite code that has been deprecated. You will also learn how to develop workarounds for functionality that has been removed as well as how to refactor code that uses removed functionality involving extensions. Another important skill you will learn in this chapter is how to improve application security by rewriting code depending on functions that have been entirely removed in PHP 8.

Chapter 9, Mastering PHP 8 Best Practices, introduces you to best practices now enforced in PHP 8. It covers a number of significant method signature changes and how their new usage continues the general PHP trend of helping you to produce better code. You will also learn about changes in the use of private methods, interfaces, traits, and anonymous classes, and how namespaces are now parsed. Mastering the best practices covered in this chapter will not only move you toward writing better code but will help you avoid the potential code breaks that might arise if you fail to grasp these new practices.

Chapter 10, Improving Performance, introduces you to a number of new PHP 8 features that have a positive effect on performance, with a special focus on the new Just-In-Time compiler. This chapter also includes thorough coverage of weak references whose proper use results in applications that use far less memory. By carefully reviewing the material covered in this chapter and by studying the code examples, you will be able to write faster and more efficient code.

Chapter 11, Migrating Existing PHP Apps to PHP 8, introduces a set of classes that form the basis of a PHP 8 backward-compatible break scanner. Throughout the book, you are shown potential code breaks that might follow a PHP 8 update. In addition, you will learn about the recommended process for migrating an existing customer PHP application to PHP 8. This chapter will leave you much better equipped to handle a PHP 8 migration, giving you the ability to perform PHP 8 migrations with greater confidence and a minimum number of problems.

Chapter 12, Creating PHP 8 Applications Using Asynchronous Programming, explains the difference between the traditional synchronous and asynchronous programming models. In recent years, an exciting new technology has taken the PHP community by storm: asynchronous programming, also known as PHP async. In addition, popular PHP async extensions and frameworks, including the Swoole extension and ReactPHP are covered, with plenty of examples to get you started. By the time you are done working through this chapter, you will be in a position to improve the performance of your applications, making them anywhere from 5 times up to a staggering 40 times faster!

lock icon The rest of the chapter is locked
Next Chapter arrow right
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €14.99/month. Cancel anytime}