# 7.3.USES=php 和 Flavors

当使用 [`php`](https://docs.freebsd.org/en/books/porters-handbook/uses/#uses-php) 并带有以下参数之一：`phpize`、`ext`、`zend` 或 `pecl`，该 Port 会自动填充 `FLAVORS`，其中包含它支持的 PHP 版本。

**示例 5：简单的 `USES=php` 扩展**

以下写法将为所有支持的版本生成包：

```makefile
PORTNAME=	some-ext
PORTVERSION=	0.0.1
PKGNAMEPREFIX=	${PHP_PKGNAMEPREFIX}

USES=		php:ext
```

以下写法将为所有支持的版本生成包，但排除 7.2：

```makefile
PORTNAME=	some-ext
PORTVERSION=	0.0.1
PKGNAMEPREFIX=	${PHP_PKGNAMEPREFIX}

USES=		php:ext
IGNORE_WITH_PHP=	72
```

## 7.3.1. 带 PHP 应用的 PHP Flavors

PHP 应用也可以支持 flavor。

这样可以为所有 PHP 版本生成包，方便用户在其服务器上使用所需的 PHP 版本。

> **技巧**
>
> 支持 flavor 的 PHP 应用*必须*在其包名中追加 `PHP_PKGNAMESUFFIX`。

**示例 6：为 PHP 应用添加 Flavors 支持**

为 PHP 应用添加 flavor 支持非常简单：

```makefile
PKGNAMESUFFIX=	${PHP_PKGNAMESUFFIX}

USES=	php:flavors
```

> **重要**
>
> 当添加对支持 PHP flavor 的 Port 的依赖时，使用 `@${PHP_FLAVOR}`。*绝不要*直接使用 `FLAVOR`。


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://porters-handbook.bsdcn.org/di-7-zhang-flavors/7.3.usesphp-he-flavors.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
