mastodon.cc is one of the many independent Mastodon servers you can use to participate in the fediverse.
Mastodon for Art

Administered by:

Server stats:

58
active users

#php

16 posts16 participants1 post today

#ThingsILearned at #InternetArchive: We have our own task queuing system. Like Celery or Amazon SQS but written in #PHP at least a decade before any of those. It has recently handled its task number 5 billion.

When you upload a file, the task system (called "catalog") will generate derivative formats, like OCRing books or transcoding videos. Some tasks have taken months to run end-on-end.

so this would probably be a very bad idea, but gonna ask anyways...

I don't understand why something like this is not possible with #php property hooks

the `set` hook accepts `null` and I would expect the argument to be handled there before actually setting hitting the constructor's argument

WYT ?

A Self-Hosted Favicon Proxy written in PHP

shkspr.mobi/blog/2025/10/a-sel

In theory, you should be able to get the base favicon of any domain by calling /favicon.ico - but the reality is somewhat more complex than that. Plenty of sites use a wide variety of semi-standardised images which are usually only discoverable from the site's HTML.

There are several services which allow you to get favicons based on a domain. But they all have their problems.

  • Google
    • Exposes your user's to Google's tracking.
    • Relies on redirects.
  • DuckDuckGo
    • Not officially supported by DDG.
  • Favicon.is
    • No privacy policy whatsoever.
  • Icons.horse
    • Paid service.
    • Only small size icons.
  • Favicone
    • No privacy policy.
    • Only small size icons.

I want to show favicons next to specific links, but I don't want to expose my visitors to unnecessary tracking. How can I proxy these images so they are stored and served locally?

There are a few existing services. Some use Cloudflare workers or other cloud services, there are some local-first ones which are unmaintained. But nothing modern, self-hosted, and as easy to deploy as uploading a single PHP file.

So here's my attempt to make something which will preserve user privacy, be reasonably fast, and have moderately up-to-date icons, while remaining fast and efficient.

  • Table of Contents

  • Getting the domain
  • Getting the image
  • Getting the structure right
  • Preventing abuse
  • Putting it all together
  • Getting the domain

    Assuming the request comes in to https://proxy.example.com/?domain=bbc.co.uk

    PHP has a handy FILTER_VALIDATE_DOMAIN filter which will determine if the string is a domain.

    filter_var( $domain, FILTER_VALIDATE_DOMAIN, FILTER_FLAG_HOSTNAME );

    Dealing with IDNs

    Some domains contain non-ASCII characters - for example https://莎士比亚.org/ - not all favicon services support International Domain Names.

    Using the idn_to_ascii() function, it is possible to get the Punycode domain.

    $domain = idn_to_ascii("莎士比亚.org");

    Getting the image

    1. Check if the icon has previously been downloaded.
    2. Rotate randomly between a few different Favicon services.
    3. Download the icon.
    4. Save it somewhere.

    Getting the structure right

    I know from my work on OpenBenches that storing tens of thousands of files in a single directory can be problematic. So I'll store the retrieved favicon in: /tld/domain/subdomain/

    That will make it quick to see if an icon exists. I'll save the file with a filename based on the current timestamp. That will allow me to check if an icon is out of date, and will prevent people downloading the icons directly from me.

    Preventing abuse

    I don't want anyone but visitors to my site to be able to use this service. So I'll add a (weak) check to see if the request came from my domain.

    $referer = parse_url( $_SERVER["HTTP_REFERER"], PHP_URL_HOST );if ( $referer == "shkspr.mobi") {   …}

    Some browsers may not send referers for privacy reasons. So they won't see the favicons. But they probably wouldn't have seen the images loaded from a 3rd party service. So I'll serve a default image.

    Putting it all together

    You can grab the code from my personal git service.

    The PHP logo.
    Terence Eden’s Blog · A Self-Hosted Favicon Proxy written in PHP
    More from Terence Eden
    #favicon#HowTo#HTML

    🆕 blog! “A Self-Hosted Favicon Proxy written in PHP”

    In theory, you should be able to get the base favicon of any domain by calling /favicon.ico - but the reality is somewhat more complex than that. Plenty of sites use a wide variety of semi-standardised images which are usually only discoverable from the site's HTML.

    There are several services which allow you to …

    👀 Read more: shkspr.mobi/blog/2025/10/a-sel

    #favicon #HowTo #HTML #php

    The PHP logo.
    Terence Eden’s Blog · A Self-Hosted Favicon Proxy written in PHP
    More from Terence Eden

    👋 Hello Fediverse!
    I’m Toby – on the web since 1996, at home in #PHP since 2000.
    Co-founder of Qafoo & Frontastic (acquired by commercetools in 2021), where I worked as a Principal Engineer.

    I speak openly about my mental health and do #MentalHealth advocacy in the tech scene.

    Currently on a sabbatical, loving family life, fantasy & sci-fi, hiking & sauna time.

    More about me: schlitt.info
    #introduction

    schlitt.infoTobias Schlitt - where inclusion meets solutionExplore the world of Tobias Schlitt, a seasoned software engineer with over 25 years of experience in creating complex web applications and fostering inclusive work environments. Dive into his blog for insights on technology, remote work, and mental health advocacy. Discover how inclusivity and solution-oriented approaches drive his professional life."

    FrankenPHP permet de créer des extensions #PHP en Go. Grâce à quelques fonctions et son générateur d’extensions, on peut désormais créer une extension PHP sans écrire une seule ligne de C. Découvrez avec Alexandre Daubois le cheminement vers cette nouveauté 👇 les-tilleuls.coop/blog/des-ext

    Les-Tilleuls.coopDes extensions PHP en Go avec FrankenPHP | Les-Tilleuls.coopDécouvrez, avec Alexandre Daubois, comment créer des extensions PHP avec le langage Go grâce à FrankenPHP.

    I took the time to update packagist.org/packages/stella- to the latest version of the NIST specs regarding passwords. It's now also tested on PHP8.1 through PHP8.5

    If you are looking for a library to make sure your passwords are compliant to the latest security rules, this might be for you.

    Feel free to open an issue when you're missing something.

    packagist.orgstella-maris/nist-password - PackagistHandle password according to the NIST

    📝 Evolving my personal music scrobbler #Plexamp #Musicbrainz #Music #Php #Jellyfin #Navidrome #Laravel

    I've nearly entirely rewritten my site over the past few months. First, I refactored the frontend into a Laravel application that leveraged the same postgREST endpoints that my long-running 11ty site used. Next, I wrote a new administrative application in Filament and migrated off of Directus. If I did this right, the...

    coryd.dev/posts/2025/evolving-

    Cory DransfeldtEvolving my personal music scrobblerBy Cory Dransfeldt