Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Target [Laravel\Fortify\Contracts\CreatesNewUsers] is not instantiable. #41

Closed
jparradog opened this issue Sep 3, 2020 · 7 comments
Closed

Comments

@jparradog
Copy link

  • Jetstream Version: 0.6.0
  • Laravel Version: 8.x-dev
  • PHP Version: 7.4.2
  • Database Driver & Version:mysql

Description:

After the clean installation of Laravel with jetstream and livewire, authentication and equipment, it does not allow registration.
context:
https://flareapp.io/share/OmVLBR78

Steps To Reproduce:

laravel new blog --dev
cd blog
npm install
php artisan migrate
php artisan jetstream:install livewire --teams
register new user

@rajakhoury
Copy link

Did you register the FortifyServiceProvider and JetstreamServiceProvider located in App\Providers ?

@Jubeki
Copy link
Contributor

Jubeki commented Sep 4, 2020

App\Providers\FortifyServiceProvider and App\Providers\JetstreamServiceProvider should be registered automaticly.
But It seems like the Providers are not written to the config.

I looked into the issue:
The problem lies in the install command.

protected function installFortifyServiceProvider()
{
if (! Str::contains($appConfig = file_get_contents(config_path('app.php')), 'App\\Providers\\FortifyServiceProvider::class')) {
file_put_contents(config_path('app.php'), str_replace(
"App\\Providers\RouteServiceProvider::class,".PHP_EOL,
"App\\Providers\RouteServiceProvider::class,".PHP_EOL." App\Providers\FortifyServiceProvider::class,".PHP_EOL,
$appConfig
));
}
}

It checks if the ServiceProvider is not already registered in config/app.php and then writes it to the config.
But the replacing part is not working. Even though the Str::contains(...) is working correctly.

Don't know what the issue is while replacing the RouteServiceProvider to RouteServiceProvider and FortifyServiceProvider

Same Problem with JetstreamServiceProvider.

@Jubeki
Copy link
Contributor

Jubeki commented Sep 4, 2020

It seems like under windows it works with \n instead of PHP_EOL
Don't know why though.

so it could be:

file_put_contents(config_path('app.php'), str_replace(
    "App\\Providers\\RouteServiceProvider::class,\n",
    "App\\Providers\\RouteServiceProvider::class,\n        App\Providers\FortifyServiceProvider::class,".PHP_EOL,
    $appConfig
));

Edit: Under windows PHP_EOL="\r\n" but the config file has the endings \n

@mikebronner
Copy link
Contributor

mikebronner commented Sep 4, 2020

@Jubeki This is probably something specific to your setup.
https://stackoverflow.com/questions/128560/when-do-i-use-the-php-constant-php-eol
See the answer there, does that describe your situation?

Edit: Nevermind, I see your updated comment regarding the config file. :)

@jparradog
Copy link
Author

The installer did not auto-register the service providers, FortifyServiceProvider and JetstreamServiceProvider, I already did it manually and it works fine now.
config\app.php
App\Providers\FortifyServiceProvider::class, App\Providers\JetstreamServiceProvider::class,

@taylorotwell
Copy link
Member

Can't recreate on a fresh app.

@Jubeki
Copy link
Contributor

Jubeki commented Sep 4, 2020

@taylorotwell it happens with Windows and Git.

Git replaces \r\n with \n but PHP_EOL is still \r\n so in the file config/app.php you have Line endings with \n but str_replace is looking for \r\n (PHP_EOL) so the replacing is not happening.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants