HEIF / HEIC images in Fedora 35

HEIF is a set of new image and video formats that are common on mobile phones but still not supported by default on most operating systems.

To get support for .heic on Fedora 35 you need to have the RPMFusion repository enabled, then run:

sudo dnf install -y libheif

If you’re using KDE then you’ll also need this:

sudo dnf install -y qt-heif-image-plugin

Not sure if you get the video formats along with these, I don’t have any videos in this format to test. If it works or if you know how to add the video formats please leave a comment telling me what’s needed and I’ll update the post.

Composer package development

When developing a composer package locally, you sometimes need to test the package in an actual project, if only to make sure that the package installs correctly. The package itself probably works fine (you write tests don’t you?) but adding it to another project may reveal issues or you simply need resources to be in place, e.g. when creating a Symfony Bundle. To set the development package up in your composer.json file add this:

Then once this is done you can do a composer require:

This will create a symlink in vendor/my to the directory set in the “url” and points to the branch name of your local repository.

Symfony 2.3 to 2.8, 502 Bad Gateway

I recently had a problem while upgrading a Symfony 2.3 project to 2.8. A lot of pages started giving me “502 Bad Gateway” errors for no obvious reason but only when being accessed through ngrok. After some searching and testing I noticed that if I turned off debugging things worked just fine. The dev.log was full of deprecation messages so I fixed a couple of them to make the log more readable. This surprisingly fixed some of the pages.

After even more digging I eventually came across this: https://github.com/Seldaek/monolog/issues/172

After some testing with both Chrome and Firefox I realized that the culprit was ngrok which seems to have a limit on response headers and with all the deprecation messages the application was overflowing that limit. Since my team isn’t using server side debugging with Chrome I disabled the chromephp and firephp log handlers in app/config/config_dev.php and everything started working again.

Variables in Apache’s conf files

Apache 2.4 added a seemingly little known feature, setting and using variables in config files. It took me some time to find any information about this but it is in the documentation. It’s simple enough to use, at the beginning of your file you define the variable with Define, then you can access it with ${variable}. An example:

Symfony 2 development on Fedora 21

There are some packages that are needed in PHP for developing Symfony 2 applications on Fedora 21.

To install what is needed:

This will resolve and install some dependencies such as php-xml and php-pdo. It will even install the apache webserver (httpd). MariaDB is installed by default in at least the KDE spin so there’s no need to install that specifically and php-mysql would resolve to install mariadb any way.

It’s also good to edit some .ini files after this. In /etc/php.ini it’s a good idea to set the timezone variable:

In /etc/php.d/15-xdebug.ini the following will help with debugging from NetBeans:

To simplify access to logs it could be an idea to run the httpd server as your own user, in /etc/httpd/conf/httpd.conf change the user setting, leave the group as is:

To start and enable the services needed:

 

Fedora 21 in VirtualBox

Just installed Fedora 21 as a guest on a Windows 7. Some weird problems getting everything to work but a couple of things to remember:

  • To get full screen working properly make sure you check “Auto resize Guest Display”, in the View menu of a running VM.
  • Chromium based browsers (Chrome, Opera and Vivaldi) have been having some problems with mouse integration in VirtualBox, at least on linux guests. A workaround is to disable mouse integration if you can’t select any text by dragging in one of these browsers (Host+I).

 

Legacy code in PHP

If you are a PHP programmer you have probably had your share of exposure to old spaghetti code that doesn’t seem to follow any rules or patterns other than “I need this now”. I’ve worked on several such projects and I wish I had had a resource like Paul M. Jones’ Modernizing Legacy Applications In PHP at my disposal when trying to get through the code in these projects. The book shows several simple steps to make sense of and clean up legacy code. It’s well worth the money if you haven’t gone through a major refactoring process on code that someone else has written.

Disclaimer: I’m in no way affiliated with the author or publisher other than being a happy customer.

Doctrine 2 and Symfony2, Using INDEX BY in Query Builder

It can be useful to get the resulting array from a query using the object id as key. This can be achieved in PDO by using the PDO::FETCH_NAMED and PDO::FETCH_NUM fetch styles and Doctrine offers this as well. When using the query builder all you have to do is to use the third parameter on the “from” part:

 

The third parameter to the ‘from’ method tells doctrine to use the id property on the User object as the array key when returning the results. In most cases you’ll want the indexBy column to have a unique constraint as the results may be unpredictable otherwise.