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

mstdmstd's avatar

Making Resets Passwords functionality I got \Mail\\Factory] is not instantiable error

Hi all, In my lumen 8.0 app I want to add Resets Passwords functionality reading https://stackoverflow.com/questions/37338015/trying-to-reset-passwords-in-lumen article but I got error :

{
    "message": "Target [Illuminate\Contracts\Mail\Factory] is not instantiable while building [Illuminate\Notifications\Channels\MailChannel].",
    "exception": "Illuminate\Contracts\Container\BindingResolutionException",
    "file": "/mnt/_work_sdb8/wwwroot/LumenProjects/PublishPagesAPI/vendor/illuminate/container/Container.php",
    "line": 1089,
    "trace": [
        {
            "file": "/mnt/_work_sdb8/wwwroot/LumenProjects/PublishPagesAPI/vendor/illuminate/container/Container.php",
            "line": 882,
            "function": "notInstantiable",
            "class": "Illuminate\Container\Container",
            "type": "->"
        },
        {
            "file": "/mnt/_work_sdb8/wwwroot/LumenProjects/PublishPagesAPI/vendor/illuminate/container/Container.php",
            "line": 754,
            "function": "build",
            "class": "Illuminate\Container\Container",
            "type": "->"
        },
        {
            "file": "/mnt/_work_sdb8/wwwroot/LumenProjects/PublishPagesAPI/vendor/illuminate/container/Container.php",
            "line": 692,
            "function": "resolve",
            "class": "Illuminate\Container\Container",
            "type": "->"
        },

In my composer.json :

{
    "name": "laravel/lumen",
    "description": "The Laravel Lumen Framework.",
    "keywords": ["framework", "laravel", "lumen"],
    "license": "MIT",
    "type": "project",
    "require": {
        "php": "^7.3|^8.0",
        "anik/form-request": "^4.2",
        "cviebrock/eloquent-sluggable": "^8.0",
        "dusterio/lumen-passport": "^0.3.4",
        "flipbox/lumen-generator": "^8.2",
        "guzzlehttp/guzzle": "^7.3",
        "illuminate/mail": "^8.48",
        "illuminate/notifications": "^8.49",
        "intervention/image": "^2.5",
        "laravel/lumen-framework": "^8.0",
        "league/flysystem": " ~1.0"
    },
    "require-dev": {
        "fakerphp/faker": "^1.9.1",
        "mockery/mockery": "^1.3.1",
        "phpunit/phpunit": "^9.3"
    },
    "autoload": {
        "files": [
            "app/library/helper.php"
        ],
        "psr-4": {
            "App\": "app/",
            "Database\Factories\": "database/factories/",
            "Database\Seeders\": "database/seeders/"
        }
    },
    "autoload-dev": {
        "classmap": [
            "tests/"
        ]
    },
    "config": {
        "preferred-install": "dist",
        "sort-packages": true,
        "optimize-autoloader": true
    },
    "minimum-stability": "dev",
    "prefer-stable": true,
    "scripts": {
        "post-root-package-install": [
            "@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
        ]
    }
}

Do I need to install some packages and how to init it in my package ?

0 likes
2 replies
mstdmstd's avatar

Thanks! It helped, but next I got error:

: Route [password.reset] not defined. at /mnt/_work_sdb8/wwwroot/LumenProjects/PublishPagesAPI/vendor/laravel/lumen-framework/src/Routing/UrlGenerator.php:231)

and checking related code I see in Notifications/ResetPassword.php:

    public function toMail($notifiable)
    {
        \Log::info(  varDump($notifiable, ' -1 $notifiable::') );
        \Log::info(  varDump(static::$toMailCallback, ' -2 static::$toMailCallback::') );
        if (static::$toMailCallback) {
            return call_user_func(static::$toMailCallback, $notifiable, $this->token);
        }

        \Log::info(  varDump(static::$createUrlCallback, ' -3 static::$createUrlCallback::') );
        if (static::$createUrlCallback) {
            $url = call_user_func(static::$createUrlCallback, $notifiable, $this->token);
        } else {

            $url = url(route('password.reset', [
                'token' => $this->token,
                'email' => $notifiable->getEmailForPasswordReset(),
            ], false));
        }

        return $this->buildMailMessage($url);
    }

and checking log I see :

[2021-07-01 13:35:04] local.INFO: NULL : -2 static::$toMailCallback:: : NULL  
[2021-07-01 13:35:04] local.INFO: NULL : -3 static::$createUrlCallback:: : NULL 

Looks like in come config file I have to set these variables? Could you please point where and which parameters?

Also as this article was written for lumex 5, if Notifications good decision for lumen 8?

Please or to participate in this conversation.