skip to Main Content

I getting started with laravel so, i don’t know much about it.
There is this youtube video i was following so far it was great however when it got to the point where i have to use middlewares i found out that i don’t have that folder in my project directory.

  • I have tried to re-create a new project,
  • i have uninstalled composer, php and laravel itself and re-installed them back again but it didn’t work still.

i have searched all over the internet for solution couldn’t find one thathelped

help me

2

Answers


  1. Middleware folder is present in appHttpMiddleware
    It is not available in a fresh laravel install.

    If you want to create your custom Middleware then you can use below command

    php artisan make:middleware Authenticate
    

    After running this command it will automatically create that folder with your middleware file inside it.

    Please make sure to include your middleware in kernel file.

    Login or Signup to reply.
  2. This was changed since Laravel 11 the Append.php has been removed and also prior to Laravel 11, you would typically never touch bootstrap/app.php. However, that is no longer the case in this new version.
    
    To create a new middleware you would have to use the following command in termianal
    
    php artisan make:middleware EnsureTokenIsValid
    
    New middleware aliases can be created in app.php 
    function (Middleware $middleware) {
        $middleware->alias([
            'some_key' => AppHttpMiddlewareMyMiddleware::class,
        ]);
    }`enter code here`
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search