r/PHPhelp

▲ 14 r/PHPhelp

Is it worth it to go without a framework?

I've been using PHP casually for decades. In the last two years I've started to try to take it more seriously, and that inevitably led me to Laravel. For basic CRUD sites, Laravel has been a godsend, allowing scaffolding of a ton of functionality pretty quickly, Blade templates make sense to me, the workflow works for me.

Deployment is where things have been tricky. Since I do this as a hobby and my user count is in the single digits per day, I use shared hosting. Deploying a Laravel application to shared hosting is pretty rough. I've managed it, but queries are extremely slow, everything feels sluggish, etc.

So, in an attempt to weigh the pros and cons, I went to packagist.org and started to look into cobbling together my own packages to find a happy medium between writing all my own libraries (I do not relish the idea of going back to this) and full-blown frameworks like Laravel.

But, I've run into an issue I did not expect: everything seems to be deprecated in the latest versions of PHP. FastRouter's page one Github documentation references classes that don't seem to exist in the project anymore, meaning that basic functionality required me digging into the code to find out why classes weren't there. PHP-Auth throws sixteen deprecation flags when just creating the instance of the Auth class.

The standalone Blade templating engine doesn't work. Twig does - and actually works as described, so kudos to them.

All of this to state my theory: Everyone in PHP has gone to Laravel or Symfony and never looked back. This has inevitably led to all the standalone packages rotting.

Or, I'm an idiot and doing something obviously wrong.

To my question: Is it even worth it to try to cobble together something small and simple anymore? Just with FastRouter, PHP-Auth, and Twig templating I'm finding my workflow is SIGNIFICANTLY slower than just using Laravel. And PHP-Auth won't even work, so I'm back to rolling my own, which I do not want to do.

I just want some simple session authenticating, I don't need OAuth2.

Anyway, I'm open to hearing discussion on this, and I'd appreciate those more knowledgeable than I chiming in.

Thank you.

reddit.com
u/KaedenCraft — 22 hours ago
▲ 0 r/PHPhelp+1 crossposts

PHP

I have an old Embarcadero PHP IDE version 3

I wanted to use it. Obviously, it does not work on my site as it now has PHP 8

So what I did I gave Claud the RPCL components PHP files to fix.

After 2 iterations, including showing the error file, it worked.

Now I can develop PHP with the old IDE.

reddit.com
u/WeightOdd5643 — 2 days ago

Advice for a third-year information technology student doing a final-year group project.

Hi guys, really need your help here ,I would be the most appreciative if I could get your advice. I am a third year information technology student doing a final-year group project. We will develop a web-based application/website, and my proposal for this project is a management system for an electrician. The owner currently uses WhatsApp, business cards and word of mouth; those are his forms of acquiring clients. my group knows these languages: HTML, CSS, PHP, MySQL, runnin on localhost (phpMyAdmin) XAMPP) and JavaScript for building a website. And the other language we have learned in college are are C++ Java and python. Could you advise me some key features and functional(like tracking adding your clients, notifications, reminders, doc of inventory, history of services, the type of services provided, dashboard and more) requirements that I should have in my project that will stand out thank you so much. I would be the most grateful for your advice from all

reddit.com
u/Ordinary_Corner_2415 — 2 days ago
▲ 14 r/PHPhelp

Looking for modern PHP (8.5+) tutorials for beginners that emphasize best practices

Hi everyone,

I'm looking to learn modern PHP from scratch, but I want to make sure I'm starting off on the right foot with contemporary tools and patterns.

I used to program in PHP when it was at 5.6, but left Web Development for a while. im back and keep moving between nodeJS and back to PHP, i still think PHP much better for Web Development for 90% of cases.

Many tutorials online still cover outdated paradigms (like procedural scripts mixed with raw HTML or deprecated MySQL functions). I'm specifically looking for comprehensive learning resources (video courses, interactive sites) that focus on Modern PHP (8.4+).

What I'm hoping to find:

  • Beginner-friendly explanations that don't skip over core fundamentals.
  • Modern PHP 8.5+ features (Property Hooks, new array/string methods, property promotion, typed properties, etc.).
  • Strict adherence to best practices (PSR standards, proper OOP concepts, PDO with prepared statements, dependency management via Composer).
  • Projects built without relying heavily on massive frameworks right away.

If you have any recommended courses, YouTube playlists, or documentation guides that match this, please drop them below!

Thanks in advance!

reddit.com
u/NightDeveloper_876 — 3 days ago

Laravel Security Inquiry

