@ollieread@phpc.social avatar

ollieread

@ollieread@phpc.social

I'm Ollie, and I write PHP content and open-source code when i'm not working as a PHP contractor.

Big Laravel fan!

Multitenancy is my thing; ask me about it.

This profile is from a federated server and may be incomplete. Browse more on the original instance.

ramsey, to Kubernetes
@ramsey@phpc.social avatar

I’m interested in running (i.e., ) as the app server for a website. The website has multiple domains pointing to it, and I plan to run this in a cluster. Can someone point to any docs or blog posts that show how others have set up similar configurations with Caddy or FrankenPHP, especially with regard to how Caddy magically configures HTTPS for the domains in this kind of setup?

ollieread,
@ollieread@phpc.social avatar

@ramsey rather you than me 😂

ollieread,
@ollieread@phpc.social avatar

@ramsey I'm afraid I can't offer any pointers or direction, but I'd just like to let you know that you have my most heartfelt condolences that this is a thing you have to experience. Best of luck!

ollieread, to random
@ollieread@phpc.social avatar

I know the convention is for singletons to have an "instance" method, but I quite like the idea of a "get" method.

Though I suppose as a convention it can be an issue, as a class is more likely to have a get method as standard.

ollieread,
@ollieread@phpc.social avatar

@andrewfeeney I quite like that 😂

ollieread,
@ollieread@phpc.social avatar

@bobmagicii Fair. That's some...interesting formatting there 😂

ollieread,
@ollieread@phpc.social avatar

@bobmagicii what if the class in question is a multiton with a single optional string parameter

ollieread, to php
@ollieread@phpc.social avatar

So, I’m building a dependency-injection package, and it’s a lot of fun. I’ve gone a route that I don’t really see many, if any, following. I suspect it may be that a lot of the solutions out there are old, and while they have been updated, they’re still going to inherit certain approaches.

ollieread,
@ollieread@phpc.social avatar

@ramsey I happen to already have an example screenshot for this!

ollieread,
@ollieread@phpc.social avatar

@ramsey Ah, I'm doing something very similar, except I only allow bindings based on actual classes.

I also have named bindings, where you can bind more than one concrete to an abstract, but all but a default is specified by "name". You can also optionally have a discriminator attribute, which is typically just a wrapper for the named attribute with a particular attribute.

ollieread,
@ollieread@phpc.social avatar

@Crell It's not that interesting really. It's mostly utilising attributes, and fluent builders, rather than having one gigantic mammoth container class.

ollieread,
@ollieread@phpc.social avatar

@ramsey And I also have qualified attributes. Essentially, you register a custom resolver, and an attribute. If a dependency has that attribute, the custom resolver is used.

A good example would be a built in one I have called DataStore, which is a key value store for primitives. Would also work with things like Laravel databases, where you'd use #[Database('mysql')], and it'd do the equivalent of Database::connection('mysql').

ollieread,
@ollieread@phpc.social avatar

@ramsey There are also a number of others, like the Shared, Provider, Scope, and Factory attributes.

ollieread,
@ollieread@phpc.social avatar

@ramsey I now fear that I may have made it sound more interesting than it actually is 😅

The big one, really, is that I'm utilising many attributes (and I may or may not have stolen the idea for some from Java Guice).

That, and rather than a container doing everything, I have specialised fluent builders, where things are somewhat separated.

ctietze, to php
@ctietze@mastodon.social avatar

A question for more experienced #PHP developers than me:

We have this setup where all requests go through a PHP script for authorization (think: cookie) checking before serving files.

That's fine with HTML, but less ideal for 5MB PDFs.

I'm trying to search for ways to use PHP to allow/deny access, but otherwise let the web server (Apache) do its job.

Is there such a facility to rewrite requests for auth, but then go on serve the static files?

ollieread,
@ollieread@phpc.social avatar

@ctietze not sure about Apache, but if switching to Nginx is an option, it supports auth subrequests. I don't know if there's a way to do it with Apache.

