Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The method of configuring Hyperf Hot Update Development Environment through PHPStorm

2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

Editor to share with you the way to configure Hyperf hot update development environment through PHPStorm, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!

Hot update development environment through PHPStorm configuration

When developing persistent applications like Hyperf/Swoole, whenever the application code changes, we need to restart the application to make the code effective, although it is also a correct and reasonable operation when developing CLI applications, because we still need to pay attention to the information output of stdout in the development process to judge the running status and results of the application. But this is very different from our original habit of developing PHP-FPM applications. What can we do if we want to maintain the development habits under PHP-FPM and save the code as soon as it works?

According to the introduction in the chapter "Hyperf official documentation-Cooperative process component Library", there are several third-party tools that can support this function, but if we use PHPStorm for development, then we can achieve this function directly through FileWatcher in PHPStorm.

The principle of the implementation is to listen for file changes under the project through FileWatcher, and then execute a shell script, through which the shell script is used to restart the application.

Create reload.sh

First, let's create a reload.sh file in the bin directory of skeleton and write the following Shell code:

#! / bin/bashbasepath=$ (cd `dirname $0`; pwd) cd $basepathif [- f ".. / runtime/hyperf.pid"]; thencat.. / runtime/hyperf.pid | awk'{print $1}'| xargs kill & & rm-rf.. / runtime/hyperf.pid & & rm-rf.. / runtime/containerfiphp hyperf.php start

What the shell script here does is determine whether the. / runtime/hyperf.pid file exists, if so, kill the running application according to the pid file, delete the pid file, and then start the application by executing the php bin/hyperf.php start command

Set the application to run as a daemon

Since the hot update is set, we also need to set the application to run as a daemon. In Hyperf, you can add daemonize to the settings of config/autoload/server.php and set it to true. The reference configuration is as follows:

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report