PHP extensions fatigue

Each time I install a Debian-Apache-MySQL-PHP web hosting environment for PHPMyAdmin, Composer and Drupal, I do:

apt install gettext php-curl php-cli php-mysql php-mysqli php-zip php-json php-cgi php-gd php-mbstring php-seclib php-phpsecli php-pear libapache2-mod-php

Maintaining this through the years causes me fatigue because every day the names can change a bit and I must search for new names for the same packages.

I thought to solve this fatigue by using some single command to install all PHP extensions whatsoever without distinction (only those in official Debian repositories). Is there such a command?

Ansible and/or Docker or alternatives is too complicated for me, I am a Bash-and-be-done-with-it guy.

What could you advise me to solve the faituge of remembering and changing all these names, throughout the years?

Well there isn’t a “1 stop shop” kind of thing when it comes to installing multiple packages, though I mean you can always just alias the whole command if you’re too lazy to type it out. What I tend to always to is have an alias for specific commands such as

alias install='sudo apt-get -y install'

Or

alias update='sudo apt-get -y update'

Then when I want to install something, I just type in

install package_name_here

So for this instance, it would be

install php8.2-fpm

The -y flag automatically confirms and says yes to any confirmation requests you have for whatever package you install.

When I do an update, I just type in

update

in the terminal which is much faster than typing sudo apt -y update or sudo apt-get -y update.


So to answer your question, I mean you can always just alias the whole command like

alias in-php='apt install gettext php-curl php-cli php-mysql php-mysqli php-zip php-json php-cgi php-gd php-mbstring php-seclib php-phpsecli php-pear libapache2-mod-php'

Which in short terms would be “Install PHP” if you will or it could just be install-php. Other than that, there isn’t a built-in command on Linux or macOS that “automatically” installs the package you want by just typing in the package name if that’s what you’re trying to say.

Though I should mention, you can potentially do sudo apt -y install php-* which would install all available packages that pertains to PHP using that prefix of php-. So it would install php-curl, php-cli, php-mysql, php-zip, php-mbstring, etc all in one go.

Hello and thanks for detailing !

I am not lazy to type the command, it’s mostly hard for me it’s a long-liner with a few packages I have yet to learn on and that the name of any package can change any day :expressionless:

I think I can use backslashes for line break there, I should try it out.

I thought about installing all packages
Actually some PHP packages don’t have the term php on start:

apt-cache pkgnames | grep php

outputs 663 packages, with these:

weechat-php
libmarkdown-php
mlmmj-php-web
zabbix-frontend-php
libphp-jabber

It’s odd that the name doesn’t start with php, but there are actually many such packages :frowning:

This makes my PHP extensions fatigue worse :face_vomiting:

Not everything with PHP in the name is an extension to be installed. Many of those are just libraries written in PHP that one would normally use via composer but also have system packages available.

In my experience, these names pretty much never change so I’m not sure why you think they are changing constantly. The list of extensions a particular application needs might change from time to time, but the names of the extension package don’t.

The “just install everything” approach isn’t really a good plan. If you can’t remember which extensions you need, write it down somewhere and update it as things change.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.