Butti | High Performance with Laravel Octane | E-Book | www.sack.de
E-Book

E-Book, Englisch, 204 Seiten

Butti High Performance with Laravel Octane

Learn to fine-tune and optimize PHP and Laravel apps using Octane and an asynchronous approach
1. Auflage 2024
ISBN: 978-1-80181-904-6
Verlag: De Gruyter
Format: EPUB
Kopierschutz: 0 - No protection

Learn to fine-tune and optimize PHP and Laravel apps using Octane and an asynchronous approach

E-Book, Englisch, 204 Seiten

ISBN: 978-1-80181-904-6
Verlag: De Gruyter
Format: EPUB
Kopierschutz: 0 - No protection



Laravel Octane is a very powerful component in the Laravel ecosystem that can help you achieve remarkable app performance. With Laravel Octane, you will find tools (queues, cache, and tables) that facilitate a new asynchronous approach for improving application performance.

This book highlights how Laravel Octane works, what steps to take in designing an application from the start, what tools you have at your disposal, and how to set up production environments. It provides complete coverage of the strategies, tools, and best practices to make your apps scalable and performant. This is especially important as optimization is usually the overlooked part in the application development lifecycle. You will explore the asynchronous approach in Laravel and be able to release high-performing applications that have a positive impact on the end-user experience.

By the end of this book, you will find yourself designing, developing, and releasing high-performance applications.

Butti High Performance with Laravel Octane jetzt bestellen!

Autoren/Hrsg.


Weitere Infos & Material


Table of Contents - Understanding the Laravel Web Application Architecture
- Configuring the RoadRunner Application Server
- Configuring the Swoole Application Server
- Building a Laravel Octane Application
- Reducing Latency and Managing Data with an Asynchronous Approach
- Using Queues to Apply the Asynchronous Approach in Your Application
- Configuring the Laravel Octane Application for the Production Environment


1


Understanding the Laravel Web Application Architecture


This book is for Laravel developers who would like to make or design their Laravel web application in a more scalable way and make it more performant.

This book aims to provide you with knowledge, suggestions, and explanations on how to improve the software architecture of a web application, starting from a typical PHP web application architecture to a more scalable and performant architecture.

It provides a 360-degree overview of what it takes to design and build a performant application with Laravel Octane. We’ll see why Laravel Octane is suitable for designing and building a performant application. The book also covers the different tools used by Laravel Octane, such as Open Swoole and RoadRunner, and lists and describes the various features and differentiating elements. But the most important thing is to enable you to understand why and when to use Open Swoole or RoadRunner.

But before starting, why use Laravel Octane?

Laravel Octane is a tool that allows us to access some functionality and features exposed by the two application servers we just mentioned.

One of the benefits of Laravel Octane is the huge improvement in the response times to HTTP requests by clients such as web browsers. When we develop a Laravel application, we use an important software layer implemented by the framework. This software layer needs time and resources to start. Even if we talk about only a few resources and a short amount of time, this repeated action for each request, especially in a context where there are many requests, can be a problem. Or rather, its optimization could bring enormous benefits.

Laravel Octane, through application servers, does just that: optimizes the process of starting the framework, which typically happens for each individual request. We will see in detail how this is done; essentially, the objects and everything that the framework needs are started and allocated to the start of the application server, and then the instances are made available to the various workers. Workers are the processes that are initiated to serve the requests.

Another reason why it is interesting to evaluate the adoption of Laravel Octane in your Laravel web application is that by using an application server such as Swoole, you can access those features implemented by Swoole.

The functions are, for example, the advanced mechanisms of the cache driver, shared storage for sharing information between the various workers, and the execution of tasks in parallel.

This is a totally new concept to the classic PHP developer who typically does not have an immediate functionality available in the PHP core for the parallelization of processes.

This chapter will introduce you to the Laravel ecosystem and explore what Laravel Octane is.

This chapter aims to introduce you to the application server approach, in which more workers cooperate to manage multiple requests. Understanding the behavior under the hood allows the developer to avoid some mistakes, especially on shared resources (objects and global states) across the worker. This is important because the classical PHP approach is to have one dedicated thread to manage one request.

In this chapter, we will cover the following topics:

  • Exploring the Laravel ecosystem
  • Understanding the request lifecycle
  • Getting to know the application server

Technical requirements


In order to run the code and tools shown in this book, you must have the PHP engine installed on your machine. It is recommended that you have a recent version of PHP installed (at least , released in November 2020).

