/r/PHP

Photograph via snooOG

Share and discover the latest news about the PHP ecosystem and its community.

Please respect r/php's rules.

Please follow the rules

Releases: Current Releases, Windows Releases, Old Releases

Contribute to the PHP Documentation

Related subreddits: CSS, JavaScript, Web Design, Wordpress, WebDev


/r/PHP is not a support subreddit. Please visit /r/phphelp for help, or visit StackOverflow.

/r/PHP

169,581 Subscribers

13

Catpaw v3

Hello r/PHP,

It's been a while.

I've been busy at work and I've also been working on some new features and improved type safety for catpaw.

The latest release is v3, you can find it here.

I'm implementing an idea I've had some time ago, which i think can pay off well when it comes to faster UI development in PHP.

I call this feature Superstyle... because it's just style sheets, but with super powers.

I'll try to explain myself.

I've always found it a bit awkward and slow to write html and markup separately.

I've recently realized, since CSS's new nesting features, that html itself might have become a bit redundant in most cases, if not all.

I know it's a bold claim, but hear me out.

HTML is a declarative domain specific language that we use to describe our DOM tree, it doesn't do much more than that, and that's why it is great, it just does one thing and it does it well.

<div class="container">
    <span class="info">Some text</span>
</div>

But of course I'm not saying anything new here.

Whenever we want to give our document some style we use CSS, another domain specific language.

But I've wondered if CSS can actually also describe a DOM tree by itself... and I think it can.

div.container {
    /* Some css rules */
    span.info {
        /* More css rules */
        content: "Some text";
    }
}

Does the structure look familiar?

It technically describes the same tree as the HTML example above: a div with a "container" class, which contains a span with an "info" class and the text "Some text".

Well that's what Superstyle is, a feature that takes CSS content in and outputs the same CSS content and its HTML representation, with some optimizations added.

But what could the advantage be?

For starters I believe it to be less redundant, I can describe both the style of the document and the document itself at the same time.

There is potential for more advanced syntax in the future.

And third, I think it encourages more usage of CSS and less usage of JS, which in my book is a good thing.

That's all I've got for now.

Optimizations and improvements will come in the near future, in the mean time it would be nice to get some thoughts, possibly on the github discussion https://github.com/tncrazvan/catpaw/discussions/5.

Documentation and example can be found here.

Have a nice day.

6 Comments
2024/05/07
21:19 UTC

0

Laravel API with multiple tenants and mobile clients: JWTs vs sessions?

Hey, we have PHP-based app with React web app and Android client. Our app is using JWTs right now, but it's a bit messy implementation and we want to refactor it or even totally switch to sessions

Why? Because few factors which are difficult on JWTs:

  • App is multi-tenant i.e. user can belong to multiple groups, then send request to endpoints like api.service/{tenant_id}/payment - we use httpOnly, secure cookies to store tokens/jwt, so they are totally invisible for app. User should be able to login into multiple tenants at the same time and right now it's problematic, because we have only one cookie for that. Mobile apps use Bearer token, but web app can use only these cookies so it's real problem. With session, we can control that on server level

  • Performance is often argument for JWTs, but we want to utilize redis to store sessions + also app is something like modular monolith, it's gateway for everything, so we do not utilize JWT advantages like easy access to multiple distributed services

  • Revocation: tenant admin should have ability to quicky remove access for specific users and with JWTs it's harder. We can use blacklist, also on redis, but it means every request we need to validate this... looks like very similar to session operation - but maybe I am wrong?

  • Overall in each connection app must get some users data, so even if we have JWT, we still need to call DB... and each request make a lot of them, so it does not look like a big issue with just additional redis call

  • Handling session can be much simpler than adding generating tokens, refreshing etc. - ok, there are some great libs for that, but sessions are still just native

I'm not sure, but looks like in our case sessions will be the best, but maybe I've missed something and should include that? Any feedback is really welcome!

