r/PHPhelp • • May 14 '26

Login attempt

2 Upvotes

Sentry caught a bad login attempt...

the url they used was xxhttps://ssrf.cve-2024-123456.detect/login

this is obviously not my site, and i changed the actual url to 123456

what is this?? i have not clicked on it and I suggest you don't either.

Is anyone familiar with what's going on?


r/PHPhelp • • May 14 '26

Solved How to send HTML email with mail() without destroying DKIM key or email appearance

0 Upvotes

I already know how to send HTML email through the PHP mail() function, however many external email providers may ditch my outgoing emails if they are not properly signed with a DKIM key.

Now if I try sending a super short message, I have no problem, but if I'm sending an entire newsletter as HTML with no line breaks (because I like to reduce the payload on the network), then the DKIM key breaks and many validators would complain.

One thing I did was use the chunk_split command on the entire message. Everytime I used that, the DKIM check always passes however, some of the HTML code is corrupted (probably because of the carriage return and line feed within HTML tags).

Is there another built-in PHP command I could use to replace chunk_split?

Then again, I'll probably have to manually split it and put a CRLF at the end of each HTML tag, then that may be a problem if I have a paragraph of text exceeding 80 characters.

Please advise.


r/PHPhelp • • May 12 '26

OOP in PHP

16 Upvotes

Hello, I started learning OOP a few days ago. I’ve understood the basic concepts quite well: I can easily create classes and individual methods. However, when it comes to creating a Manager class that requires nesting/interacting objects together, I get completely lost. Do you have any tips, useful references, or is it really just a “click” that comes with practice?

Here’s an example:

For the Game and Loan classes, I didn’t have any difficulties, but this is where I get stuck with Library. The code is “correct” because I got help from AI.

In short: I lose track of the types of objects I’m manipulating as soon as multiple classes interact together.

Thanks in advance for your answers.

<?php
declare(strict_types=1);

class Library
{
    public function __construct(private array $listeGame = [], private array $listeLoan = [])
    {

    }
    public function ajouterJeu(Game $game): void
    {
        $this->listeGame[] = $game;
    }

    public function listerDisponibles(): array
    {
        $jeuxDispos = [];
        foreach ($this->listeGame as $game) {
            if ($game->getDisponibilite() === true) {
                $jeuxDispos[] = $game;
            }
        }

        return $jeuxDispos;
    }

    public function listerEmpruntsActifs(): array
    {
        $empruntsActifs = [];
        foreach ($this->listeLoan as $loan) {
            if (!$loan->getGame()->getDisponibilite()) {
                $empruntsActifs[] = $loan;
            }
        }
        return $empruntsActifs;
    }

    public function emprunter(Game $game, string $emprunteur): void
    {
        $this->listeLoan[] = new Loan($game, $emprunteur, new \DateTime("now"));
        $game->emprunter();
    }

    public function retourner(Loan $loan): void
    {
        $loan->getGame()->retourner();
        $this->listeLoan = array_filter($this->listeLoan, function ($l) use ($loan) {
            return $l !== $loan;
        });
    }
}

r/PHPhelp • • May 11 '26

turning fatal error back to warning when array index is not defined.

0 Upvotes

I have code that was working well in php 5.6 but now php 8.4 is complaining.

I narrowed the code down as follows:

if (isset($d{1})){echo "yay";}

the new PHP doesn't like curly braces so I fixed that with something slower:

if (isset($d)&&strlen($d)>1){echo "yay";}

But the one that's really frustrating is this one:

echo somefunction($d['name']);

In an old PHP version, if 'name' isn't set in the $d array or $d is not an array, then the parameter going into the function is null and I get a warning. but in php 8.4, I get this fatal error:

PHP Fatal error: Uncaught TypeError: Cannot access offset of type string on string in

Apparently this error doesn't happen in the php 7 and I heard php 7 is obsolete.

Is there a setting I can use in the php 8 config file to turn that fatal error into a warning again so my program can run? without me having to sift through my thousands of lines of code to change each index manually?


