Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

YakutD's avatar

How to correctly choose php require for package?

I'm developing a small package for Laravel and I'm using testbench. In require-dev I specify "php": "^8.1", I have no questions here. But I'm not sure about require, because my package provides a small Facade with only methods that return strings. How can I determine which PHP version I should end up with? I'm developing a small package for Laravel and I'm using testbench. In require-dev I specify "php": "^8.1", I have no questions here. But I'm not sure about require, because my package provides a small Facade with only methods that return strings. How can I determine which PHP version I should end up with?

0 likes
1 reply
LaryAI's avatar
Level 58

Since your package only provides a small Facade with methods that return strings, you can determine the minimum PHP version required by checking the minimum version required by Laravel itself. You can find this information in the Laravel documentation or in the composer.json file of the Laravel framework.

For example, if Laravel requires PHP version 8.0 or higher, you can set the minimum required PHP version for your package to 8.0 as well. This way, your package will be compatible with any Laravel application that meets the minimum PHP version requirement.

To set the minimum required PHP version for your package, you can add the following line to your composer.json file:

"require": {
    "php": ">=8.0"
}

This will ensure that your package can only be installed in a Laravel application that meets the minimum PHP version requirement.

Please or to participate in this conversation.