Hyperf beginner installation to start and access!
Hyperf’s official introduction:
Hyperf is a high-performance, highly flexible PHP coroutine framework based on Swoole 4.5, with built-in coroutine servers and a large number of commonly used The performance of components has been qualitatively improved compared to the traditional framework based on PHP-FPM. It provides ultra-high performance while maintaining extremely flexible scalability. Standard components are implemented based on the PSR standard and are based on powerful dependency injection design, ensuring Most components or classes are replaceable and reusable.
Hyperf runs in command line Cli mode. PHP-FPM mode is our commonly used mode. Among them, ThinkPHP, Laravle, Ci and other frameworks are all in this mode. The latest versions of TP and Laravle also support it. Cli mode!
Recommended: "PHP Video Tutorial"
The biggest difference between the two modes is:
PHP-FPM Yes: Every time you respond to a request, you must initialize the framework from the entry file, forward it to the controller through routing, get the result, and return the response!
Cli is: After starting the framework, the framework will reside in memory. Once started, it will register the service to the system, listen to our web port (80 or 9501, etc. can be customized), and then respond to every request. There is no need to load the framework file, the routing is recognized directly to the controller and you execute the logic code and return the result!
So the performance of the Hyperf framework is much higher than that of traditional frameworks such as TP. You only need to load it once and it will be waiting for you downstairs. One is that every time you look for him, he will come down from upstairs to see you every time.
Hyperf environment requirements:
Hyperf can only run in Linux and Mac environments, which means that our Windos computer does not support it, but Docker can be used under Windows for Windows as the running environment.
Running environment requirements:
PHP >= 7.3
- ##Swoole PHP extension >= 4.5, and close Short Name
- OpenSSL PHP extension
- JSON PHP extension
- PDO PHP extension (such as Need to use MySQL client)
- Redis PHP extension (if need to use Redis client)
- Protobuf PHP extension (if need to use To the gRPC server or client)
Hyperf installation:
You need to use composer, if your composer uses a foreign image , then it is very slow. Here is a very fast mirror address: composer mirror addresscomposer config -g repo.packagist composer https://mirrors.aliyun.com/composer
composer create-project hyperf/hyperf-skeleton
swoole.use_shortname = off below extension = swoole.so. The example is as follows:
[swoole] extension = swoole.so swoole.use_shortname = off
Start the project :
To start the project, you need to find the bin directory in the framework root directory, which contains a hyperf.php file Execute the command in the framework bin directory:php hyperf.php start
php bin/hyperf.php start
What should I do if the port is occupied?
If after starting, you find that the port is occupied when starting here later, then check the port process ID, kill the process and start again!<p>netstat -tunlp | grep 9501<br/>tcp 0 0 0.0.0.0:9501 0.0.0.0:* LISTEN 15893/skeleton.Mast<br/>kill 15893</p>
Summary:
Generally speaking, the process is not difficult. You need to have a learning server, or a mac computer itself, or a Docker environment built on a windows computer. . The requirement for PHP is greater than 7.3. It is recommended that you use PHP7.4. The extensions required for running also need to be installed together. The last step is to add swoole.use_shortname = off in php.ini, otherwise the framework cannot be started!The above is the detailed content of Hyperf beginner installation to start and access!. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



Hyperf is an excellent PHP framework. Its main features are fast, flexible and scalable. It is currently widely used in the industry. In the process of developing using the Hyperf framework, we often encounter situations that require configuration management. This article will introduce how to use the Hyperf framework for configuration management and provide specific code examples. 1. The location of the configuration file. When developing using the Hyperf framework, the configuration file is usually placed in the config directory, or it can be entered in the .env file.

Since its birth in 2004, PHP has been one of the most popular development languages in the world. With the rapid development of the Internet and the continuous innovation of technology, the development of PHP is also changing with each passing day. Among them, microservice architecture has gradually become a popular trend in software development today. This article will take you into the world of PHPHyperf microservice development, from entry to proficiency. 1. What is microservice architecture? Microservices architecture is a system architecture built on a set of small, independently deployed service components. Compared with traditional monolithic application architecture, microservice architecture

How to use the Hyperf framework for file downloading Introduction: File downloading is a common requirement when developing web applications using the Hyperf framework. This article will introduce how to use the Hyperf framework for file downloading, including specific code examples. 1. Preparation Before starting, make sure you have installed the Hyperf framework and successfully created a Hyperf application. 2. Create a file download controller First, we need to create a controller to handle file download requests. Open the terminal and enter

How to use the Hyperf framework for request current limiting Introduction: In modern Internet applications, how to ensure the stability of the system under high concurrency is very important. Request throttling is one of the common coping strategies. This article will introduce how to use the Hyperf framework to limit request flow and give specific code examples. 1. What is request current limiting? Request current limiting refers to limiting the number of request visits to the system within a period of time to prevent the system from crashing due to too many requests. Through reasonable current limiting strategies, better service quality and stability can be provided. H

How to use the Hyperf framework for image processing Introduction: With the rapid development of the mobile Internet, image processing has become more and more important in modern Web development. Hyperf is a high-performance framework based on Swoole, which provides a wealth of components and functions, including image processing. This article will introduce how to use the Hyperf framework for image processing and provide specific code examples. 1. Install the Hyperf framework: Before starting, we first make sure that the Hyperf framework has been installed. Compo

How to use the Hyperf framework for data paging Introduction: Data paging is very common in actual Web development. Paging can make it easier for users to browse large amounts of data. Hyperf is a high-performance PHP framework that provides a powerful set of features and components. This article will introduce how to use the Hyperf framework for data paging and give detailed code examples. 1. Preparation: Before starting, you need to ensure that the Hyperf framework has been correctly installed and configured. Can be done via Composer

How to use the Hyperf framework for cache management Cache is one of the important means to improve application performance, and modern frameworks provide us with more convenient cache management tools. This article will introduce how to use the Hyperf framework for cache management and provide specific code examples. The Hyperf framework is a high-performance framework developed based on Swoole. It has a rich set of built-in components and tools, including powerful cache management functions. The Hyperf framework supports multiple cache drivers, such as Redis and Memcach.

In recent years, microservices architecture has become a mainstream way to build modern applications. It improves the scalability, maintainability, and deployability of a large application by splitting it into small, autonomous services. In a microservice architecture, each service is developed, deployed, and run independently, and they interact through lightweight communication mechanisms. When building microservice applications, choosing a suitable development framework is very critical. PHPHyperf is a microservice framework based on Swoole's high-performance coroutine network framework