13 Comments
2024/05/06
17:32 UTC

70

Pitch Your Project 🐘

This is a new experiment, thanks /u/colshrapnel for suggesting it!

In this thread you can share whatever code or projects you're working on, ask for reviews, get people's input and general thoughts, … anything goes as long as it's PHP related.

Let's make this a place where people are encouraged to share their work, and where we can learn from each other 😁

PS: if this thread performs well, we could make it a monthly thing. Feel free to suggest betters titles if you want to as well :)

62 Comments
2024/05/06
08:01 UTC

6

Weekly help thread

Hey there!

This subreddit isn't meant for help threads, though there's one exception to the rule: in this thread you can ask anything you want PHP related, someone will probably be able to help you out!

12 Comments
2024/05/06
06:00 UTC

35

Appreciation - The PHP community is great

5 Comments
2024/05/05
21:13 UTC

18

Any companies in Canada that hire PHP (Core) or Laravel/CodeIgniter Devs?

I have been looking for a month and a half, but no luck. And it seems like as a newcomer especially I am not being considered because of my lack of experience in Canada. If anyone knows of any leads in Ontario that are looking for devs that have PHP, JavaScript, jQuery, Laravel and CodeIgniter experience, please reach out. I have 4 years of experience.

I am also looking for any meetups in Toronto that might help me make connections.

Thanks!

17 Comments
2024/05/05
18:42 UTC

285

The Surprising Shift in PHP Developer Skills

Hey,

I've been conducting interviews for a Senior PHP Developer position at my company, and I've encountered something quite surprising. Out of the candidates I interviewed, nearly 90% predominantly have experience with Laravel, often to the exclusion of native PHP skills.

For instance, when asked about something as fundamental as $_SERVER['REMOTE_ADDR'],a basic PHP server variable that provides the IP address of the requesting client, most candidates could only relate to how such information is handled in Laravel, without understanding the native PHP underpinnings.

Moreover, when discussing key security concepts such as CSRF, XSS, and SQL Injection protections, the responses were primarily focused on Laravel's built-in functions and middleware. There was a noticeable lack of understanding about how these security measures are implemented at the PHP level, or why they are necessary beyond the framework's abstraction.

Are modern PHP frameworks like Laravel making developers too reliant on built-in solutions, to the point where they lose touch with the foundational PHP skills? This could have implications for troubleshooting, optimizing, and understanding the deeper mechanics of web applications.

BTW: we are still looking for Sr php Developers (remote) , if you are interested DM me.

215 Comments
2024/05/04
19:54 UTC

0

Contributing to PHP

Hey everyone, hope you all are doing great.

I have been developing with core PHP and Laravel for a reasonable time and I am pretty confident about contributing to PHP and to the Laravel ecosystem as a whole. I need guidance about contributing on where to start or Laravel is even good for beginners to contribute. any help would be appreciated.

Thanks and Regards.

4 Comments
2024/05/04
13:18 UTC

25

Vite integration for PHP

Why was there no Vite integration for PHP?

The only ones I could find were tied to a framework.

So I went ahead and built one. :-)

https://github.com/mindplay-dk/php-vite

It's in a pre release state, but it's quite well documented and there's a working MPA example project you can try.

Thoughts? :-)

16 Comments
2024/05/04
12:35 UTC

25

Where did krakjoe dissappear?

He used to be an active contributor to PHP. Then got health problems a year ago.

Now his websites are down.

4 Comments
2024/05/03
23:06 UTC

5

Go to client portal framework?

What are you guys going to for the beginning of a client portal that has registration, updating profile, email password reminder, user deletion, etc and then you add tabs and the necessary additional content.

6 Comments
2024/05/03
21:09 UTC

0

Laravel Testing with CodiumAI IDE Extension

The article highlights the importance of testing in Laravel development for ensuring application functionality and stability, discussing different test types like unit, feature, browser, and API tests.

