Fix Class JRequest Not Found in Joomla 4, 5, and 6

error jrequest not found joomla scaled

Written by

in

Class ‘JRequest’ not found means your extension, template override, or custom PHP still calls the removed Joomla 1.x/2.x/3.x request helper. JRequest was deprecated for years and is gone in Joomla 4+. It is not restored by the Behaviour – Backward Compatibility plugins. Replace every call with the Joomla Input API: Factory::getApplication()->getInput() (or $this->input inside a core MVC controller).

This is one of the most common fatals after a Joomla 3 to 4 upgrade, and it still appears on Joomla 5 and 6 when an old module, plugin, or child-template override was never updated. Official Input docs: Joomla Input.

What you will learn

  • Why Joomla removed JRequest and why the compat plugin will not bring it back
  • Exact old → new code replacements for getVar, getInt, getCmd, and related helpers
  • How to find every remaining JRequest usage on the server
  • Controller, module, plugin, and template override patterns that stay valid on Joomla 6
  • How filters work so you do not silently break integers, HTML, or form arrays

Why the error appears after upgrading

On Joomla 3, JRequest::getVar('foo') still ran (with deprecation noise in newer 3.x). On Joomla 4, 5, and 6 the class file is not loaded. PHP throws a fatal error as soon as that line executes.

Typical sources:

  • Custom components and modules written for Joomla 2.5 / 3
  • Abandoned third-party extensions
  • Template overrides copied from an old html/ folder
  • One-off scripts in the site root or a cli/ helper

The Behaviour – Backward Compatibility plugins bridge selected later APIs. They do not reintroduce JRequest. See our Behaviour – Backward Compatibility guide for what those plugins actually restore.

Old JRequest call Modern replacement Notes
JRequest::getVar('x') $input->get('x', null, 'STRING') or typed helper Default filter for get() is CMD, not “anything goes”
JRequest::getInt('id') $input->getInt('id', 0) Always pass a default
JRequest::getCmd('task') $input->getCmd('task', '') Safe for option/task style tokens
JRequest::getBool('check') $input->getBool('check', false) Watch string "false" quirks; prefer real booleans
JRequest::getWord('layout') $input->getWord('layout', '') Letters and underscore only
JRequest::getFloat('price') $input->getFloat('price', 0.0) Or getDouble where available
JRequest::getMethod() $input->getMethod() / server method checks Prefer framework request method helpers when available
JRequest::setVar('x', $v) $input->set('x', $v) Use def() when you only want to set if missing

Step 1: Capture the full stack trace

Turn on error reporting on staging (or read administrator/logs/ and the PHP / server error log). The fatal line path tells you whether to edit an extension, a template override, or a custom file.

Example message:

Error: Class "JRequest" not found
Calling: templates/YOUR_TEMPLATE/html/.../default.php:42

Fix that file first. Searching the whole tree still matters because several files may call JRequest.

Step 2: Find every JRequest usage

From the site root (SSH) or a project-wide search in your IDE:

grep -R --include="*.php" -n "JRequest" .
# or
rg -n "JRequest" -g "*.php"

Also search case variants and legacy imports:

rg -n "jrequest|JRequest::" -g "*.php" -i

Skip libraries/ core and vendor trees unless you overwrote core (you should not). Focus on components/, modules/, plugins/, templates/, and any custom src/ folders.

Step 3: Replace with Factory::getApplication()->getInput()

Preferred modern form (Joomla 4, 5, and forward-compatible with Joomla 6 guidance):

use Joomla\CMS\Factory;

$input = Factory::getApplication()->getInput();
$data  = $input->get('data', '', 'STRING');
$id    = $input->getInt('id', 0);
$task  = $input->getCmd('task', '');

Avoid the older property access when you can:

// Works on many CMS installs, but the public ->input property is deprecated for new code
$input = Factory::getApplication()->input;

Joomla’s migration notes recommend getInput() instead of reading the input property directly. See Joomla 5.4 → 6 deprecations.

Old code

$data = JRequest::getVar('data');
$id   = JRequest::getInt('id');
$view = JRequest::getCmd('view');

New code

