#Route not working

25 messages · Page 1 of 1 (latest)

carmine bane
#

Hi, I just created a new route within my web.php
Route::get('/create-card', [App\Http\Controllers\VcardController::class, 'createCard'])->name('create-card');
And my controller:

class VcardController extends Controller
{
    public function createCard(){
        var_dump(12);
        die();
        $lastname = "Berg";
        $firstname = "Melroy";
        $additional = "van den";
        $prefix = "Mr.";
        $suffix = "";

        $vcard = new VCard();
        $vcard->add(new Name($lastname, $firstname, $additional, $prefix, $suffix));

        $formatter = new Formatter(new VcfFormatter(), 'vcard-export');
        $formatter->addVCard($vcard);
        return $formatter->download();
    }``` But it returns a 404 page.  I don't see what I'm doing wrong, or missing something
midnight stratus
#

Did you cache anything

Also return a value instead of var dumping and killing the script

carmine bane
#

I did not cache anything right now. Do I need to run a cache method in the cmd?

#

besides that I removed the var_dump, so it should download that file and stay on the old page.

#

hmm clearing route cache did not do the trick

long plaza
#

Share your whole web file.

long plaza
#

I can't open pastebin for some reason, doesn't work on my network. Can you host in a gist or something?

carmine bane
#

what's that?

long plaza
#

Its github.

carmine bane
long plaza
#

Yes

#

You are defining Route::get('/{unique_url}', function($unique_url){

#

Before your new url

#

So it is taking it over.

#

That is basically saying /any-url should try and hit that route.

carmine bane
#

oh I forgot about those rules

#

that's why that routee was down there

long plaza
#

If you move your create-card route up above it it should work.

#

And remember for the future to have that route last.

carmine bane
#

it works yeah, directly when you saw the issue I was like "oh yeah that's how routing works" haha

long plaza
#

👍 Make sure to mark as solved.

carmine bane
#

how do I do that? haha

long plaza
#

I don't actually know lol

fair pumice