> For the complete documentation index, see [llms.txt](https://book.bsdcn.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://book.bsdcn.org/porters-handbook/di-7-zhang-flavors/7.3.usesphp-he-flavors.md).

# 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
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
