r/PHPhelp • • Mar 18 '26

I need to take a value from database as PHP variable and somehow convert that variable to be compatible with a Javascript

8 Upvotes

I have a situation where I need a button created with Javascript if conditions set in the database table say so. I basically have it figured out how to get the value and stuff, but using an if equals value with php doesn't allow me to run the Javascript within. What's the best way to pass this information/value into a variable that's usable with the Javascript? Thanks.​​


r/PHPhelp • • Nov 17 '25

How do you do your development and deployments?

8 Upvotes

At the moment, we are developing on a folder on a remote server. I'd love to develop locally, but I might have to hold off on that battle.

When we're done, we FTP the file changes to the prod folder.

We're using Azure Git. An idea we had was to deploy when the site when a commit to git was made. I briefly looked at it and I wasn't able to figure it out. Any suggestions?


r/PHPhelp • • Nov 04 '25

Is PHP a fast language or not?

8 Upvotes

r/PHPhelp • • Nov 04 '25

What is the best/modern way to render text to a png image with PHP?

8 Upvotes

Basically I want to create an endpoint that takes in some arguments and returns a png image with the text rendered using a font file located on the server. I'd also want to store/cache images and ideally run like a nosql DB or something similar, to track duplicate requests and just return an image without going through the render process, if it already exists for a certain set of input parameters.

I have implemented a prototype in Python/Flask using PiL. But now I'm thinking of implementing it in PHP instead, just so it can be easily used with a simple Apache/WP setup side by side with the website that will be using this endpoint to render text following user input.

Thanks!


r/PHPhelp • • Oct 31 '25

develope a Rest API

8 Upvotes

Hello, I want to develop a restapi, what framework would you recommend?

I'm searching myself, there are many options, but I'm worried about the security of the inputs.

If anyone has experience, I'd appreciate some advice.

Laravel is heavy, let's think about a simple api!

