On 14/10/2025 18:50, Andriy Gapon wrote:
On 14/10/2025 19:45, Moin Rahman wrote:
On Oct 14, 2025, at 18:36, Andriy Gapon <[email protected]> wrote:
I am writing a recipe to configure a system for a particular purpose.
I need to install some version of PHP, doesn't matter much which, but
it should be a recent one. E.g., the latest available in ports or
the default version.
I do not want to hardcode any version / prefix like, say, "php83"
(because it may be obsolete or unavailable in a few years).
How could this be achieved with pkg?
I do not know what actually you are trying to do or if I have understood
you correctly. But let's say if I need dokuwiki and I do not want to add
specific version I just do `pkg install www/dokuwiki` which will find
out the required php version suffix and install all the php requirements.
But if you need are using this for a custom application which is not in
the tree and you need to install specific php versions for those then I
believe you are out of options.
Yes, it's for something that's not in ports.
But maybe it could be put into ports with some effort...
Maybe it would be a good idea to have some PHP meta-ports that just
install default versions?
E.g., for Python there is a python3 package that installs a current
default python3.xx version as dependency and there is python package
that installs a current default pythonX (python3 currently) as a
dependency.
I think it always brings some complications. In the past, there was
"php" as default (or maybe php5, don't remember it well, it was long
time ago) and then for example php56 as newer port. But then it was
problematic with upgrades where some "default" changed but user wanted
to stay on older branch, because many applications was still dependent
on an older PHP.
For your example with Python - "lang/python3" is not used as dependency
for any port. Python applications depends of "default" or Makefile
specified Python version. In analogy to your case with make a private
port of PHP application - you cannot depend on lang/php (or lang/php8),
because then it is hard to say which extensions you should install. Only
in a rare case when you application doesn't need any PHP extensions, you
"can" depend on fictional metaport lang/php8.
If you are writing some playbook or scripted setup, you can query
available versions by pkg search, for example:
# pkg search -x '^php8[0-9]-[0-9]'
Sort the results, tail -n1 and you have the latest available version.
Then you can say which PHP extensions to install.
Kind regards
Miroslav Lachman