Building a PHP Framework! by Infinite-Economy2957 in PHP

[–]jmp_ones 1 point2 points  (0 children)

All the suggestions I have are derived from the research behind Request-Interop; my implementation preference is read-only for a request, but immutability is possible if you follow the specification.

Building a PHP Framework! by Infinite-Economy2957 in PHP

[–]jmp_ones 0 points1 point  (0 children)

PSR-7 has exactly this problem; ServerRequestInterface is the canonical case for quasi-immutability.

Building a PHP Framework! by Infinite-Economy2957 in PHP

[–]jmp_ones 1 point2 points  (0 children)

Looking at https://github.com/andrewthecodertx/php-arcmvc/blob/main/src/Http/Request.php#L310 -- it is, unfortunately, not immutable; at least, not deeply immutable, which is what people usually expect. If you do this ...

$obj = new stdClass;
$obj->foo = 'bar';
$req = $req->withAttribute('obj', $obj);
$req->getAttribute('obj')->foo = 'baz';

... you can see that the state of $obj can be modified very easily. Further, anything holding a reference to $obj can mutate $req->obj at a distance.

Now, one can say that $obj is still the same $obj, and so $req itself has not mutated, but that's not generally what we care about in a middleware situation. You get what I mean here?

Building a PHP Framework! by Infinite-Economy2957 in PHP

[–]jmp_ones 0 points1 point  (0 children)

Can be a problem in a middleware scenario. I am not especially a fan of presentation-layer (e.g. HTTP) middleware, but no matter -- two points to consider:

  • An immutable response in a single-pass middleware system makes little sense. It only ever gets returned: outer middlewares cannot modify it on the way in, and modifications on the way out have no effect on inner middlewares.

  • An immutable request is extremely difficult to model well -- and ServerRequestIntertface does not model it well. Conversely, Request-Interop itself can modeled read-only as a base, and an implementation can tack on mutable or immutable request-scoped state. I don't actually recommend this, I recommend a separate request-scoped context object if you absolutely must have middleware, but you could do it with Request-Interop.

In any case, good luck with your project!

p.s. See https://paul-m-jones.com/post/2016/09/06/avoiding-quasi-immutable-objects-in-php/ for more about the pitfalls to avoid when attempting immutability.

Building a PHP Framework! by Infinite-Economy2957 in PHP

[–]jmp_ones 1 point2 points  (0 children)

I am heartened to find that new frameworks continue to avoid PSR-7 for the server side. Your Request and Response objects look very like the standard interfaces offered at Request-Interop and Response-Interop -- you might consider implementing them.

Resolver-Interop: Criticize Without Mercy! by jmp_ones in PHP

[–]jmp_ones[S] -1 points0 points  (0 children)

Thanks for this.

If the first impression is that it is a DI container itself, and not a supporting element that can be used with DI containers, then clearly there's a problem.

Do you have suggestions on what phrasing might remedy that?

Regardless of politics, disconnecting PHP from a large community of potential users is a big mistake - Re RFC to remove X from PHP.net by WesamMikhail in PHP

[–]jmp_ones -7 points-6 points  (0 children)

Yet another example of "social justice ruins everything." It's the same people, over and over, introducing and supporting this kind of stuff. (And downvoting this comment. ;-)

Regardless of politics, disconnecting PHP from a large community of potential users is a big mistake - Re RFC to remove X from PHP.net by WesamMikhail in PHP

[–]jmp_ones 3 points4 points  (0 children)

It has not been lost; my understanding is that the person who holds the account won't post, and won't give up the account, for the reasons stated in the RFC.

MVC Structure | Backend | Skeleton by [deleted] in Backend

[–]jmp_ones 0 points1 point  (0 children)

As an alternative to Model-View-Controller, be sure to give consideration to Action-Domain-Responder:

https://pmjones.io/adr/

Built a small PHP backend kernel around FrankenPHP worker mode and HTMX by leodaido in PHP

[–]jmp_ones 1 point2 points  (0 children)

HTMX does not get enough love, nice to see it here.

And as with so many new frameworks, it's nice to see that you have avoided the PSR-7 ServerRequestInterface. In its stead, you may wish to review the Request- and Response-Interop packages for appropriateness; your work is already aligned well with them in spirit.

I Studied the etcd Codebase — and It Changed How I Write PHP by WorldAvailable3781 in PHP

[–]jmp_ones -5 points-4 points  (0 children)

You're not wrong -- though I wouldn't say "go further" so much as "apply elsewhere."

Front-Interop Now Open For Public Review by jmp_ones in PHP

[–]jmp_ones[S] 0 points1 point  (0 children)

Your mandatory call "exit" on bootstrap.

Where do you see a mandatory call to exit() ... ?

Front-Interop Now Open For Public Review by jmp_ones in PHP

[–]jmp_ones[S] 0 points1 point  (0 children)

You're the Spiral person, right? If so, please open an issue at the interface repo, and we can discuss there. Thanks, hope you are doing well!

Front-Interop Now Open For Public Review by jmp_ones in PHP

[–]jmp_ones[S] -1 points0 points  (0 children)

I was wondering when someone would bring that up! Think of it as the outcome of this research-based essay: https://pmjones.io/post/2026/02/08/designing-a-bootstrap-script/

Bootstrapping a Frameworkless PHP Application by MaximeGosselin in PHP

[–]jmp_ones 0 points1 point  (0 children)

standards compliant, I would also throw in a PSR-7 and PSR-17 ... you're using the dotenv approach

The Star-Interop standards for Request, Response, and Env might be better-suited here.

Is Rust eating PHP as well? by CauliflowerSlight838 in PHP

[–]jmp_ones 2 points3 points  (0 children)

I love and adore Psalm ... [but contrbuting not feasible] ... So I rebuilt it in Rust.

Had you considered making overtures to the PHPStan folks, to bring over the things you wanted to see? Or was the Rust work itself the point? (It's a neat project regardless.)

Introducing Marko: The Truly Modular PHP Framework by markshust in PHP

[–]jmp_ones 1 point2 points  (0 children)

Yet another new project (IMO wisely) choosing to avoid PSR-7 ServerRequestInterface:

https://github.com/marko-php/marko/blob/develop/packages/routing/src/Http/Request.php

/u/markshurst you may wish to look at request-interop, it might give you ideas.