Home > PHP Framework > Swoole > Swoole framework easyswoole installation

Swoole framework easyswoole installation

coldplay.xixi
Release: 2021-04-28 16:56:32
forward
2916 people have browsed it

Swoole framework easyswoole installation

EasySwoole is a memory-resident PHP framework developed based on Swoole Server. It is designed for APIs and breaks away from the traditional PHP operating mode to bring convenience to process arousal and file loading. performance loss. EasySwoole highly encapsulates Swoole Server while still maintaining the original features of Swoole Server. It supports simultaneous monitoring of HTTP, customized TCP, and UDP protocols, allowing developers to write multi-process, asynchronous, and highly available applications with the lowest learning cost and effort. Serve.

1. Environmental requirements

2.Framework installation

# 创建项目composer create-project easyswoole/app easyswoole# 进入项目目录并启动cd easyswoole
php easyswoole start
Copy after login

Recommended (free):swoole

Swoole framework easyswoole installation

3. Understand the directory structure of the easyswoole framework
https://www.easyswoole.com/Manual/2.x/Cn/_book/Introduction/structure .html

4. Create a new controller
Swoole framework easyswoole installation

##App\HttpController is the controller directory, we create a new oneUser.php, the code is as follows:

<?phpnamespace App\HttpController;use EasySwoole\Core\Http\AbstractInterface\Controller;class User extends Controller{

    public function index()
    {
        $data[&#39;id&#39;] = 101;        $data[&#39;name&#39;] = "jack";        $this->response()->withHeader(&#39;Content-type&#39;,&#39;application/json;charset=utf-8&#39;);        $this->response()->write(json_encode($data));
    }    public function test()
    {
        $this->response()->write("test method for the User Controller");
    }
}
Copy after login
Restart the project, browser access


Swoole framework easyswoole installation

Access

http://10.211.55.17:9501/User/ Just visit http://10.211.55.17:9501/User/index. Note that index() in the controller is the default method.
Swoole framework easyswoole installation

The above is the detailed content of Swoole framework easyswoole installation. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:csdn.net
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template