Issue 023: HTTP 500 on cPanel After Extracting Release Over Existing Directory With Deleted/Renamed Classes

📌 Context

  • Status: RESOLVED
  • Environment: PHP 8.3 / Symfony 7.4 LTS / cPanel Shared Hosting / Composer (--classmap-authoritative)
  • Date: 2026-11-24
  • Detected in: Production (cPanel subdomain), immediately after executing database migrations via phpMyAdmin following a release.zip extraction over an existing deployment. Not triggered in local development because local git checkouts remove deleted/renamed files automatically.
  • Component: config/services.yaml, vendor/composer/autoload_classmap.php, var/cache/prod/, src/Controller/Admin/RtCommunityCrudController.php (deleted in commit 6472657)

🛑 Symptoms & Error Log

After deploying an updated dist/release.zip onto an existing cPanel installation and running the migration SQL in phpMyAdmin, web requests failed with an HTTP 500 error. The production error log recorded:


[24-Nov-2026 11:14:44 UTC] 2026-11-24T11:14:44+00:00 [critical] Uncaught Exception: Expected to find class "App\Controller\Admin\RtCommunityCrudController" in file "/home/<user>/public_html/<subdomain>.<domain>/src/Controller/Admin/RtCommunityCrudController.php" while importing services from resource "../src/", but it was not found! Check the namespace prefix used with the resource in /home/<user>/public_html/<subdomain>.<domain>/config/services.yaml (which is being imported from "/home/<user>/public_html/<subdomain>.<domain>/src/Kernel.php").

Detection: The failure was noticed immediately in the cPanel error log (prod.log / PHP error_log) upon hitting the application after running the database migration in phpMyAdmin (hard HTTP 500 crash during Symfony container compilation, not a silent failure).

🔍 Root Cause Analysis / Current Hypotheses

  1. Archive extraction does not remove deleted/renamed files:

Extracting dist/release.zip over an existing cPanel directory overwrites modified files and adds new files, but leaves behind files that were deleted or renamed in newer commits.

  1. Leftover files from commit 6472657:

In commit 6472657, three classes under src/ were deleted or renamed:

  • src/Controller/Admin/RtCommunityCrudController.php -> deleted (replaced by src/Controller/Admin/CommunityCrudController.php)
  • src/Entity/RtCommunity.php -> renamed to src/Entity/Community.php
  • src/Repository/RtCommunityRepository.php -> renamed to src/Repository/CommunityRepository.php
  1. Interaction between services.yaml directory scanning and Composer --classmap-authoritative:

config/services.yaml imports all PHP files under src/ via App\: resource: '../src/'. At the same time, scripts/build-release.sh builds production dependencies with composer install --no-dev --optimize-autoloader --classmap-authoritative. Because the leftover RtCommunityCrudController.php still existed on disk in src/Controller/Admin/, Symfony’s service loader expected App\Controller\Admin\RtCommunityCrudController to exist, while Composer’s authoritative classmap no longer listed it, causing a fatal exception during container compilation.

🚫 Attempted Solutions & Failed Approaches

  • Extracting dist/release.zip over the existing deployment and running database migrations in phpMyAdmin without removing old src/ files -> Failed with Expected to find class "App\Controller\Admin\RtCommunityCrudController" in file ".../src/Controller/Admin/RtCommunityCrudController.php" while importing services from resource "../src/", but it was not found!
  • Checking/suspecting file or folder permissions -> Not the cause; permission errors on var/cache/prod/ or src/ produce Permission denied or Unable to write in the "cache" directory errors rather than a missing class error from services.yaml.

💡 Working Solution / Resolution (or Temporary Workaround)

Remove the leftover deleted/renamed files from src/ on the cPanel server and clear the production cache (var/cache/prod/*):


cd /home/<user>/public_html/<subdomain>.<domain>

# 1. Remove leftover files deleted/renamed in commit 6472657
rm -f \
  src/Controller/Admin/RtCommunityCrudController.php \
  src/Entity/RtCommunity.php \
  src/Repository/RtCommunityRepository.php

# 2. Clear production cache and warm up
rm -rf var/cache/prod/*
APP_ENV=prod php bin/console cache:warmup

🛡 Prevention / Next Steps

  • Catch it before production: Before packaging or deploying a release that deletes or renames classes under src/, check git diff --name-status <last_deployed_commit>..HEAD -- src/ for D (deleted) or R (renamed) entries, and verify APP_ENV=prod php bin/console cache:warmup succeeds after a clean extraction of dist/release.zip into a temporary directory.
  • Clean directory before extracting release.zip on cPanel: When updating an existing cPanel installation, delete src/, templates/, config/, and vendor/ before extracting the new dist/release.zip (while preserving .env.local, var/, and any uploaded user files).

Leave a Reply

Your email address will not be published. Required fields are marked *

Blue Captcha Image
Refresh

*