Categories
Resources Web Development

PHP resource links

What’s New in PHP 8 (Features, Improvements, and the JIT Compiler)

Categories
Software Development Web Development

How to configure php 7.4+ on Linux Ubuntu 20.04+

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.

Why would you do that?

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.

But I set the damn configs WTF?

The two main files are located at

  1. /etc/php/7.4/cli/php.ini
  2. /etc/php/7.4/fpm/php.ini

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.

Categories
Resources Web Development

How to list and install php modules on ubuntu linux

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

php -m

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
service --status-all
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

Here is an interesting article about how apt-cache works on linux
Here is a link to some more resources about this topic.

Categories
Random Resources Web Development

PHP random links and resources

PHP the Right way – a website/book full of the most useful information you will find about PHP

Categories
Resources Web Development

PHP Namespace information, links and resources

It is important to understand what namespaces are in PHP and how to use them. Otherwise you will be lost and have many pains.

Videos

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

Categories
Resources Web Security

Symfony doctrine database secret configuration links and resources.

Storing secrets for Symfony applications – some ideas how to approach the topic

Categories
Resources Web Development

Symfony encore webpack compiling scss

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.

Down below the section Configuring Encore/webpack

Categories
Resources Web Development

Installing PHP composer programmatically with a bash script on linux

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.

Categories
Resources Web Development

Links and resources about installing php and extensions

It took quite a bit of searching to find something that accurately describes how to currently install php and it’s extensions on Linux.

How to install php on ubuntu

Another good link on installing php 7.4 on ubuntu

Enable php modules/extensions on ubuntu

Categories
Resources Web Development

PHP composer links and resources.

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.