Skip to content

u/borsnor

In this archive from Dec 2012 to Oct 2026

4
posts
51
comments
1
media
79
score

We opted for Docker inside WSL. Even though production is not running Docker yet. It's our goal eventually. We want to be able to spin up containers for jobs, consumers, and fpm, all on different droplets (digitalocean). We're not quite there yet due to legacy infrastructure. But I feel like we'll never get there if we don't give it any thought at all.

1 points

Caddy for tls termination and proxy to fpm and varnish for caching, seperate droplets on digitalocean. Managed MySQL and redis from digitalocean. Digitalocean spaces as an S3 compatible storage and CDN solution. Bugsnag and newrelic for error reporting and monitoring. Whole range of api, website, backoffice and mobile apps runs on it all. I'm the only person managing it all for my customer

1 points

That's also possible, though with containers there might be some caveats. They have a remote binary now a days which the IDE can copy via ssh and run to do remote development if I understood it correct.

1 points

I am not sure what you mean? I develop using Docker containers all the time and it works perfectly fine in PHPStorm. Same for "remote" in WSL, also no issues. I even run containers on WSL as well.

3 points

I use systemd service template files for rabbitmq consumers and symfony messenger processes. Needing only two files to run and manage 10 different processes is quite nice.

But we have over 20+ different cronjobs (console commands) which all need a lot of different arguments. Service template files just won't cut it there. Crontab is a hell of a lot easier to manage in this regard.

2 points

While there definitely is room for fp in php, in my experience and opinion, php is not a language that serves fp in a great way. There is no signature overloading for starters, which I always found a blessing for fp. There are languages much better suited for full on fp. Erlang comes to mind (or elixer now a days). Scala/Haskell, etc. Php has made many great improvements for oop since it's 5.x days though.

1 points

You mean alcohol, not ethanol, which is me. I just thought I would share this gem. The joys of maintaining open source software and all that.

3 points

Yes except that in this case, you would depend on an interface definition only. Like I said, the user picks the client implementation. In other words, the actual client implementation is never a direct dependency of your library. Only the interface definition is. Client implementations must be explicitly chosen and composer required/downloaded by the user.

1 points

Possible source of vulnerabilities after v1.0.0 is tagged, which means paying money out in our bug bounty program for no real win

Why would you have to pay for possible bugs in dependency libraries? The benefit of using for example httplug is that the user can inject the client implementation they want to use. This also means the user is fully responsible for said client.

1 points

Cannot reproduce;

rob /tmp > cat script.php
<?php

$times = 1000;
$ids = [];
for ($i = 1; $i <= $times; $i++) {
    $newId = uniqid();
    $ids[] = $newId;
}

var_dump(count(array_unique($ids)));

Consistently produces (and that's not even using true for the $more_entropy argument):

rob /tmp > for i in {1..100}; do php script.php; done
/tmp/script.php:10:
int(1000)
...
/tmp/script.php:10:
int(1000)
1 points

I think some people are missing the point a bit.

Adding Composer dependency management and autoloading to legacy applications is often seen as an impossible task, not worth the effort. But this is definitely not the case, or least it has not been in my experience, and I have gone through the same-ish story several times on several projects at clients.

While it may not immediately bring your application from the 90's back into the 21st century, it does make it easier to gradually improve it.

Sharing "success" stories like these helps serve as a reminder that it is definitely possible :-)

2 points

Seems you are right. Not sure why. I just scribbled this up quickly. Will have a peek later :-)

Edit: took a quick stab at it. Seems that it simply doesn't play nice with a weight of 1. If you use 0, 10, 10, 10 for example, it will distribute much more evenly. Not sure why..

See: https://3v4l.org/r5g49

2 points

Something like..

/**
 * @param array $items
 * @param array $weights
 *
 * @return mixed
 */
function random_weighted(array $items, array $weights) {
    $weight = 0;
    $return = current($items);

    for ($i = 0, $n = count($items); $i < $n; ++$i) {
        $random = mt_rand(0, $weights[$i] + $weight);

        if ($random >= $weight) {
            $return = $items[$i];
        }

        $weight += $weights[$i];
    }

    return $return;
}        
1 points

Keyboard shortcuts

Move and act

jork
Next / previous post or comment
Enteroro
Open the post
f
Open the media viewer
s
Save
h
Hide (the toast has Undo)
Tab
Right after an action: the toast's Undo
x
Collapse the comment
v
Next layout: cards, compact, grid

Go to

/
Search
gthenh
Home
gthena
All
gthens
Subreddits
gthenl
Library
?
This list
Esc
Close a menu or this list

In the viewer

←or→
Previous / next file
↑or↓
Previous / next post
korj
Previous / next post
Space
Play / pause
m
Mute
z
Zoom
s
Save
o
Open the post (on its own page: back to it)
Esc
Close

Keys do nothing while you type in a box.