PHP 8 Programming Tips, Tricks and Best Practices
eBook - ePub

PHP 8 Programming Tips, Tricks and Best Practices

Doug Bierer, Cal Evans

Partager le livre
  1. 528 pages
  2. English
  3. ePUB (adapté aux mobiles)
  4. Disponible sur iOS et Android
eBook - ePub

PHP 8 Programming Tips, Tricks and Best Practices

Doug Bierer, Cal Evans

DĂ©tails du livre
Aperçu du livre
Table des matiĂšres
Citations

À propos de ce livre

Discover effective techniques, workarounds, and expert guidance for avoiding situations where your application might break following PHP 8 migrationKey Features‱ Get the hang of all the new features introduced in PHP 8‱ Learn how to detect potential code breaks and keep your application code running smoothly in PHP 8‱ Explore an exciting new trend - asynchronous PHP programming using Swoole and FibersBook DescriptionThanks to its ease of use, PHP is a highly popular programming language used on over 78% of all web servers connected to the Internet. PHP 8 Programming Tips, Tricks, and Best Practices will help you to get up-to-speed with PHP 8 quickly. The book is intended for any PHP developer who wants to become familiar with the cool new features available in PHP 8, and covers areas where developers might experience backward compatibility issues with their existing code after a PHP 8 update. The book thoroughly explores best practices, and highlights ways in which PHP 8 enforces these practices in a much more rigorous fashion than its earlier versions. You'll start by exploring new PHP 8 features in the area of object-oriented programming (OOP), followed by enhancements at the procedural level. You'll then learn about potential backward compatible breaks and discover best practices for improving performance. The last chapter of the book gives you insights into PHP async, a revolutionary new way of programming, by providing detailed coverage and examples of asynchronous programming using the Swoole extension and Fibers. By the end of this PHP book, you'll not only have mastered the new features, but you'll also know exactly what to watch out for when migrating older PHP applications to PHP 8.What you will learn‱ Gain a comprehensive understanding of the new PHP 8 object-oriented features‱ Discover new PHP 8 procedural programming enhancements‱ Understand improvements in error handling in PHP 8‱ Identify potential backward compatibility issues‱ Avoid traps due to changes in PHP extensions‱ Find out which features have been deprecated and/or removed in PHP 8‱ Become well-versed with programming best practices enforced by PHP 8Who this book is forThis book is for PHP developers at all levels who have experience in PHP 5 or above. If you're just getting started with PHP, you'll find the code examples useful for learning the language. Developers who have worked for a few months on one or more PHP projects will be able to apply the tips and techniques to the code at hand, while those with many years of PHP experience are sure to appreciate the concise coverage of new PHP 8 features.

Foire aux questions

Comment puis-je résilier mon abonnement ?
Il vous suffit de vous rendre dans la section compte dans paramĂštres et de cliquer sur « RĂ©silier l’abonnement ». C’est aussi simple que cela ! Une fois que vous aurez rĂ©siliĂ© votre abonnement, il restera actif pour le reste de la pĂ©riode pour laquelle vous avez payĂ©. DĂ©couvrez-en plus ici.
Puis-je / comment puis-je télécharger des livres ?
Pour le moment, tous nos livres en format ePub adaptĂ©s aux mobiles peuvent ĂȘtre tĂ©lĂ©chargĂ©s via l’application. La plupart de nos PDF sont Ă©galement disponibles en tĂ©lĂ©chargement et les autres seront tĂ©lĂ©chargeables trĂšs prochainement. DĂ©couvrez-en plus ici.
Quelle est la différence entre les formules tarifaires ?
Les deux abonnements vous donnent un accĂšs complet Ă  la bibliothĂšque et Ă  toutes les fonctionnalitĂ©s de Perlego. Les seules diffĂ©rences sont les tarifs ainsi que la pĂ©riode d’abonnement : avec l’abonnement annuel, vous Ă©conomiserez environ 30 % par rapport Ă  12 mois d’abonnement mensuel.
Qu’est-ce que Perlego ?
Nous sommes un service d’abonnement Ă  des ouvrages universitaires en ligne, oĂč vous pouvez accĂ©der Ă  toute une bibliothĂšque pour un prix infĂ©rieur Ă  celui d’un seul livre par mois. Avec plus d’un million de livres sur plus de 1 000 sujets, nous avons ce qu’il vous faut ! DĂ©couvrez-en plus ici.
Prenez-vous en charge la synthÚse vocale ?
Recherchez le symbole Écouter sur votre prochain livre pour voir si vous pouvez l’écouter. L’outil Écouter lit le texte Ă  haute voix pour vous, en surlignant le passage qui est en cours de lecture. Vous pouvez le mettre sur pause, l’accĂ©lĂ©rer ou le ralentir. DĂ©couvrez-en plus ici.
Est-ce que PHP 8 Programming Tips, Tricks and Best Practices est un PDF/ePUB en ligne ?
Oui, vous pouvez accĂ©der Ă  PHP 8 Programming Tips, Tricks and Best Practices par Doug Bierer, Cal Evans en format PDF et/ou ePUB ainsi qu’à d’autres livres populaires dans Computer Science et Programming in PHP. Nous disposons de plus d’un million d’ouvrages Ă  dĂ©couvrir dans notre catalogue.