use Joomla\CMS\Factory;

$input = Factory::getApplication()->getInput();
$data  = $input->get('data', null, 'STRING');
$id    = $input->getInt('id', 0);
$view  = $input->getCmd('view', '');

Step 4: Use $this->input inside MVC controllers

If your class extends Joomla\CMS\MVC\Controller\BaseController, Input is already available:

$id   = $this->input->getInt('id', 0);
$data = $this->input->post->get('jform', [], 'array');

Do not call Factory::getApplication() again unless you are outside that controller context.

Step 5: Match filters to the old intent

Blindly changing getVar to $input->get('name') can break values because the default filter is CMD (strips many characters). Pick the filter that matches the old third argument or helper name.

  • INT / getInt for IDs and counts
  • CMD / getCmd for option, view, task, layout tokens
  • STRING / getString for normal text (HTML tags stripped)
  • HTML when you must keep markup more carefully (still sanitize before output)
  • ARRAY for jform style posts: $input->post->get('jform', [], 'array')
  • RAW only when you fully trust and validate afterward

Typed helpers keep code readable:

$name = $input->getString('name', '');
$qty  = $input->getInt('quantity', 0);
$ok   = $input->getBool('agree', false);

Step 6: GET vs POST vs files

Use nested input when the source matters:

$getOnly  = $input->get->get('p1', 0, 'int');
$postOnly = $input->post->get('p1', 0, 'int');
$files    = $input->files->get('jform');

On SEF sites, routing values like option and view come from the router as well as query strings. Prefer the main $input->getCmd('view') unless you intentionally need raw GET only.

Step 7: Fix template overrides and modules

Overrides under templates/TEMPLATE/html/ often keep decade-old snippets. After replacing JRequest:

  1. Clear Joomla cache
  2. Reload the exact menu item that crashed
  3. Re-run the project-wide search until zero hits remain in site-owned PHP

For modules using a modern Dispatcher, inject Input (or read it from the application) instead of static JRequest calls. The official Input manual includes a full module sample.

Step 8: Prefer updates over patches when the vendor still exists

If the fatal sits inside a third-party extension:

  1. Install the vendor’s Joomla 4/5/6 native package
  2. Only then patch local forks if the product is abandoned
  3. Document every local patch so the next update does not overwrite your fix blindly

A one-line site patch is fine for an override you own. It is a poor long-term plan inside administrator/components/com_oldthing/ that you did not write.

Situation Best action
Your custom module / override Replace with getInput() and commit the change
Maintained commercial extension Upgrade to the Joomla 4+ package from the vendor
Abandoned extension Patch if small, or replace the extension
Only one leftover JRequest in a child template Fix the override; do not hack core

Key takeaways

  1. JRequest does not exist on Joomla 4, 5, or 6. The fatal is expected until you remove the calls.
  2. Use Factory::getApplication()->getInput() or $this->input in MVC controllers.
  3. Map old helpers to typed getters and explicit filters. Default get() uses CMD.
  4. Search the whole site tree. One fixed file is not enough if overrides still call JRequest.
  5. Compatibility plugins will not resurrect JRequest. Update the code.

Frequently asked questions

What does Class ‘JRequest’ not found mean in Joomla 4?

PHP tried to call the removed JRequest class. Update that code to the Input API before the page can load.

Does this still happen on Joomla 5 and Joomla 6?

Yes. Any leftover JRequest call fatals on current majors the same way.

Will Behaviour – Backward Compatibility fix JRequest?

No. Those plugins bridge other legacy pieces. JRequest must be replaced in code.

Is JFactory::getApplication()->input still OK?

It often still works, but new code should call getInput(). Prefer use Joomla\CMS\Factory over legacy JFactory aliases when you touch the file.

Why did my value become empty after switching to input->get()?

You probably hit the default CMD filter. Use STRING, INT, or another filter that matches the old getVar intent.

How do I read jform POST data now?

Use $input->post->get('jform', [], 'array'), then validate in the model the same way core components do.

Can Infyways fix this on a client site?

Yes. If you need a Joomla 3 to 4/5/6 upgrade with extension and override cleanup, contact Infyways.