3. Nov 2022 |

Disable xdebug and fix Postman output

At some point var_dump in Postman started printing HTML instead of json and made debugging experience worse. I used php artisan serve and suspected that my CLI php is using xdebug. This advice I found helpful.

sudo phpdismod -s cli xdebug – to disable xdebug

sudo phpenmod -s cli xdebug – to enable xdebug

This is how you can disable and enable xdebug from command line. After this that <pre> thing should go away from Postman responses.

12. Oct 2022 |

php versions

As I use composer packages more and more I need to switch between php versions used in terminal. Some notes here for myself.

  • which php – where php is installed
  • php -v – which php is currently in use in terminal
  • ls -la /usr/bin/php* – which php versions are installed in the system

Install php on Ubuntu

sudo update-alternatives --config php – see options and switch between versions.

For installation I took commands from this instruction.

sudo apt install software-properties-common
sudo add-apt-repository ppa:ondrej/php

Install php7.4 with few common PHP modules (also Digital Ocean post)

sudo apt-get install -y php7.4 php7.4-cli php7.4-json php7.4-common php7.4-mysql php7.4-zip php7.4-gd php7.4-mbstring php7.4-curl php7.4-xml php7.4-bcmath

Digital Ocean gives following suggestions for packages:

sudo apt-get install -y php8.1 php8.1-cli php8.1-common php8.1-mysql php8.1-zip php8.1-gd php8.1-mbstring php8.1-curl php8.1-xml php8.1-bcmath

For uninstalling just use:

sudo apt remove php7.4 etc or the php -m to list all loaded PHP modules.

sudo apt autoremove

Composer broke down

StackOverflow solution and install composer the old way.

8. Jan 2022 |

How to prepare for the TestDome php assessment – my mistakes and tips

3rd year IT student in search of an internship

5th semester at school is pretty much over by now. Only one small assignment to do on upcoming Tuesday Thursday. Hopefully, I will write about the semester at some point.

On Monday I am going to do PHP tests for the internship that I applied for. I am preparing for it at the moment by solving Testdome PHP exercises and PHP interview questions. If I succeed it would be a huge step for me to become a sufficient Magento developer one day.

Continue reading “How to prepare for the TestDome php assessment – my mistakes and tips”

19. Nov 2021 |

Does PHP Loop Through the Whole Array to Find a Specific Element?

Same question here but I find its answer a bit misleading. My answer would be YES. You need to loop through the whole array to find a specific element and the worst case complexity is O(n). Unless:

  • you use associative array and ask the element by its key. Then the search takes constant time O(1).
  • you ask element by its index (you know where the element is and you go there directly). Then the search takes constant time O(1).
6. Jan 2021 |

7/100 – Birthday reminder app with sqlite and php

As I sometimes lock myself out from Facebook I have no idea if any of my friends is having a birthday any time soon. I also already have difficulty remembering ages and birthdays of all my relatives (especially new ones). Before solving my personal CRM needs with Monica I decided to build something myself.

Today I worked on building a small web app using sqlite and php to save/edit/delete birthdays of my friends and family, calculate ages etc.

Most difficult was to figure out how to sort recurring (yearly) events starting from “next upcoming” with single SQL query. But I think I figured it out by using one SQL query followed small php loop (which has worst case complexity of O(n)) to find the place to split an array 🙂

SELECT id, firstname, lastname, birthday,
(current_date - birthday - 1) as age,
substr(birthday, 9, 100) as day,
substr(birthday, 6, 2) as month
FROM Persons
ORDER BY month, day;

Hopefully I can get it ready enough at some point for sharing on Github. Something cool for the end: OpenAI has trained a model that can create new images – you just describe them in English. Mindblowing.