Informations

Année
2021
ISBN
9781801079709
Édition
1

Section 1: PHP 8 Tips

This section introduces cool stuff never seen before, new to PHP 8. The chapters discuss new features, first in Object-Oriented Programming, followed by new things at the functional and extension level. The last chapter in this section covers direct C language prototyping.
In this section, the following chapters are included:
  • Chapter 1, Introducing New PHP 8 OOP Features
  • Chapter 2, Learning about PHP 8's Functional Additions
  • Chapter 3, Taking Advantage of Error-Handling Enhancements
  • Chapter 4, Making Direct C-Language Calls

Chapter 1: Introducing New PHP 8 OOP Features

In this chapter, you are introduced to new PHP: Hypertext Preprocessor 8 (PHP 8) features specific to Object-Oriented Programming (OOP). The chapter features a set of classes that can be used to generate CAPTCHA images (CAPTCHA is an acronym for Completely Automated Public Turing test to tell Computers and Humans Apart), clearly illustrating new PHP 8 features and concepts. This chapter is critical in helping you quickly incorporate new PHP 8 features into your own practice. In doing so, your code will run faster and more efficiently, with fewer bugs.
The following topics are covered in this chapter:
  • Using constructor property promotion
  • Working with attributes
  • Incorporating match expressions into your program code
  • Understanding named arguments
  • Exploring new data types
  • Improving code using typed properties

Technical requirements

To examine and run the code examples provided in this chapter, the minimum recommended hardware is listed here:
  • x86_64-based desktop PC or laptop
  • 1 gigabyte (GB) free disk space
  • 4 GB of random-access memory (RAM)
  • 500 kilobits per second (Kbps) or faster internet connection
In addition, you will need to install the following software:
  • Docker
  • Docker Compose
This book uses a pre-built Docker image that contains all the needed software to create and run the PHP 8 code examples covered in this book. You do not need to install PHP, Apache, or MySQL on your computer: just use Docker and the provided image.
To set up a test environment to run the code examples, proceed as follows:
  1. Install Docker.
    If you are running Windows, start here:
    https://docs.docker.com/docker-for-windows/install/
    If you are on a Mac, start here:
    https://docs.docker.com/docker-for-mac/install/
    If you are on Linux, have a look here:
    https://docs.docker.com/engine/install/
  2. Install Docker Compose. For all operating systems, start here:
    https://docs.docker.com/compose/install/
  3. Install the source code associated with this book onto your local computer.
    If you have installed Git, use the following command:
    git clone https://github.com/PacktPublishing/PHP-8-Programming-Tips-Tricks-and-Best-Practices.git ~/repo
    Otherwise, you can simply download the source code from this Uniform Resource Locator (URL): https://github.com/PacktPublishing/PHP-8-Programming-Tips-Tricks-and-Best-Practices/archive/main.zip. You can then unzip into a folder you create, which we refer to as /repo in this book.
  4. You can now start the Docker daemon running. For Windows or Mac, all you need to do is to activate the Docker Desktop app.
    If you are running Ubuntu or Debian Linux, issue this command:
    sudo service docker start
    For Red Hat, Fedora, or CentOS, use this command:
    sudo systemctl start docker
  5. Build a Docker container associated with this book and bring it online. To do so, proceed as follows.
    From your local computer, open Command Prompt (terminal window). Change the directory to /repo. For the first time only, issue the docker-compose build command to build the environment. Note that you might need root (administrator) privileges to run Docker commands. If this is the case, either run as administrator (for Windows) or preface the command with sudo. Depending on your connection speed, the initial build might take quite a bit of time to complete!
  6. To bring...

Table des matiĂšres