Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

4external's avatar

Cannot change default App in bootstrap. Class not found.

Hi!

I create new MyApp.php in \app

<?php

namespace App\Application;

use App\SHA512Hasher;
use Laravel\Lumen\Application;

class MyApp extends Application
{
    /**
     * Register container bindings for the application.
     *
     * @return void
     */
    protected function registerHashBindings()
    {
        $this->singleton('hash', function () {
            return new SHA512Hasher(); // here's your custom hasher
        });
    }
}

In \bootstrap\app.php


<?php

require_once __DIR__.'/../vendor/autoload.php';

try {
    (new Dotenv\Dotenv(__DIR__.'/../'))->load();
} catch (Dotenv\Exception\InvalidPathException $e) {
    //
}

//$app = new Laravel\Lumen\Application(
//    realpath(__DIR__.'/../')
//);

$app = new  App\Application\MyApp( // change here
    realpath(__DIR__.'/../')
);

$app->withFacades();

But when run app i get error

Fatal error: Uncaught Error: Class 'App\Application\MyApp' not found in /var/www/4external/data/www/newapp/bootstrap/app.php:26 Stack trace: #0 /var/www/4external/data/www/newapp/public/index.php(14): require() #1 {main} thrown in /var/www/4external/data/www/newapp/bootstrap/app.php on line 26

What i do wrong?

0 likes
3 replies
4external's avatar

Ok.

Or i need move MyApp.php in \app\Application or MyApp.php declare in App\

Abdelrage's avatar

@4external salut j'ai le même problème aujourd'hui avec bootstrap dans laravel 10 comment résoudre s'il te plait ?

martinbean's avatar
Level 80

@4external Yes. Your namespace should follow your directory layout. This is the PSR-4 autoloading standard.

Please or to participate in this conversation.