https://docs.nginx.com/nginx/admin-guide/security-controls/configuring-subrequest-authentication/#

ollieread, to php
@ollieread@phpc.social avatar

I need to remember that Mastodon exists! I’m currently writing a bunch of content to do with PHP and this would be the perfect place to talk about that.

I’m currently trying to decide whether #php #reflection is an interesting enough topic that people may like an in-depth course/series on it. It seems to be something a lot of people are vaguely aware of, but don’t really know the details.

ollieread,
@ollieread@phpc.social avatar

@alessandrolai I think it could be achieved without venturing into implementation.

It's super rough (I threw it together in the last 5–10 minutes), but here's a write-up that hopefully explains enough of it. It's concept I was going to explore anyway.

https://gist.github.com/ollieread/144840c92e6829e07134c17b28878510

ollieread,
@ollieread@phpc.social avatar

@alessandrolai interestingly, the container PSR is the one that I think is the most limiting, or needs improvement. Honestly, I'd probably create a dependency injection PSR that utilises it but adds some base indication for more advanced features, as well as some attributes for utilisation.

I think attributes are the future of PSRs as they'll let you hook into WAY more systems without making those systems adhere to specific contracts.

ollieread,
@ollieread@phpc.social avatar

@alessandrolai thanks.

It's interesting that you should mention modern PHP and PSRs, as I've long held that some of those could do with being updated, as I think they're bit a limiting at present. (also I think some of them could be improved) 😅

ollieread,
@ollieread@phpc.social avatar

In fact, this is my first draft of the article on covariance and contravariance as concepts but also related to .

I've tried to go for simple, without too many details, but I think this contains the fewest number of details I'm capable of writing 😂

https://gist.github.com/ollieread/273cf344503533ee4c497ab4c62929bf

ollieread,
@ollieread@phpc.social avatar

I’ve also been trying to put together some content that’s more beginner friendly, by researching frequently searched queries on Google.

These are the ones I have so far.

ollieread,
@ollieread@phpc.social avatar

@grmpyprogrammer well it definitely seems to be something people are interested in, and doesn't seem to be covered anywhere else. Not to any decent degree either, so maybe I will.

luis_in_brief, to random
@luis_in_brief@social.coop avatar

I feel like a spammer for showing up so many places in the past 24 hours and saying “yo, the thing you say no one has built: we’ve built it, it’s right here, we’re paying maintainers every month”.

Tidelift isn’t perfect but it is real and targeting exactly these kinds of problems.

https://social.coop/

ollieread,
@ollieread@phpc.social avatar

@ramsey @luis_in_brief this is so true 🥲

I’m on the verge of switching to something that could get me a proper competitive salary, or preferably, contracts. The only reason I haven’t is the whole “experience” aspect. Not a lot of people will care about your general knowledge if you don’t have X years of experience in the specific thing 😅

AstraKernel, to php

PHP conductor 😂

ollieread,
@ollieread@phpc.social avatar
ollieread, to random
@ollieread@phpc.social avatar

Hmm, the Mastodon web app doesn't have support for easy account switching 😅

ollieread, to random
@ollieread@phpc.social avatar

I ended up going with the standard ::instance() approach 😂

It'll get complicated soon when I allow for containers to be scoped, but, we'll see.

https://gist.github.com/ollieread/58203d66276d863d1df5f40b8a27cae0

  • All
  • Subscribed
  • Moderated
  • Favorites
  • megavids
  • thenastyranch
  • rosin
  • GTA5RPClips
  • osvaldo12
  • love
  • Youngstown
  • slotface
  • khanakhh
  • everett
  • kavyap
  • mdbf
  • DreamBathrooms
  • ngwrru68w68
  • provamag3
  • magazineikmin
  • InstantRegret
  • normalnudes
  • tacticalgear
  • cubers
  • ethstaker
  • modclub
  • cisconetworking
  • Durango
  • anitta
  • Leos
  • tester
  • JUstTest
  • All magazines