I only self learned on laravel for more than a week before being assigned other stuff during internship. And I now have a job as a software developer and already told my head about this and they assigned me with a web system project.

How do i check the security of my code since i use both claude, reddit, and some repo as basis for the project (more on claude).

I didn't use a starter kit when i started the project so everything is from scratch.

reddit.com
u/ScorpSass — 4 days ago

Using APCu or sessions to reduce MySQL queries

I have a lot of data stored in MySQL, and the values are used on every pageview. 15+ years ago, I set up sessions to reduce the queries. It's set up so that if a required session variable exists then it skips the query, but if it doesn't exist then it queries, sets the results to session variables, then maps those sessions to variables.

It looks like this:

if (session_id() === '') session_start();
 $sess_file = '/tmp/sess_' . session_id();
 if (is_file($sess_file)) chmod($sess_file, 0644);

if (!isset($_SESSION['siteID']))) {
 for ($attempt=0; $attempt < 3; $attempt++) {
  if ($attempt == 2) {
   // log error and return error page, whatever they're doing isn't working
  }

  $var_query = sprintf("SELECT * FROM vars WHERE foo='%s' LIMIT 1",
   mysqli_real_escape_string($dbh, $foo));

  $sth_vars = mysqli_query($dbh, $var_query);

  if (isset($sth_vars) && mysqli_num_rows($sth_vars)) {
   list($_SESSION['siteID'], $_SESSION['lorem'], $_SESSION['ipsum']) =
    mysql_fetch_row($sth_vars);

   $attempt = 3;
  }

  // Lookup failed, send alert and try again
  else {
   if ($attempt < 2) sleep(1);
   else exit;
  }
 }
}

session_commit();

// Map $_SESSION to variables 
foreach ($_SESSION as $session_key => $session_value) $$session_key = $session_value;

I'm setting up a new server, though, and have APCu installed.

Would APCu be a better option for this use than sessions?

reddit.com
u/csdude5 — 6 days ago

mysqli_fetch_assoc with mysql prepared statements procedural, need help

Hello, im trying to update my website by replacing the simple mysqli queries with prepared statements, but i was stuck at trying to use mysqli_fetch_assoc to fetch associative data from the table, i looked through documentation but couldnt find anything, Any help will be appreciated, Thanks !

$error = array();
if(isset($_POST["login"])) {
$username = mysqli_escape_string($db, filter_input(INPUT_POST, "username", FILTER_SANITIZE_SPECIAL_CHARS));
$password = mysqli_escape_string($db, filter_input(INPUT_POST, "password", FILTER_SANITIZE_SPECIAL_CHARS));

if(empty($username)) {
array_push($error, "Username is empty!");
}
if(empty($password)) {
array_push($error, "Password is empty");
}

$sql = "SELECT `password`, `username`, `user_id` FROM `Accounts` WHERE `username` = ?;";
if(count($error) == 0) {

$stmt = mysqli_prepare($db, $sql);

mysqli_stmt_bind_param($stmt, "s", $username);
//$result = mysqli_query($db, $sql);
mysqli_stmt_execute($stmt);
mysqli_stmt_store_result($stmt);
if(mysqli_stmt_num_rows($stmt) > 0) {
$row = mysqli_fetch_assoc($result);
if(password_verify($password, $row["password"])) {
$_SESSION["username"] = $username;
$_SESSION["user_id"] = $row["user_id"];

header("location: /");

} else {
array_push($error, "Incorrect username or password!");
}
} else {
array_push($error, "Incorrect username or password!");
}
}
mysqli_close($db);
}
reddit.com
u/Available_Hippo4035 — 8 days ago

Multiple mysql statements in one PDO::exec call?

Is this supported or is it classed as undefined behaviour? Searching the web I have found one site explaining how to do it, and a post saying it never used to be allowed but the driver added the ability around 2020. But I have not seen anything official and the (somewhat terrible) PHP documentation does not mention it at all either way.

The use case is multiple statements being needed to create and alter some temporary tables so that inserts (using prepared statements) can be processed before being added to the live tables.

reddit.com
u/UnusualBecka — 9 days ago

How do i have form submissions appear on html?

I’m fairly new to coding- specifically html. i’m working on an indie website. i want to add a “guestbook” form where people can post comments on the site. i’m running into phps and i might be completely misunderstanding how they work. in my mind im trying make a separate php and class it to my html so the responses show up- if that makes sense haha. i guess my ultimate question is how do i go about this? i have a submission box (name comment and date) i want when people fill it out their reply appears on the page. i’ve coded a lot of the website already with ccs into my html.

reddit.com
u/etherealx0x — 12 days ago