It also introduces the CodiumAI IDE Extension, as a tool designed to streamline the Laravel testing process by offering automatic test generation, customization options, and advanced capabilities like sub-behaviors and data-driven testing.

4 Comments
2024/05/03
07:02 UTC

0

Magic methods

Does each magic method exists in the any class? For example __construct(){}. Does it exists in the class Foo {} or in the (object)[] ?

5 Comments
2024/05/02
23:07 UTC

3

Who migrate codebase from zend framework?

Tell us about your pain.

what was your plan? what solutions did you choose? what problems did you encounter?

Let’s discuss about it

27 Comments
2024/05/02
10:01 UTC

10

Check PHP code efficiency

Hi guys, can I ask which methods are you using to ensure that your code is the most efficient/optimized way to use? like which code is more faster or which code consumes the least memory, I want to check my code since I am only focused to make it work. thank you in advance.

29 Comments
2024/05/01
12:52 UTC

14

Semi-Scripted Conversational Applications with PHP

Even a few years ago, the quality of technology wasn't there to allow us to build conversational applications.

Today, we can mix and match programming language with AI input and decision-making to create conversational applications that range from semi-scripted to completely reliant on AI. We can also adjust the amount of control we want to cede to LLMs, which makes our work really flexible.

On the other note - thank you all for your continuous support! Recently, PHP Resonance managed to hit 100 stars on GitHub. It might not be much in general terms, but it is an important milestone for me. :)

The big reason I keep working on integrating LLMs and AI with PHP in general and also releasing the Resonance is that I truly believe in PHP's potential—both as a communication hub that integrates all the web-adjacent technologies and as one of the most efficient tools to serve them. Thanks for being here!

https://resonance.distantmagic.com/tutorials/semi-scripted-conversational-applications/

1 Comment
2024/05/01
02:10 UTC

11

php-wcli: Windows console native support for PHP 8.3

Hello, I created a PHP extension for Windows console native support.

Take a look and try.
https://github.com/ZmotriN/php-wcli

Suggestions?

12 Comments
2024/05/01
01:14 UTC

5

Recommendations On error Logging

In js there is an onerror event, I like to setup a function to write errors to the db. I know there’s set_error_handler and register_shutdown_function. I never got either working properly, any tips? I’d like to write server errors to the db too.

10 Comments
2024/05/01
00:36 UTC

11

Updating Legacy Code to PHP 8

I recently updated a very old code base to PHP 8.

There were a lot of false starts but finally found a process that worked for me.

There is no doubt many ways to make this transition, but this is the way I was successful in making the transition

I hope this might help others who have also been trying to update their code base.

https://dev.to/mrpercival/updating-legacy-code-to-php-8x-2jg1

5 Comments
2024/04/30
23:02 UTC

27

Livestream with Larry Garfield to talk about Property Hooks — starts in 15 minutes

10 Comments
2024/04/30
17:45 UTC

53

PHP 8.1 EOL has changed?

Hello PHP'ers

I had in my head that 8.1 goes EOL in November and this is confirmed by both PHP Watch and End of Life.date. However, checking on https://www.php.net/supported-versions.php today, this is listing security support until November 2025.

I'm thinking that PHP.net is correct but wonder if this has changed recently? Anyone know?

(Edit for broken link)

27 Comments
2024/04/30
15:43 UTC

18

How do you provision servers for PHP?

Hey, I usually set up one or two servers per year, but every time I did, I thought about how to automatize it. I used Laravel Forge years ago, but it isn't viable for my side projects. Today, I have a Notion page where I have the common process I follow to provision a server manually, but it is boring... I've tried Deployer, but the provisioning task fails, and it uses Caddy when I prefer Ningx. So, I'm thinking of creating my own Deployer tasks. What do you use for provision servers?

Note: I don't want to use Docker; it is helpful for some scenarios, but it isn't the case.

89 Comments
2024/04/29
12:04 UTC

Back To Top