Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Node.js, PHP and APIs

Laravel says Class Input not found in old code

ErrorClass 'Input' not found

Short answer

Laravel removed the Input facade in version 6.0 because it duplicated the Request facade. Code written for Laravel 5 that calls Input::get() fails on any current version. Replace it with Request::input() or the request object, and import the Request class when your file has a namespace.

  • Applies to Laravel 11, Laravel 12, PHP 8.3
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Find every use of the old facade in the application.

    grep -rn "Input::" app routes resources
  2. 2Match what you see, then jump to its fix

    1. 1Input::get(), Input::all() or Input::has() in code written for Laravel 5.x.The Input facade no longer existsFix
    2. 2The error now names a class in your own namespace, after you switched to the Request facade without importing it.A facade is used in a namespaced file without being importedFix

What does the error look like?

  • Class 'Input' not found

Cause 1 of 2

The Input facade no longer exists

1Check

The Laravel 6 upgrade guide lists the Input facade as removed. It was mostly a duplicate of Request.

grep -rn "Input::" app routes resources

2Fix

Change Input::get to Request::input. Other Input calls can use the Request facade. In controllers, prefer the injected request object.

use Illuminate\Http\Request;

public function store(Request $request)
{
    $name = $request->input('name');
}

3Verify

Reload the page that failed.

curl -I http://localhost/your-route

Confirmed by laravel.com

Did this fix it?

Cause 2 of 2

A facade is used in a namespaced file without being imported

1Check

Inside a namespace, PHP looks for an unqualified class name in that same namespace and does not fall back to the global one. Laravel's facades live in Illuminate\Support\Facades.

grep -n "^use " app/Http/Controllers/MyController.php

2Fix

Import the facade with use, or prefix it with a backslash.

use Illuminate\Support\Facades\Request;

$name = Request::input('name');

3Verify

Run the route again.

curl -I http://localhost/your-route

Confirmed by php.net

Did this fix it?

How do I stop it coming back?

  • Read the upgrade guide of each major version when a project jumps several versions.
  • Import every facade with use instead of relying on global aliases.
  • Prefer the injected Illuminate\Http\Request in controllers over any facade.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine built on the same technologies:

Related fixes

Back end

composer require maatwebsite/excel fails to install

Composer says the package needs an older PHP than the one installed

Composer refuses maatwebsite/excel when the PHP version or a PHP extension does not match what the package and PhpSpreadsheet need.

3 causes, each with a fix

Back end

composer require laravel/horizon fails: ext-pcntl is missing

laravel/horizon v1.1.0 requires ext-pcntl * -> the requested PHP extension pcntl is missing from your system

Horizon needs the pcntl extension, and Composer refuses to install it where PHP lacks that extension.

3 causes, each with a fix

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.