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

Allow custom routes #64

Closed
wants to merge 1 commit into from

Conversation

MarkIvanowich
Copy link

Matching a proposed PR in Fortity, This PR adds the ability to override Jetstream's routes file with an option in the configuration file.

Related issue/feature request: laravel/fortify#9 and Fortify PR: laravel/fortify#10

For my example use case, I put a route prefix before all authentication endpoints. This PR would allow Jetstream and Fortify the same flexibility.

When using the laravel/ui package, defining routes was an opt-in by calling the Auth::routes() on the app's routes file. In Jetstream and Fortify, they are booted with autoloading.

(I ❤️ Laravel)

@rodrigopedra
Copy link

Hi @MarkIvanowich

I think in this PR you should also try changing the hard-coded routes to use the route() helper and get them by name.

This way when someone customize the routes they can still use the shipped view files if they keep the same route names.

On my PR to laravel/fortify I didn't find any hard-coded route path (actually on logout action it redirects to route('/') but that is harmless)

@MarkIvanowich
Copy link
Author

MarkIvanowich commented Sep 5, 2020

changing the hard-coded routes to use the route() helper and get them by name

I'm 50/50 about going in and changing the hard-coded routes by name.

Originally, I was thinking quite narrowly with my specific use case. I thought your commit was more flexible [overriding a routes file path], which I then copied here.

If the user edits config/jetstream.php to add the line

'routes' => base_path('routes/jetstream.php')

They would need their own copy of the package's routes file, which is the same as a vendor:publish. If they publish the routes, then they are likely to have already published the views.

I'll create another branch and PR for it, just in case.

@m1guelpf
Copy link
Contributor

m1guelpf commented Sep 5, 2020

See #54

@rodrigopedra
Copy link

rodrigopedra commented Sep 5, 2020

Hi @m1guelpf

I was looking at commit 70fe396

To see the changes as PR #54 UI lists no changed files ( link to "Files Changed" tab ) (it seems you have pull bot enabled on your account https://github.com/apps/pull )

One doubt: just publishing the routes will make the service provider aware it would need to load the user-land published routes and not the package one?

Asking because in line 167 below the path to the routes file is hard-coded:

protected function configureRoutes()
{
Route::group([
'namespace' => 'Laravel\Jetstream\Http\Controllers',
'domain' => config('jetstream.domain', null),
], function () {
$this->loadRoutesFrom(__DIR__.'/../routes/'.config('jetstream.stack').'.php');
});
}

I think we still need to tweak the configureRoutes method to load the published file.

Let me know if I am missing something

@MarkIvanowich
Copy link
Author

After the strangeness from the pull bot is gone, I much prefer #67 over this, so I'm closing.

Now to get similar operation into Fortify...

@MarkIvanowich MarkIvanowich deleted the custom-routes branch September 6, 2020 00:33
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

Successfully merging this pull request may close these issues.

None yet

3 participants