PHP Reddit – Telegram
PHP Reddit
34 subscribers
291 photos
37 videos
24.9K links
Channel to sync with /r/PHP /r/Laravel /r/Symfony. Powered by awesome @r_channels and @reddit2telegram
Download Telegram
FrankenPHP on Laradock - Sharing Production Configuration

Doing a quick project, so need to know if we you have any recommendations on what I can improve to configure FrankenPHP to work with Laradock.
I created a derived project from Laradock.
I cannot create the Caddyfile that works with all static content and LetsEncrypt Certificate. Any help will be appreciated. Here is the project repo: Project Repo - Laradock + FrankenPHP + Caddy

https://redd.it/1ls4jci
@r_php
Ai Bundle

A while ago I started creating a Bundle helping me to integrate LLMs into my Symfony applications. Its supports calling the most popular providers like OpenAi, Anthropic, Google, Mistral, DeepSeek, Ollama with a unified interface. It also supports with building prompts, tool calling, returning structured data from the LLM and a basic chat persistence.
Lately I also added tool calling via MCP (stdio and HTTP) and providing MCP tools (via. HTTP).

I know, I’m not the only one with this kinds of bundle, but maybe someone finds it useful:
https://github.com/johannes85/AiBundle

https://redd.it/1ls7qn7
@r_php
Function for my php chat that seems impossible to find

Guys good evening! I'm having a problem finding a function that helps me save a series of images in an ever-changing folder on my computer created through variables. It seems impossible in Chrome now due to harmful privacy policies. I also tried creating extensions but I just can't. It seems like all my attempts are met with the impossibility of achieving it. Obviously when the site is in localhost I can perfectly transfer the photos wherever I want.. help... thank you very much!!!!

https://redd.it/1lsgt5l
@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/1lt66go
@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/1ltjpdo
@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/1ltmkiz
@r_php
Built a simple noise library in pure PHP - looking for feedback

Hello,

I've created a small library for generating noise in PHP.
The library is based on "PHP-GLFW" and its C++ implementation, but it's written entirely in pure PHP.

Initially, I updated the "https://github.com/A1essandro/perlin-noise-generator" library, which seems abandoned.

I later decided to build my own version to avoid relying on "PHP-GLFW", since it requires installation just to access a few functions.

The library: https://github.com/Cryde/noise-functions
It's still a work in progress - feel free to share your feedback or suggestions!

https://redd.it/1ltnz75
@r_php
How I can check whether a unique index exisrts and avoid recreating it?

In an entity I have:


declare(strict_types=1);

namespace App\Entity\Activity;

use App\Domain\Helper\UuidHelper;
use App\Entity\Business;
use App\Entity\BusinessTypes\ActivityOperator;
use App\Entity\Image\ImageEntity;
use App\Entity\Tags\Pivot\ActivityTag;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
use Gedmo\Translatable\Translatable;


#[ORM\Entity]
#[ORM\Index(name: "external_id_origin_unique", columns: ["external_id", "origin"], options: ["where" => "external_id IS NOT NULL", "unique" => true])]
class ItemFromApi
{

public const ORIGIN_API='api';
public const ORIGIN_INTERNAL='internal';

#[ORM\Id]
#[ORM\Column(type: 'integer')]
#[ORM\GeneratedValue(strategy: 'AUTO')]
private int $id;

#[ORM\Column(type: 'string', length: 255)]
private string $noscript;

#[ORM\Column(type: 'integer', nullable: true)]
public ?int $externalId = null;

#[ORM\Column(type: 'string', length: 255)]
public string $origin = self::ORIGIN_INTERNAL;

// Setter and getter are ommited for siplicity

}



Then I run php bin/console doctrine:schema:update --dump-sql and generates the following sql:

CREATE UNIQUE INDEX external_id_origin_unique_itinerary ON item_from_api (external_id, origin);


And run upon my db, then once I run again index is re-created:

CREATE UNIQUE INDEX external_id_origin_unique_itinerary ON item_from_api (external_id, origin);


How I can avoid the re-creation of this index?


https://redd.it/1ltq6ln
@r_php
A Cognitive Code Analysis Tool

Cognitive Code Analysis helps you understand and improve your code by focusing on how developers actually read and process it. Understandability is a huge cost factor because \~80% time is spent on reading and understanding code.

[https://github.com/Phauthentic/cognitive-code-analysis](https://github.com/Phauthentic/cognitive-code-analysis)

Features:

* Scans source code and reports detailed cognitive complexity metrics.
* Churn analysis (requires Git) to highlight risky, frequently changed code.
* Export results as CSV, XML, or HTML.

Unlike traditional metrics like cyclomatic complexity, this tool emphasizes cognitive complexity - how hard your code is to understand. It analyzes line count, argument count, variable usage, property access, and nesting to identify the hardest parts to maintain.

You can adjust the score calculation through configuration by setting weights for each metric, allowing you to tailor the cognitive complexity scoring to your own acceptable thresholds.

I’ve used it myself to spot risky areas early in projects. Measuring cognitive complexity is tough, but there’s academic backing for this approach. Check out this paper if you're curious:
[https://dl.acm.org/doi/10.1145/3382494.3410636](https://dl.acm.org/doi/10.1145/3382494.3410636)

I'd love your constructive feedback - try it out and let me know what you think!

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