hyperf/docs/en/quick-start/install.md

88 lines
4.0 KiB
Markdown
Raw Normal View History

2019-07-13 15:50:51 +08:00
# Installation
## Requirements
Hyperf can only run on the Linux and MacOS system environments. However, due to the development of Docker virtualization technology, it is possible to use Windows as the system environment using Docker for Windows. If you use MacOS we recommend a local deployment to avoid the Docker shared disk causing slow startup times for Hyperf.
2019-07-13 15:50:51 +08:00
Various Dockerfiles have been prepared for in the [hyperf/hyperf-docker](https://github.com/hyperf/hyperf-docker) project, or you can use a prebuilt image based on [hyperf\Hyperf](https://hub.docker.com/r/hyperf/hyperf).
2019-07-13 15:50:51 +08:00
2023-06-27 07:15:30 +08:00
If you don't use Docker as the basis for your system environment, you can also consider using [Box](en/eco/box.md) as the basic environment for running. If you wish to set up the environment yourself, you need to make sure that your native environment meets the following requirements:
2019-07-13 15:50:51 +08:00
- PHP >= 8.1
2022-05-25 15:24:28 +08:00
- Any of the following network engines
- [Swoole PHP extension](https://github.com/swoole/swoole-src) >= 5.0with `swoole.use_shortname` set to `Off` in your `php.ini`
- [Swow PHP extension](https://github.com/swow/swow) >= 1.3
2019-07-13 15:50:51 +08:00
- JSON PHP extension
2023-04-18 09:03:47 +08:00
- Pcntl PHP extension (Only on Swoole engine)
2022-05-25 15:24:28 +08:00
- OpenSSL PHP extension If you need to use the HTTPS
- PDO PHP extension If you need to use the MySQL Client
- Redis PHP extension If you need to use the Redis Client
- Protobuf PHP extension If you need to use the gRPC Server or Client
2019-07-13 15:50:51 +08:00
## Install Hyperf
Hyperf uses [Composer](https://getcomposer.org) to manage project dependencies. Before using Hyperf, make sure your operating environment has Composer installed.
2019-07-13 15:50:51 +08:00
### Create project via `Composer`
The project [hyperf/hyperf-skeleton](https://github.com/hyperf/hyperf-skeleton) is a skeleton project that we have prepared for you, with built-in files for common components and related configuration. It is a foundational web project that can be quickly used to get started with professional Hyperf development. At the time of installation, you can choose component dependencies according to your own needs.
2019-07-13 15:50:51 +08:00
Execute the following command to create a hyperf-skeleton project at the current location
2022-05-25 15:24:28 +08:00
Based on Swoole engine:
2019-07-13 15:50:51 +08:00
```
composer create-project hyperf/hyperf-skeleton
```
2022-05-25 15:24:28 +08:00
Based on Swow engine:
```
composer create-project hyperf/swow-skeleton
```
2023-04-18 09:03:47 +08:00
> During the installation process, for options that you are not sure about, please directly press Enter to avoid issues where the service cannot be started due to automatic addition of some listeners without proper configuration.
### Develop in Docker
2019-07-13 15:50:51 +08:00
If your native environment does not meet the Hyperf system requirements, or if you are unfamiliar with system configuration, you can run and develop the Hyperf project as follows using Docker.
2023-04-25 09:32:59 +08:00
- Run Container
2023-04-18 09:03:47 +08:00
In the following example the host will be mapped to the local directory `/workspace/skeleton`:
> If the `selinux-enabled` option is enabled when docker starts, access to host resources in the container will be restricted, so you should add the `--privileged -u root` option when starting the container.
2019-07-13 15:50:51 +08:00
2023-04-18 09:03:47 +08:00
```shell
docker run --name hyperf \
-v /workspace/skeleton:/data/project \
-p 9501:9501 -it \
--privileged -u root \
--entrypoint /bin/sh \
hyperf/hyperf:8.1-alpine-v3.18-swoole
2023-04-18 09:03:47 +08:00
```
2019-07-13 15:50:51 +08:00
2023-04-18 09:03:47 +08:00
- Create Project
```shell
cd /data/project
2019-07-13 15:50:51 +08:00
composer create-project hyperf/hyperf-skeleton
2023-04-18 09:03:47 +08:00
```
2019-07-13 15:50:51 +08:00
2023-04-18 09:03:47 +08:00
- Start the project
2023-04-18 09:03:47 +08:00
```shell
cd hyperf-skeleton
2019-07-13 15:50:51 +08:00
php bin/hyperf.php start
```
2023-04-18 09:03:47 +08:00
Next, you can see your installed project in `/workspace/skeleton/hyperf-skeleton`. Since Hyperf is a persistent CLI framework, when you have modified your code, you should terminate the running process instance with `CTRL + C` and re-execute the `php bin/hyperf.php start` startup command to restart your server and reload the code.
2019-07-13 15:50:51 +08:00
## Incompatible extensions
Because Hyperf is based on Swoole's unprecedented coroutine functionality many extensions are incompatible, the following (including but not limited to) extensions are currently incompatible:
2019-07-13 15:50:51 +08:00
- xhprof
2023-04-18 09:03:47 +08:00
- xdebug (It's available in PHP 8.1+ and Swoole >= 5.0.2)
2019-07-13 15:50:51 +08:00
- blackfire
- trace
- uopz