r/PHPhelp • • May 08 '26

Symfony Mailer - Encrypted Messages

2 Upvotes

I am learning how to use Symfony Mailer and am a bit lost on the encrypting message section.

This is my simple code below which works in sending the email.

<?php

require 'vendor/autoload.php';

const FROM = 'me@example.com';

const TO = 'example@email.com';

const SUBJECT = 'My Subject';

const MESSAGE = 'Hello World';

const DSN = 'smtp://localhost:1025';

$transport = \Symfony\Component\Mailer\Transport::fromDsn(DSN);

$mailer = new \Symfony\Component\Mailer\Mailer($transport);

$email = (new \Symfony\Component\Mime\Email())
    ->from(FROM)
    ->to(TO)
    ->subject(SUBJECT)
    ->text(MESSAGE);

$encrypter = new \Symfony\Component\Mime\Crypto\SMimeEncrypter('my-certificate.crt');
$encryptedEmail = $encrypter->encrypt($email);

try {
    $mailer->send($encryptedEmail);
} catch (\Symfony\Component\Mailer\Exception\TransportExceptionInterface $error) {
    echo 'Unable to send email' . PHP_EOL;
}

And this is how I generated the certificate and key...

openssl genrsa -aes256 -out my-certificate.key 4096
openssl req -new -x509 -days 29220 -key my-certificate.key -out my-certificate.crt

I am able to receive the email using SMTP tools like Mailpit.

My two questions are...

  1. My emails are encrypted using the certificate, but shouldn't it be done using PGP?
  2. How do I decrypt the email with SMTP testing tool or any online or CLI tool? I tried to decrypt the email and could not decrypt it even though I have all of the keys.

r/PHPhelp • • May 08 '26

php program for accounting, need to insert more inserts instructions

0 Upvotes

I'm trying to create a php program for the invoices registration, but i can't put more than 1 insert in the database ( mysql workbench) where i created a table only for those. Can someone please help me or explain me how to insert more than 1 instruction?.


r/PHPhelp • • May 06 '26

Vibe coding in pure PHP to set up Meta CAPI — Advice needed for raw cURL setups

0 Upvotes

Hey everyone. I'm not a dev, but I’ve spent the last week digging into a client’s backend because they use pure PHP with no frameworks or plugins. To keep things light and avoid breaking their setup, I decided to skip the SDK and go with raw cURL to implement Meta Conversions API.

I’ve been mostly vibe coding my way through this using the official docs and a lot of trial and error. I managed to get the events firing, but since this is my first time touching raw PHP at this level, I’d love to get some eyes on my logic and see what I might be missing.

What I’ve done so far:

I’m tracking a subscription product, so I’m sending the initial purchase from the frontend and then the renewals (Month 2, 3, etc.) directly from the server. For the server-only events, I’m using action_source: "system_generated".

I’ve got the event_id deduplication working by passing the ID from the frontend to the backend via fetch. I also figured out (after some swearing) that Meta requires user data like emails to be SHA-256 hashed and sent as an array of strings, not just a plain string. I’m also making sure the event_time is dynamic using time() so the events don't get rejected.

Where I need your advice:

  1. Performance and Latency: Since I’m using raw cURL synchronously, I’m worried about slowing down the checkout process if Meta's API takes too long to respond. In a pure PHP environment without a queue system, is there a simple way to handle this so the user doesn't wait?
  2. Error Handling: Right now I'm just logging the $response. For those of you who don't use the SDK, how do you handle retries or failures? Or do you just let it fail and move on?
  3. Deduplication: The Events Manager UI is a bit of a mess. Is there a more reliable way to confirm that the Pixel and CAPI events are merging correctly other than just trusting the "overlap" percentage?
  4. Data Quality: I’m getting "Poor Quality" warnings even though I’m sending email and IP. Is it worth trying to capture more data points through PHP, or is that just the reality of server-side tracking?

