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
Doctrine Translatable (Gedmo) - Does it not do that?

Hi - I dont know if here is the right place to ask that but I figured a lot of symfony devs will likely use doctrine and some of you have experience with i18n in database.

I found the gedmo doctrine extension translatable and tried to build a minimal working example in my symfony app. Loading an entity via the repository is working fine but loading it via its relationships does not return the translated entity but only the default locale.

This is the example Controller I try to use, any comments appreciated - thanks:

<?php


namespace App\Controller;


use App\Entity\Context;
use App\Entity\UserContext;
use Doctrine\ORM\EntityManagerInterface;
use Gedmo\Translatable\Entity\Translation;
use Gedmo\Translatable\TranslatableListener;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
use App\Entity\User;


class TranslatableTestController extends AbstractController
{
#Route('/test/translatable/{lang}', name: 'test_translatable')
public function index(EntityManagerInterface $em, TranslatableListener $translatableListener, String $lang): Response
{
// set the current lang based on the request
$translatableListener->setTranslatableLocale($lang);



// get the current user from security bundle
$user = $this->getUser();
if (!$user instanceof User) {
throw new AccessDeniedException('Access denied: User must be authenticated.');
}


$contexts = $user->getUserContexts()->map(fn($userContext) => $userContext->getContext())->toArray();


// get last context only for debugging purposes
$context = end($contexts);


return new Response(sprintf(
"<h2>Current Translation</h2>
<p> %s</p>
",
$context->getName(), // only gives default locale no matter the locale parameter
));
}
}

https://redd.it/1o2aeyy
@r_php
Profiling Symfony application with Blackfire

Dear folks,

I am looking for sources which provide advice for how to start profiling my Symfony application with Blackfire. I already created some profiles of requests of my application. But I am having a hard time to get insights and understand whats going on.

I appreciate for all kinds of guidance and advice.

https://redd.it/1o2v83p
@r_php
Signed documents PHP

Hello everyone, I hope you're all well.



I currently have a PHP system with MySQL that generates PDFs, which must be signed by the parties to indicate their agreement with the information generated. My question is that currently the document doesn't have a digital signature; it's only printed, signed on the outside, uploaded to the system, and a backup is saved.



What do you recommend for getting a digital signature? Is there a library that can be connected to it so it takes the document and the meeting participants' emails to send the document to the parties. They can generate a simple electronic signature, save the signature information, and once everyone has signed it, save it to the platform as an automatic backup? I hope this helps. Best regards.

https://redd.it/1o319bz
@r_php
Do you use the PHP manual CHM downloads? Why?

Greetings.

TLDR: Do you use (or have you previously used) the CHM manual downloads? If so, why do you prefer them over other downloadable formats (eg. single page or multi-page HTML)?