I want a simple and secure framework :(


r/PHPhelp • • Oct 11 '25

Php developer with 8 years of experience asking for career guidance

8 Upvotes

Hello everyone, I am php dev for a company based in Noida, india and am a contractual employee. I have 8 years of experience in the same company and have used techs like PHP (Laravel & Cakephp), JavaScript (jQuery as well), Bootstrap, elastic search, Postgres sql and tortoise svn (also have idea of git). Have experience in debugging my projects on Linux servers. Currently working at 12 lpa. I know its low ☹️

I truly need some advice on how to move forward in my career. Am currently 30 years old and feel stuck. Don't know what to do at this point. Please any guidance is highly appreciated. Thanks in advance


r/PHPhelp • • Sep 22 '25

Should I switch from Django to CodeIgniter for a school management SaaS, or stick with modern stacks?

8 Upvotes

Hi everyone,

I’ve been learning Django (Python) for about a year — covering its ORM, PostgreSQL, and building REST APIs. My next plan was to learn React and then move to Next.js for the frontend.

My long-term goal is to build a modern, scalable, AI-powered School Management SaaS with a robust architecture.

However, at the company where I work, there’s pressure to deliver a ready-made school management system quickly so they can start earning revenue. Most of the “off-the-shelf” products we find (e.g., on CodeCanyon) are built in CodeIgniter (PHP).

Now I’m stuck:

  • Should I pause my Django/React/Next.js learning and dive into CodeIgniter so I can customize these ready-made solutions?

  • Is CodeIgniter still a solid choice for new projects, especially for something I hope will scale and last 10–20 years?

  • How active is the CodeIgniter community compared to Django’s?

  • If I invest time in CodeIgniter, will I be limiting myself compared to staying with Django + modern JS stacks?

Any advice from people who’ve faced a similar decision (or who’ve scaled CodeIgniter apps) would be greatly appreciated.

Thanks in advance!


r/PHPhelp • • Aug 31 '25

How to create a plugin system like wordpress

8 Upvotes

I couldn't post this on the laravel sub because I don't have enough engagement, so I just gotta ask here.

I want to create a big project, and I want the functionality of the application to be extendable by plugins/modules. I plan to use Laravel & livewire. Ideally, users will get the core functionality of the app by default. Then, there's a plugin/module marketplace where they can find plugins, buy them, install and get more functionality.

I don't know how to get this done though. If you know how I can get this done, please help me out. I would love to hear your thoughts and suggestions, plus any resources you know of. Thanks!


r/PHPhelp • • Aug 15 '25

Should I upgrade PHP 7.4 to 8.4? If so, how?

8 Upvotes

Background: I became increasingly frustrated with my workplace keeping all data in spreadsheets, so I built a PHP/MySQL application which everybody thinks is much better, so now we've started using that instead of the spreadsheets. However, my main tasks take by far most of my time, and now I've been advised that PHP 7.4 is EOL and I should upgrade to 8.4. This is now a production system with quite a few daily users, I have no staging environment, and anyway there are quite a few things I wouldn't be able to test, even if I had one.

I usually abide by the rule "if it ain't broken, don't fix it" - the current system doesn't seem broken under PHP 7.4. Please advise.


r/PHPhelp • • Aug 04 '25

Converting to PHP 8.4

8 Upvotes

Hi, I have been looking on various sites and trying different things, but i'm a bit stuck.

<?php
function counter1()
{
    static $c = 0;
    return ++$c;
}
$ref = new ReflectionFunction('counter1');
?>

Works absolutely fine, however my code is in a class, so I did the following:

<?php
class Test {
function counter1()
{
    static $c = 0;
    return ++$c;
}
$ref = new ReflectionFunction('counter1');
}
?>

All my logs say is: Error: Function counter1() does not exist,

I've tried using Test::counter1, $this->counter1, SELF::counter1, anything I could think of, but it's not having any of it, my old PHP (7.4 i think) worked fine, so any thoughts / assistance greatly appreciated!

TIA!


r/PHPhelp • • Apr 06 '25

Is using superglobals like $_POST, $_GET and $_SESSION still an advisable practice?

8 Upvotes

With Laravel and Symfony dominating the PHP ecosystem now, is it still advisable to write core PHP applications using the classic superglobals? Are there security concerns now? When I check stackoverflow, I don't see new posts anymore regarding usage of these variables. They advise switching to using a framework for better maintainability and security.


r/PHPhelp • • Feb 26 '25

Why can't I use objects in prepared statements?

8 Upvotes

I'm basically running this:

$obj = new stdClass();
$obj->name  = "";
$obj->email = "";
$obj->phone = "";

$sql = "INSERT INTO table (name, email, phone) VALUES (?,?,?);";
$stmt = $conn->prepare($sql);
$stmt->bind_param("sss", $obj->name, $obj->email, $obj->phone);

foreach( $objects as $obj ) {
    stmt->execute();
}

and it is most definitely not working - it inserts the strangest things into the database. However, if I put the bind_param line into the foreach loop, it works. But I thought the point of prepared statements was that you could - you know - prepare them, and then just change the variable values and execute.

What's wrong with this?


r/PHPhelp • • Jan 23 '25

JWT vs session-based auth for PHP API

8 Upvotes

Hi everyone! I need some advice regarding a PWA project. The backend runs a PHP-based API that I wrote to provide the PWA with data. The API access requires authentication and I would like a user to stay authenticated after a login for a week at max during inactivity.

Currently, I have solved this using JWT. During the validity of the JWT access token, I rely on data stored in the JWT: a user ID and a club ID (indicating membership), to avoid having to check which club the user is an active member of.

Recently, I've read a lot of articles on how JWT is bad practice and often misused and that session-based auth is a better solution. I am wondering now if I should move to that, especially having the following requirements in mind:

  • the PHP backend needs to run on shared hosting (1&1 IONOS), so no Redis/Memcached (for caching the user authentication state and not having to request the DB on every request) available (I think?)

  • a user should not have to authenticate every time using the app, but stay logged in for 7 days during activity, with the auth window automatically extending when using (would a PHP session lifetime of 7 days at all possible on shared hosting / a good idea?)

  • I want to avoid validating a user's access right / club membership upon every API request to reduce database load (therefore the "caching" of user id and club id through JWT previously)

  • I need to however validate a user's access right periodically, e.g. every 1 hour to allow potential user banning (so far, with JWT, I have done this check every time a refresh token is used by checking the DB if the refresh token was invalidated manually - I am fully aware, this makes JWT lose its statelessness)

  • the app is expected to be able to handle tens to hundred concurrent users

Are these requirements better handled using session-based authentication? I am specifically interested in the implications regarding security and flexibility/UX.

Thanks in advance for your insights! 🙏


r/PHPhelp • • Jan 20 '25

Thanks for helping me see the light

8 Upvotes

I posted a couple days ago about writing my first lines of PHP in years. I posted 1 file with a lot of code. Got some good feedback and several comments about putting all code in 1 file. I took your feedback and refactored the 1 file into a slim app.

for anyone that cares to see where it is now. code

Not really looking for help ATM. just thanks to those that responded.


r/PHPhelp • • Jan 06 '25

Review of 8.4 dependency injection container with lazy loading

8 Upvotes

Hi everyone,

I’ve been developing a small, minimalist DI container for PHP and just published it on GitHub.

I'm not a huge fan of heavy frameworks, so I like building small components that do what I need. I would love any feedback, suggestions, or thoughts!

Some key features:

  • Lightweight - single PHP file with less than 200 lines of code, no dependencies.

  • Cached Reflection: Speeds up repeated creations.

  • Lazy Loading (PHP 8.4+): Only initializes classes when needed.

  • Shared Instances: Easily create singletons.

  • Interface Bindings: Seamlessly wire interfaces to implementations.

  • IDE-Friendly: Thorough docblocks for better autocompletion.

  • Immutable Setup: Each config change returns a new container.

Repo: github.com/rammewerk/container

I’d really appreciate any feedback on the project or overall approach - thanks!

UPDATED:

Benchmark repo: https://github.com/rammewerk/php-di-container-benchmarks
Benchmark results can be found under Doc's folder or view here: https://html-preview.github.io/?url=https://github.com/rammewerk/php-di-container-benchmarks/blob/master/docs/benchmark.html


r/PHPhelp • • Oct 27 '24

Parallel and multithread operations in php 8.xx

8 Upvotes

Hello all. In php 7.3 we had Pthreads, but time moves and now actual version of php is 8.3 as minimal. So as for windows only platform is there any actual way for, for example, read parts of file in parallel or work with very large array in several threads? The only solution I found is the fresh release of parallel extension v1.2.4, but It keep printing fatal error and shutdown my whole apache server even if I'm running example from manual(php 8.3.10 ZTS).

Maybe anyone of you already found any working solution and using it on your production? Very interest in that kind of stuff to solve my problem...


r/PHPhelp • • Oct 22 '24

session_start() taking random amounts of time

8 Upvotes

My PHP (8.2) app on Windows, running on Xampp, has started to become slow. I've narrowed the delays to being at least partly happening while session data is being written.

This code, with nothing else on the page

$start= microtime(true);
session_start();
echo "Time: " . (microtome(true)-$start);

might for example take 0 seconds 50% of the time, but sometimes it takes up to 100 seconds and a lot of the time around 3-20 seconds.
Other more complicated code takes a lot less time. This is after a reboot, so no CPU or memory issues. The code works fine on our website, just a problem locally and only on my laptop (other devs using other OS have no problem).

Have you experienced similar or know what might be causing this?


r/PHPhelp • • Sep 20 '24

Solved How can I achieve parallel execution of various blocking tasks in PHP? I’m looking for different types of tasks, not just using curl_multi to send HTTP requests.

8 Upvotes

I previously researched fibers but found they don't solve this problem. I came across two libraries:

  • 1,The parallel extension on the PHP official website:

https://www.php.net/manual/zh/book.parallel.php

https://github.com/krakjoe/parallel

  • 2,The Spatie Async package:

https://packagist.org/packages/spatie/async

This library claims, "If the required extensions (pcntl and posix) are not installed in your current PHP runtime, the Pool will automatically fallback to synchronous execution of tasks."

I want to understand if these two libraries can achieve the effect I want. What are the fundamental differences between them?


r/PHPhelp • • Sep 17 '24

Base Class & Interfaces or Abstract Classes - I'm lost when to use what

8 Upvotes

I understand a base class provides common methods to other classes that extend it.

And from what I've read, Interfaces provide a way to make sure that a method exists in your class.

It seems that Abstract class combines the two into a single file, so I'm a bit confused on when to use what.

Let's say I have a method called get_device() that is shared amount LaptopDevice, DesktopDevice, and MobileDevice classes.

Each device class gets a list of devices from its device type.

Would I do something like:

abstract class AbstractDevice {
   public function get_device() {
       return $this->device;
   }
}

class MobileDevice extends AbstractDevice {
}

or this

class Device implements DeviceInterface {
    public function get_device() {
       return $this->device;
    }
}

class MobileDevice extends Device implements DeviceInterface {
}

r/PHPhelp • • Jul 08 '24

Hackable?

8 Upvotes

Bit of a vague question here, I realise, but I’m looking to set my mind at ease (or otherwise).

I have a PC running Apache, PHP and MariaDB installed on a Windows PC. The PC runs a touchscreen which is used to access the web app I created.

The web app accesses an external rest api using an https connection and an authentication token, which is saved in one of the php files.

The system is also accessible via http within the local network.

So my question is is there any way someone could gain access to the query that the apache install sends to the remote api? The physical folder on the PC is secured with the relevant domain access control and the PC is logged in as a user who has no access to the htdocs folder.

Any remote connections would not be able to intercept any traffic between the PC running Apache etc and the external api - is that correct?

Ultimately I want to ensure no one can get hold of the access token for the rest api, either on the physical PC or through network traffic.

Cheers.


r/PHPhelp • • Jun 16 '24

Is Laravel overkill for an online store in 2024? Should I just use Shopify?

8 Upvotes

I've not been doing any coding for a few years but excited to get back into by learning Laravel.

The first thing I want to build is an ecommerce site for selling clothes. I would love to use a PHP framework like Laravel for it but I feel like it might be overkill to get a online store off the ground when ready-made solutions like Shopify exist. I have never built an ecommerce site before or used Shopify.

I understand the transactional costs are pretty much the same for a small business using Laravel with stripe vs. Shopify with Stripe/Shopify payments. The only difference that would make Laravel a bit cheaper is that there is no monthly fee like with Shopify. However, with Laravel, there is the time it takes to build and deploy the site plus hosting costs etc.

I will need to learn a lot about digital marketing and selling online too, so not sure if SEO, Google Analytics etc work the same in Laravel and Shopify and if that affects the choice of one over the other.

Basically, what is the best solution for my use case of an online shop? A framework like Laravel or Shopify in 2024?


r/PHPhelp • • May 16 '24

For those of you on Windows, how have you set up your personal development environment?

8 Upvotes

At work we're using Windows and our development process is to edit locally and push up to a remote dev server. After everything is good, we copy the code over into production.

I would really like to get a more modern development practice. I'd like to be able to debug locally within PHP storm. I would also like to have git pull down code and push up and have a good solid PR process.

Can someone give me some suggestions or pointers?


r/PHPhelp • • May 12 '24

Tips for memory-efficient PHP?

8 Upvotes

What the title says

I'm a dev for a simple backend for an indie game with user-made levels servers

Because this game will be going live for free we'll be paying for servers with our pockets, we need each request to eat up as little RAM as possible, we expect hundreds of connections at once

If anyone got tips for memory efficient code (So php processes don't get a single byte more than needed), any profiling or functions that might help, apache configs, data transfer and how to avoid php from dealing with unnecessarily huge requests, effective MySQL InnoDB querying or anything I might not know, I'd appreciate it

It's all Rest API & we're hosting on NearlyFreeSpeech


r/PHPhelp • • May 08 '24

I want to relearn PHP

8 Upvotes

I used to do a bit of programming in PHP a long time ago (20 years aog) and I would like to relearn.

I can read code, and generally workout what it is doing, but have lost the art of programming.

I have worked through some things on Laracasts but I prefer using physical books to learn from.

I would say, im not an absolute beginner but im also below intermediate.

Can anyone suggest a great text book to use for learning?