PHP Reddit – Telegram
PHP Reddit
34 subscribers
289 photos
37 videos
24.8K links
Channel to sync with /r/PHP /r/Laravel /r/Symfony. Powered by awesome @r_channels and @reddit2telegram
Download Telegram
I was just chilling and built a Go wrapper for Laravel queue worker that's 21x faster

So I was bored last weekend and got curious about why php artisan queue:work feels slow sometimes. Instead of doing something productive, I decided to mess around with Go (still learning go) and see if I could make it faster.

What I built:

Go program that manages multiple persistent PHP processes (sub workers spawned by go)
Each PHP process runs a custom Laravel command that accepts jobs via stdin
Go handles job distribution and coordination
Basically Go babysits PHP workers lol

The results were... unexpected:

1k jobs:

Normal Laravel worker: 14 seconds
My janky Go thing: 1.3 seconds

10k jobs:

Normal Laravel: 2+ minutes
Go with 6 PHP workers: 6.4 seconds

Some notes:

This is NOT production ready (missing error handling, proper shutdown, etc.)
I didn't measure CPU/memory usage so who knows if it's actually better resource wise
Definitely not trying to replace Laravel's queue system
Just a "what if" experiment that got out of hand
Communicate with two programming languages (PHP and GO) without barriers .
Maybe i did mistakes in code just correct me , I'm just learning go .

REPO : https://github.com/LAGGOUNE-Walid/laravel-queue-worker-in-go

https://redd.it/1nsteuk
@r_php
Weekly /r/Laravel Help Thread

Ask your Laravel help questions here. To improve your chances of getting an answer from the community, here are some tips:

What steps have you taken so far?
What have you tried from the documentation?
Did you provide any error messages you are getting?
Are you able to provide instructions to replicate the issue?
Did you provide a code example?
Please don't post a screenshot of your code. Use the code block in the Reddit text editor and ensure it's formatted correctly.

For more immediate support, you can ask in the official Laravel Discord.

Thanks and welcome to the r/Laravel community!

https://redd.it/1nsth3a
@r_php
Weekly Ask Anything Thread

Feel free to ask any questions you think may not warrant a post. Asking for help here is also fine.

https://redd.it/1nt7i7r
@r_php
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!

https://redd.it/1ntad7n
@r_php
Commands and Jobs

Hi everyone,

Imagine the scenario:

User has a button that will perform a heavy lifting task. My approach ? Create a Job for this.

This task will also have a schedule command because needs to run everyday for each client that we have. Business logic for this task is on a service. Should i call on the command the service function or dispatch the job?

Thanks

https://redd.it/1ntp6ap
@r_php
A new PHP Job Board

# I launched a new PHP Job Board for high quality PHP Jobs. Recruiters and Developers do consider joining. First 100 verified recruiters get to post a job for free!

https://redd.it/1nu7yow
@r_php
Where can I find a collection of custom built PHP functions?

I know PHP alone has so many built-in functions, but I wonder if there are free custom built-in PHP functions for any web app to use.
When I do search on Google I have found only for WordPress.

Eg, in my web app the below code is used to truncate a long string and add ....
function cutString($cutString, $numberToCut){

if(mb_strlen($cutString, 'UTF-8') > $numberToCut){ // If the String has more than X characters then show ...

return mb_substr($cutString, 0, $numberToCut, 'UTF-8').'...';

}else{

return $cutString;

}

}

This has been used in whole web app as a string truncator in to what exactly I want from.

And here another custom built-in function from my web app:
function getDomain($url) {

$host = parse_url($url, PHP_URL_HOST);

if ($host) {

// length validation + expanded TLD patterns

preg_match('/([a-z0-9\-]{1,63}\.(?:[a-z]{2,63}|[a-z]{2}\.[a-z]{2}|[a-z]{3}\.[a-z]{2}))$/i', $host, $matches);

return $matches[1] ?? $host;

}else{

return null;

}

}

Is there a collection or repository of custom-built PHP functions for anyone to use?

Also, nowadays, are custom-built functions like the above still valuable to others? If I share mine on GitHub, would it help? Sometimes it feels like I'm one of the few developers still messing with custom PHP codes.

https://redd.it/1nuav7x
@r_php
Share Your Laravel Story: Be Featured as Artisan of the Day!
https://redd.it/1nuft56
@r_php
Is it possible to find a job or an internship that's not paid as a junior PHP dev?

Hello everyone, Im 20 years old and I am in that stage where I dont know if i should pursue something, in my case being a web dev. I have a few projects, a PHP Hospital Management System, a local platform for agriculture companies in MCV and OOP PHP, a webshop in Node and a group project carpooling app in Node as well and im planning on doing more real world applications, apps that in theory could solve real world problems. During these four years, I did a lot of WordPress work, which inlcuded redesigning themes, incorporating plugins, css and JS corrections, tranlsating pages etc. Some languages i have extensive knowledge in are PHP, JavaScript, Node, Java, Express, SQL and a bit ot C#. So i was wondering if its possible to find an unpaid internship or perhaps a lower paid job, as im not aiming to get a six figure job. Any advice on what to do, what to focus on or where to find an internship or a job in Europe or US remote? Thank you in advance.

https://redd.it/1nuewpr
@r_php
Anyone has a working example of google ads API in php to share?

I'm trying to get it to work with the google ads library but it keeps installing older versions and I'm lost, the authentication is a pain in the ass also. Anyone care to share a working version of it if you have it?

https://redd.it/1nuk7lf
@r_php