How to redirect to a different request type?

sweet, no rush Tim and thank you

Have a look… https://github.com/tflight/auth-example

I’m looking now! -so cool

Bravo! Bravo! well done Tim. Now this really gives me something to play around with. And I really appreciate the comments you’re using throughout.

I had to include the Auth class as it was not (maybe update the repo with an autoloader so it works right out of the box for anyone downloading this superb example)

I just put this in the index.php:
require __DIR__ . '/../src/middleware/Auth.php';

Thanks again, I’m sure I’ll have some questions, but this really gives me something to study! :slight_smile:

I am loading composer’s autoloader index.php#L12, and using PSR-4 to load the App namespace, so it shouldn’t need an include(). (And you probably don’t want that file loading when it isn’t needed.) Perhaps try running $ composer dump-autoload -o on the command line?

aha, I figured it out Tim,

I had my “vender” directory inside of composer/vender/
and not at the root level of the app.

Is there a way to keep composer stuff inside composer and have the autoload work as expected?
Is there a reason you have have vendor located in main dir?

The vendor directory composer creates is in the same directory as the composer.json file, which is located in the project root. Or at least that is the way I’ve always seen it done. Composer will keep everything it does inside the vendor directory, you typically don’t touch anything in there.

project/
    src/
    config/
    public/
        index.php
    tests/
    vendor/
        autoload.php
        slim/
    composer.json
    composer.lock
    phpunit.xml

Tim, in your login example you included this line:
<input type="hidden" name="_METHOD" value="POST">

Is this some kind of fallback for old browsers or something? Is this part of Slim’s recommendation and Slim will parse this accordingly? (Obviously I looked around but alas can’t find any documentation on this)

That line shouldn’t be there, or at least shouldn’t be necessary. I probably copied over another form that might have been overriding to a DELETE method or something.

Browsers support GET and POST, anything else needs to be overridden, as described in the docs at The Request Method.

Okay, I see.

thanks!