itsjoshbruce's avatar

Laravel 6 (upgrade from 5.8) Failing to Find Route and 404 Page

I'm getting ready to delve into deeper pages for my site. Created route group (practitioners). Created home page URL (get). Created profile page route (get). Went from link on homepage to profile page, the following happened.

(Can't upload images, sorry.)

Anybody seen something like this before??

0 likes
6 replies
bobbybouwmann's avatar

I think something goes wrong in your vendor directory or your caching. So make sure you run composer autoload, php artisan cache:clear and php artisan clear-compiled.

If this doesn't work just delete the vendor directory and run composer install again!

itsjoshbruce's avatar

Ran an experiment by taking out the other sites (domain route group).

Worked like a charm. Unfortunately, I would really like to avoid having to install Larvel 4 times; so, not sure what I'm doing wrong here.

Here's the domain route for each site - only difference being the env reference:

Route::domain(env('DOMAIN_PRO'))->group(function () {

Decided to see what would happen if I took and combined all the domain routes into one provider. That seemed to work, but it kind of makes me concerned about having routes in multiple service providers.

Thoughts??

bobbybouwmann's avatar

You should be able to register routes through different service providers, however they shouldn't interfere with each other of course!

Can you share some more relevant code?

itsjoshbruce's avatar

Sorry it's taken a moment was messing around with things.

Not sure what other code would be relevant. Here's more of what I have that's actually working - though not as separate service providers - just separate route files.

class AmosProvider extends ServiceProvider
{
    public function register()
    {
        // Hosts images
        $this->loadRoutesFrom(__DIR__.'/routes-link.php');

        $this->loadRoutesFrom(__DIR__.'/routes-pro.php');
        $this->loadRoutesFrom(__DIR__.'/routes-dev.php');
        $this->loadRoutesFrom(__DIR__.'/routes-media.php');

        $this->loadViewsFrom(__DIR__.'/', "amos");
    }
Route::domain(env('DOMAIN_PRO'))->group(function () {
    Route::get('/', function () {
        return view("amos::default")
            ->with("view",
                UIKit::webView(
                    "",
                    UIKit::featuredPractitioners()->noBottomBorder(),
                    UIKit::appearanceLinks()->noTopBorder()
                )
        );
    })->middleware("web")->name("pro::index");

    Route::prefix('practitioners')->group(function() {
        Route::get("/", function() {
            return UIKit::practitionersPage();
        })->middleware("web");

        Route::get("{username}", function($username) {
            return UIKit::practitionerPage($username);
        })->middleware("web");
    });

    Route::post('/', function (Request $request) {
        return ProProvider::processNewsletterSignUp($request);
    })->middleware("web");

    Route::post('request-invite', function (Request $request) {
        return ProProvider::processInitationRequest($request);
    })->middleware("web");

});

The shortest routes file but pretty much the canonical pattern for all of them.

Not much has changed compared to when I was trying to do each as a separate service provider. The routes would get loaded separately with separate service providers though.

itsjoshbruce's avatar
itsjoshbruce
OP
Best Answer
Level 3

Think I discovered what the issues were.

  1. The domain had a number in it and seems to have been causing an issue with MAMP Pro (saw mention of this in a Stack answer.

  2. When I created multiple providers and promoted a more global/abstract to be included I used include_once instead of include, which caused a loss of some of the routes.

Now I appear to be able to have 3 (of 5) providers, each with a different domain group using env(). 2 of them are using files and classes from the 3rd that is the more generic implementation.

Please or to participate in this conversation.