If anyone is working on a similar vanilla stack or has experience with CAPI without the SDK bloat, I’d appreciate any tips or "gotchas" you’ve run into. I can share my cURL wrapper if anyone wants to tell me where I’m being a total amateur.

Trying my best not to break the client's site here, so any help is massive.


r/PHPhelp • • May 03 '26

Tutorials or Open Source Code for Matrimony Website in Laravel

0 Upvotes

Hi everyone,

I’m planning to build a matrimony website using Laravel for a community trust that helps connect brides and grooms as a social service (non-profit initiative).

I’m looking for:

  • Good tutorials (YouTube/blogs/courses) for building a matrimony or similar matchmaking platform in Laravel
  • Any open-source projects or GitHub repos that I can study or use as a base
  • Suggestions on key features I should include (like profile verification, search filters, privacy controls, etc.)

The goal is to keep it simple, secure, and useful for the community rather than overly commercial.

If anyone has worked on something similar or can point me to useful resources, I’d really appreciate your help!

Thanks in advance!

Post content is created with the help of chatgpt!


r/PHPhelp • • May 03 '26

Vibe coding

0 Upvotes

Im an IT graduate but picked the hardware major since i find my coding skills to be not good enough but i got a job as a programmer now.

How do i stop myself from vibe coding and attaching myself with tutorials?

Like yeah i know AI is supposed to just help us but i have no idea on how to prevent vibe coding since i am not that knowledgeable on the coding area.


r/PHPhelp • • May 02 '26

For your open source projects, do you use your own name in the namespace?

3 Upvotes

For those that write open source software in your personal GitHub account, do you namespace your projects with FirstLast/Project ?

To me it seems fine for one off libraries but once you build anything of substance, it seems like it would be better off going under its own brand.

Thoughts?


r/PHPhelp • • May 02 '26

Wampserver installation issue

0 Upvotes

Using wampserver, says visual studio (C++) 2015-2022 (both x64 and x86) arn't installed but I checked control panel and they are.

I need this for a stupid assignment due ina week, idk shit about webhosting or PHP files, this is just the software the prof said to use. If anyone knows a fix or alternitive please lmk, thank you

edit: used xampp, works great for what i needed. So theres that lol


r/PHPhelp • • May 02 '26

Solved [Laravel] NPM required?

0 Upvotes

Hi,

Is Node/NPM required when building a Laravel app without any web frameworks (i.e. using only Blade templates/components and some API routes)? I set up a test project using the installer and no preset, and deleted anything npm (module folder, package.json etc) and it still ran fine using 'php artisan serve'. Is that an okay thing to do or will it bite me in the ass at some point when trying to push this to a production environment?
I understand vite is used to "bundle frontend assets" but I don't know what it would bundle in my case, if there's only Blade. I've never worked with a bundler or Laravel before.

Thanks!

(Edit: I don't have a real-world app in mind. This is for a uni project which second-semester students will work on, which is probably why simplicity is the essence. The professor asked for an npm-less production environment, which afaik is the case since there are only npm dev dependencies, but I'm wondering if we can drop NPM altogether).


r/PHPhelp • • Apr 30 '26

Solved Any additional tips for an email validation

3 Upvotes

I use CakePHP to validate user's email in my form:

$validator
    ->email('user_mail', false, 'Email format is wrong')
    //min allowed by email rule is 6 symb f@f.ff
    ->minLength('user_mail', 6, 'Min length for an email is 6 symbols')
    ->maxLength('user_mail', 128, 'Max length for an email is 128 symbols')
    ->requirePresence('user_mail', true, 'Email field is required')
    ->notEmptyString('user_mail', 'Email can\'t be empty');

Is that validation sufficient? What do you recommend to add/remove?


r/PHPhelp • • Apr 30 '26

PHP-FPM vs PHP-CLI

4 Upvotes
I'm running some simple PHP 8.5 tests (empty loop, open database connection, ...) on a MacBook Pro with Debian in a UTM VM.

