Configuring php can be confusing. PHP uses multiple configuration files, but the main ones are both named php.ini. You see with php you can have separate configurations for the app and the command line aka cli.
This may sound stupid at first but it is due to the fact that your command line is a different environment from your app environment. In Linux for example each user of the cli has their own environmental variables. These variables get passed to the php cli. This can drive you insane on linux. You think you set the configurations correctly, app works, try command line and BOOM all messed up.
The two main files are located at
Yes they have the same exact name. Yes they contain the same thing. However, one is used for the command line (cli) and the other is for apps (fpm). So you must set the settings in both. If you wanted to use 1 file for both you might be able to remove/rename 1 file such as the cli, set the fpm file. Then use a symlink from the fpm file to the cli directory. It would require some testing but it will probably work.
P.S. The php configuration file is the largest you will ever in your life see. I’m guessing a few thousand lines, it feels like that, but there is a ton of commenting and documentation to help you complete with links.
I always, always forget how to do this and it takes an hour of googling to figure this out again. Basically I often need to see not just what php modules are installed on my system, but also what can be installed.
For example you can see what is already installed and available to you on your current system you simply type
in your command line. This command will list all of what is installed currently on your system.
But that is not what I want and probably not what you want if you are reading this. What I want is to know what is available for installing, or better what are the exact names of the packages. For this information you need a different command.
sudo apt-cache search php7*
This command searches the apt cache for packages that contain php7* the * is a wildcard meaning anything that looks like php7 such as php7.4-mysql. Try the command above and you will get a list of all of the php modules specifically for version 7.4. Not all modules will be listed. You can use another command to see all of the available php modules even if they don’t contain 7.4 in the name you can install them.
To see all php modules available use this command.
sudo apt-cache search php*
Minus the 7 and it will return every last module that contains the word php.
Then to install anything you need you use a command like the following
sudo apt install php7.4-mysql php7.4-curl php7.4-json php7.4-cgi php7.4-xsl
And that is how you list and install php modules/extensions.
Pro-tip : add -y to the end of the apt install command so you don’t have to keep answering yes during the module installs
After you install the modules you need to restart the PHP service. To see all the services currently running in order to find your PHP service type
That will list all of your systems services. Find the name of your php installation and restart it with this line of code
service php7.4-fpm restart
PHP the Right way – a website/book full of the most useful information you will find about PHP
It is important to understand what namespaces are in PHP and how to use them. Otherwise you will be lost and have many pains.
Below is a series of great videos explaining PHP namespaces little by little in easy to find and digest chunks.\
PHP namespaces 1/10: What is a namespace in PHP?
Everything about PHP namespaces – OOP in PHP | Part 10
Storing secrets for Symfony applications – some ideas how to approach the topic
I couldn’t remember where the hell in the documentation I saw this. This is how you tell yarn to run encore and compile everything.
The easiest way to install Composer is by using the bash script provided here. What I do is use vim to create a file named composer-install.sh then post that script in it.
I do this in any folder, then I move the script to make it global as suggested in the documentation here.
Basically all you are doing is using the linux mv command to move the composer.phar script so it is in the users global space.
Composer is a dependency manager for PHP. Confusing to install, easy to use.
Composer documentation – the actual documentation helps.
A gentle introduction to composer as a dependency manager – excellent resource covering pretty much everything about PHP composer you could ever want to know. Well mostly.