Also, in order to easily install additional tools, it is recommended that you have Homebrew installed if you use macOS. In the case of GNU/Linux systems, it will be sufficient to resort to using the package manager of the distribution used, and in the case of Windows systems, the advice is to have a virtual environment, for example, with Docker.

In the current chapter, some commands and source code will be shown, simply to share some concepts. In subsequent chapters, especially the second chapter about RoadRunner and the third chapter about Open Swoole, the installation of each package and tool will be addressed step by step.

There are those who, regardless of their operating system, prefer to maintain a “clean” installation by resorting to using Docker regardless of the host operating system. Where the next chapters deal with the installation of operating system-dependent tools, the different methods will be highlighted depending on the system in use.

The source code and the configuration files of the examples described in the current chapter are available here: https://github.com/PacktPublishing/High-Performance-with-Laravel-Octane/tree/main/octane-ch01

Exploring the Laravel ecosystem


Laravel is a great framework in the PHP ecosystem that helps developers to build web applications quickly and reliably.

It includes, as dependencies, some great tools from the PHP ecosystem, such as Symfony packages, and some other solid and mature packages such as Monolog for logging, Flysystem for accessing files and storage, and CommonMark for managing Markdown format.

From the Symfony world, Laravel includes packages such as Symfony/routing to manage routing, and http-foundation and http-kernel to manage HTTP communication.

All this is just to say that Laravel uses the best parts of the PHP ecosystem, puts them together, and provides tools, helpers, classes, and methods to simplify the usage of all the tools from the developer’s perspective.

In addition, Laravel is more than a framework. Laravel is an ecosystem.

Laravel also provides applications and services that are integrated with the framework.

For example, Laravel provides the following:

  • Cashier: For integration with Stripe and Paddle for the payment and subscription process.
  • Breeze, Jetstream, Sanctum, and Socialite: For managing authorization, authentication, the social login integration process, and exposing protected APIs.
  • Dusk and Pest: For testing.
  • Echo: For broadcasting events in real time.
  • Envoyer, Forge, and Vapor: For server or serverless management and to manage the deployment process.
  • Mix: For compiling JavaScript and CSS through a webpack configuration fully integrated with the Laravel frontend.
  • Horizon: A web user interface for monitoring queues based on Redis.
  • Nova: An administrator panel builder for Laravel applications.
  • Sail: A local development environment based on Docker.
  • Scout: A full-text search engine, backed by providers such as Algolia, Meilisearch, or simply by the MySQL or PostgreSQL database.
  • Spark: A boilerplate solution for managing billing/subscription in your application.
  • Telescope: UI module for showing debugging and insights.
  • Valet: A macOS-specific bundle of applications configured for running the PHP application. It has dependencies with nginx, PHP, and Dnsmasq.
  • Octane: For improving performance and optimizing resources.

In this book, we will analyze the last tool in this list: Laravel Octane.

We will go over the use of other tools within the Laravel ecosystem, such as Sail (for simplifying the installation process of a complete development environment), and Valet (for correctly setting up the local environment to run a web server and PHP). Also, Laravel Octane depends on important software that we will see in-depth throughout the book. Laravel Octane has strong requirements: it requires additional software such as Swoole or RoadRunner.

But one...


Butti Roberto :

Roberto Butti has been working in Web software development since 2000. He has worked for different markets and companies as well as with several languages/frameworks on both the server- and client-side Web. Today, he is focused on Web architecture with Laravel on the server side and various reactive Javascript frameworks such as React, Vue, and Svelte on the client side. Always passionate about performant and scalable architectures, he found in Laravel Octane, and more generally in OpenSwoole, an enabling tool for projects where concurrency, real-time, and performance are crucial.



Ihre Fragen, Wünsche oder Anmerkungen
Vorname*
Nachname*
Ihre E-Mail-Adresse*
Kundennr.
Ihre Nachricht*
Lediglich mit * gekennzeichnete Felder sind Pflichtfelder.
Wenn Sie die im Kontaktformular eingegebenen Daten durch Klick auf den nachfolgenden Button übersenden, erklären Sie sich damit einverstanden, dass wir Ihr Angaben für die Beantwortung Ihrer Anfrage verwenden. Selbstverständlich werden Ihre Daten vertraulich behandelt und nicht an Dritte weitergegeben. Sie können der Verwendung Ihrer Daten jederzeit widersprechen. Das Datenhandling bei Sack Fachmedien erklären wir Ihnen in unserer Datenschutzerklärung.