With exactly the same code fragment, CPU usage is always 2–3 times higher with PHP-FPM than with PHP-CLI.

Is this normal? Or does it have to do with my settings?

r/PHPhelp • • Apr 29 '26

When should I use traits vs just adding methods to a class?

0 Upvotes

I understand that traits are meant for code reuse across unrelated classes, but I’m struggling with when they actually make sense in practice.

For example, say I have a simple class like Person or whatever, with generic methods like set, get, and has.

Now I want to add more specific methods like setEmail(), setAge(), etc.

Would it ever make sense to put those specific methods into a trait, or should they just live directly in the class?

The Trait will only be used for this 1 class and never elsewhere.


r/PHPhelp • • Apr 28 '26

Better way to doing this? PHP Code Sniffer notice

0 Upvotes

Someone know any better way to do this?

Inside this file I have this variable $args.

But phpcs can't recognize that I am using it, because it is inside another file (pannel.php), and acuses that the variable is not being used, even though I required the file.

phpcs: The method parameter $args is never used
Auto-fixable: ❌

The function were like this:

/**
 * Render the inner page template
 *
 * @param array $args Array with the list item arguments.
 */
public function pannel_template( $args ) {

    ob_start();
    require AARDEX_COMPONENTS_DIR . '/src/components/pannel.php';
    return ob_get_clean();
}

In order to solve the issue I am just ignoring the error:

/**
 * Render the inner page template
 *
 * @param array $args Array with the list item arguments.
 */
public function pannel_template( $args ) { //phpcs:ignore

    ob_start();
    require AARDEX_COMPONENTS_DIR . '/src/components/pannel.php';
    return ob_get_clean();
}

r/PHPhelp • • Apr 27 '26

Runtime vs InvalidArgument exceptions - when to use which?

10 Upvotes

When should you throw RuntimeException vs InvalidArgumentException in PHP?

I understand that InvalidArgumentException extends LogicException, which is meant for errors detectable before runtime, and RuntimeException is for conditions only discoverable during execution.

But I keep second-guessing myself on cases like this:

function getFile(string $path): string
{
    if (!file_exists($path)) {
        throw new ???Exception('File not found.');
    }
    return file_get_contents($path);
}

The argument $path is technically valid -- a non-empty string, correct type. But the file it refers to does not exist. Is that a RuntimeException because the absence is only discoverable at runtime? Or is it an InvalidArgumentException because the argument I passed did not correspond to anything real?

Where do you draw the line, and how do you think about this distinction?


r/PHPhelp • • Apr 25 '26

Wordpress php link help

0 Upvotes

I have (what I think is) a fairly simply request, though I cannot sort it out myself.

I'd like to add a link to an image on an older Wordpress site (2014) that goes to their Instagram page. I've tried adding a link to the image, but when I click it, it only opens the image itself.

It uses php7.3. I tried to update to 8.5, but it seems the code is incompatible (?), and the site content just disappeared, so I reverted back. I'm honestly not sure. I didn't' design this site and I'm not savvy with Wordpress or php.

I'm really at a loss and could use the help.

I'm willing to let whomever log into the interface to get it done.

Many thanks!


r/PHPhelp • • Apr 24 '26

Fresher struggling to get a PHP developer job – need guidance

14 Upvotes

Hi everyone,

I recently graduated with a degree in Computer Science, and I’m trying to get my first job as a PHP developer, but I’m feeling quite stuck and searching for some guidance.

Currently, I’m trying to rebuild my foundation and focus on: PHP (core concepts), XAMPP, MySQL / databases, Basic frontend (HTML, CSS, JavaScript)

My main confusion is:

  • What level of PHP is actually expected for a fresher/junior role?
  • What kind of projects should I build to stand out?
  • Should I focus only on PHP or also learn something like Laravel/modern frameworks?
  • How do I know when I’m “job-ready”?

If anyone has gone through a similar phase or is currently working as a PHP developer, I’d really appreciate your advice.