(I'll note here that currently all downloadable versions are unavailable - this is being looked into by actual PHP core devs who have the required access)

Context:

I've been investigating some issues with the downloadable versions of the PHP manual. In particular the CHM versions are currently manually built.

Additionally the official tools to build CHM files - Microsoft's HTMLHelp Workshop - are no longer available for download from MS and can't be installed on Windows 11 (the installer errors saying a newer version is already installed). These issues make building the CHM files increasingly difficult.

(I also briefly tried freepascal's chmcmd, but this fails to build a working CHM file)

For those who prefer the CHM files, I'd like to understand why so I can work out if there's other alternatives that could be implemented.

https://redd.it/1o3s2wh
@r_php
How can I reskill in laravel

Hello All,
I know this is a php based subreddit. But I would like to reskill in laravel because it has been a year since I properly worked in laravel and I feel disconnected to the laravel framework. So I'm open for some course suggestion that can be helpful for me to be reskilled again in laravel.

About me: I'm a php full stack dev with 4 years of exp.

https://redd.it/1o45wny
@r_php
Convert your Notion pages into Markdown

Hey, guys! Just released a new package called md-notion 🙌

Pretty much feature-complete tool that can read your page, nested pages and databases, even database items and all block types are supported

https://github.com/RedberryProducts/md-notion

My primary goal was to use notion for context for my LLM integrations with LarAgent, but you may find a better use cases too 👍

Please support by starring a repo 🙏

Would love to hear your feedback 💪

https://redd.it/1o4ge7o
@r_php
Two weeks ago I opensourced my pure PHP static site generator

As the noscript says I released my static site generator phpssg opensource on github a few weeks ago in this post and I got a crazy amount of support and really helpful constructive feedback. Today I wanted to give you all an update on how it's going.

I published the latest stable version on packagist so now it's really simple to get started with just require taujor/phpssg, I rethought the entire build system because it was difficult to pull data in from remote API's etc. I refined the documentation and have kept everything super minimal. I'm going to add an example template next week as a way to quick start your project. Another big feature I have planned for the coming weeks are Hooks, so you can easily extend the internal builder class with your own custom functions that will be ran at specific points in the build process. The generator is already quite extendable through utilities and the fact that it is an extremely thin layer over vanilla php. You can even mimic server island functionality (like astro) by combining this with a typical php server.

I will be adding tutorials and exploring what we can really achieve in php with static site generation on the project website which is also being built in the coming weeks (phpssg.com)

I hope you enjoy using phpssg as much as I did building it. Let me know what you think, I'm always open to discussion/criticism.

https://redd.it/1o4qx1p
@r_php
Is my Deployer configuration correct for a small Laravel + Inertia project?

Hi everyone,

I'm working on deploying a small project for a rental company. The backend is **Laravel + Inertia**, and I'm using a low-cost VPS (€8/month). I wrote a Deployer noscript to handle:

* PostgreSQL installation and database setup
* Nginx + PHP-FPM configuration
* Node/npm install and build
* Laravel shared directories and writable permissions

My questions:

1. Does this look like a proper setup for a small Laravel + Inertia project?
2. Are there any obvious mistakes or security issues?
3. Anything I should improve for a VPS with limited resources?

Thanks in advance!

Here’s a simplified version of my noscript with sensitive info removed:

namespace Deployer;

require 'recipe/laravel.php';

// Config
set('application', 'Rentalia');
set('repository', 'git@github.com:***.git');
set('git_tty', true);

// Shared files/dirs
add('shared_files', ['.env']);
add('shared_dirs', ['storage']);
add('writable_dirs', [
'bootstrap/cache',
'storage',
'storage/app',
'storage/app/public',
'storage/framework',
'storage/framework/cache',
'storage/framework/sessions',
'storage/framework/views',
'storage/logs',
]);

// Hosts
host('production')
->setHostname('***.***.***.***')
->set('remote_user', 'root')
->set('deploy_path', '/var/www/rentalia')
->set('branch', 'main');

// Tasks
task('postgres:setup', function () {
writeln('Installing PostgreSQL...');
run('apt-get install -y postgresql postgresql-contrib');

writeln('Creating database and user...');
run('sudo -u postgres psql -c "CREATE DATABASE rentalia;"', ['timeout' => 300, 'tty' => false]);
run('sudo -u postgres psql -c "CREATE USER rentalia_user WITH PASSWORD \'***\';"', ['timeout' => 300, 'tty' => false]);
run('sudo -u postgres psql -c "GRANT ALL PRIVILEGES ON DATABASE rentalia TO rentalia_user;"', ['timeout' => 300, 'tty' => false]);
})->desc('Install and configure PostgreSQL');

task('webserver:setup', function () {
writeln('Installing Nginx and PHP-FPM...');
run('apt-get update');
run('apt-get install -y nginx php8.3-fpm');
// Nginx configuration omitted for brevity
})->desc('Install and configure Nginx');

task('npm:install', function () {
run('cd {{release_path}} && npm ci');
});

task('npm:build', function () {
run('cd {{release_path}} && npm run build');
});

// Hooks
after('deploy:vendors', 'npm:install');
after('npm:install', 'npm:build');
after('deploy:failed', 'deploy:unlock');




https://redd.it/1o4r1tf
@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/1o4uebv
@r_php
How to properly deploy using laravel?

I bought a domain on Hostinger with no vps server (Shared hosting) , i uploaded my *Laravel* files in domain's file manager and made sure that public files only in public_html , what is the next steps ?

https://redd.it/1o50rnv
@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/1o58rlv
@r_php
Any Resources for Learning How to Create Miroservices in Core PHP or in any Framework?

I have experience with Core PHP, Laravel, and a bit of Symfony and WordPress. I’ve also completed several projects. Now, I want to learn how to build microservices using PHP. Could someone recommend tested and reliable resources for that?

https://redd.it/1o5aa4x
@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/1o5bs2r
@r_php
is PHP dying?

Forgive me if this topic has been discussed to death, but I'd love to hear from other folks.

I learned PHP a long time ago, and for years I had no trouble finding work. There were plenty of sites that were LAMP based (or nginx, or maria, or postgres, but you get the idea -- PHP).

Now I cannot find any job postings that are looking for PHP. I'm surprised, though, as there must still be so many site and SAAS products that were written in PHP, and still need support and feature development.

Any opinions?



https://redd.it/1o5irx1
@r_php
phpMyAdmin - database column order

Hello

In my table "marrdata" I have 14 columns.

I understand that it's the column name rather than number that matters, but I wanted to check - if I add in another two columns, does it matter if they upset the current order?

Eg currently it is:

1 - IDNo

2 - Year

3 - Name

4 - Page

5 - Notes

I'd like to have

1 - AnsID

2 - IDNo

3 - Year

4 - Name

5 - Page

6 - AnsNotes

7 - Notes


thanks



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