I use Chatgpt to avoid the grammatical mistakes.


r/PHPhelp • • Apr 23 '26

Solved Anyone using Yii3?

2 Upvotes

Hello, I am testing Yii3 and wanna ask if anyone tried adding a foreign key on their migrations using Yii3? usually in Yii2 we do it like this

// Yii2

public $table = 'user_info';

public $foreignTable = 'users';

$this->addForeignKey('fk_user_info_user_id', $table, 'user_id', $foreignTable, 'id', 'RESTRICT', 'CASCADE');

// Yii3

$table = 'user_info';

$foreignTable = 'users';

$columnBuilder = $builder->columnBuilder();

$builder->addForeignKey('fk_user_info_user_id', $table, 'user_id', $foreignTable, 'id', 'RESTRICT', 'CASCADE');

but now I am having trouble in Yii3 with an error of

SQLSTATE[42S02]: Base table or view not found: 1146 Table 'db_api_test.fk_user_info_user_id' doesn't exist The SQL being executed was: ALTER TABLE `fk_user_info_user_id` ADD CONSTRAINT `user_info` FOREIGN KEY (`user_id`) REFERENCES `users` (` id`) ON DELETE RESTRICT ON UPDATE CASCADE

Thank you for any insights or suggestions.


r/PHPhelp • • Apr 20 '26

Using exec today. Am I a bad php dev?

18 Upvotes

Recently I needed to strip just location data from my user's jpg uploads and used ExifTool with exec to do the job. I tried to make this as safe as possible. I checked the file mime type, changed the file name, and escaped the path (escapeshellarg) when passing it to exec.

Now I need to try to read some text from a jpg and once again my research has pulled me towards running this with Tesseract OCR and exec.

Many years ago I heard that we should not use exec, but I was wondering have things gotten any better? Is it still recommend to not use exec, or is it more or less safe, as long you follow the general security steps of checking the file mime, keeping the call to the program hard coded in the method, and escaping the file path. Or am I a terrible PHP dev?

Thanks.


r/PHPhelp • • Apr 21 '26

Deploying laravel React

0 Upvotes

where to dwploy larav react with sqlite as db, im just a beginner


r/PHPhelp • • Apr 19 '26

upgrading vanilla php 5.4 to 8.x with laravel 13

7 Upvotes

Hey guys. I'm in a small company where i'm basically the "guy that does technology", be it data sceince, backend, front end and everything in between.

My boss just asked me to upgrade our legacy php 5.4 crm and I think I'll just bump it all the way to latest stable (8.4?) with laravel 13, because why not (why not?).

I have no prior experience in such migrations and honestly not native in php at all. I read and figured I should use Rector, phpstan and a sniffer. I setup composer and got a running php 5.6 docker environment for testing.

I will make use of lots of claude code, first to complete test coverage for our app.

If anyone here thinks they can be available for questions i might have in the process, via mail or whatsapp, i would super appriciate that.

Our software was built by a non-existant company and I also consider a relativley cheap option to help us with this (Shift?) so i am definitley open to hear either "dont do it youll fuck everything up" or "yea sure it can be done, here are your tools: x y z", or just "pay this service, theyll do it for ya". idk. im honestly a bit scared, as i feel it's outside of my skillset, and there is nobody to consult with.

Yann


r/PHPhelp • • Apr 16 '26

[Laravel] What's the maximum amount of concurrent tasks I can run on a single call?

5 Upvotes

Hi! I am building a feature that requires several queries to be run to present stats to a user in real time (this cannot be done via jobs or pre-calculated values)

Essentially the requirement for the UX is:

User clicks a button => Dispatch the process => get the metrics

This usually takes about 60s because we run +10 queries in app and other API calls, I want to know if making this process concurrently (probably call up to 50 functions in parallel) will reduce the time to response and, is there a limit on how many concurrent functions can I call?

Edit: Here are the official docs but It seems that I cannot find the limits on this approach https://laravel.com/docs/13.x/concurrency