Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Abrown's avatar
Level 1

Laravel Jetstream

Hey everyone! first time working with laravel jetstream, when I followed the instructions for creating a jetstream project, I noticed the files for APIs - middleware, http were not created. my directory that was auto created goes app/http & controllers - (there really isnt a &, because its technically got /, but not for directory level. the file name is actually http/controller)

anyway, I am rather far into a project and trying to set up authentication. How can I rectify this?

0 likes
9 replies
LaryAI's avatar
Level 58

Certainly! It sounds like you're having some confusion with the directory structure and the files that should be present when setting up Laravel Jetstream. Let's clarify a few things and provide a solution to ensure you have the necessary files for authentication.

Step-by-Step Solution:

  1. Install Laravel Jetstream: If you haven't already installed Jetstream, you can do so using Composer. Make sure you have a fresh Laravel installation or navigate to your existing Laravel project directory.

    composer require laravel/jetstream
    
  2. Install Jetstream with Livewire or Inertia: Jetstream supports both Livewire and Inertia. Choose one of them based on your preference. For example, to install Jetstream with Livewire:

    php artisan jetstream:install livewire
    

    Or, if you prefer Inertia:

    php artisan jetstream:install inertia
    
  3. Run Migrations: After installing Jetstream, you need to run the migrations to set up the necessary database tables for authentication.

    php artisan migrate
    
  4. Publish Jetstream Assets: If you need to customize the Jetstream views or components, you can publish the assets.

    php artisan vendor:publish --tag=jetstream-views
    
  5. Check Directory Structure: After running the above commands, your directory structure should include the necessary files for authentication. Specifically, you should have:

    • app/Http/Controllers/Auth directory with controllers like AuthenticatedSessionController, RegisteredUserController, etc.
    • app/Http/Middleware directory with middleware like Authenticate, RedirectIfAuthenticated, etc.
    • routes/web.php and routes/api.php for defining your routes.
  6. Verify Routes: Jetstream should automatically set up the routes for authentication. You can verify this by checking the routes/web.php file. It should include routes for login, registration, password reset, etc.

    Route::middleware(['auth:sanctum', 'verified'])->get('/dashboard', function () {
        return view('dashboard');
    })->name('dashboard');
    
  7. Run the Application: Finally, make sure your application is running correctly. You can start the development server using:

    php artisan serve
    

Example Directory Structure:

After following the above steps, your directory structure should look something like this:

app/
├── Http/
│   ├── Controllers/
│   │   ├── Auth/
│   │   │   ├── AuthenticatedSessionController.php
│   │   │   ├── ConfirmablePasswordController.php
│   │   │   ├── EmailVerificationNotificationController.php
│   │   │   ├── EmailVerificationPromptController.php
│   │   │   ├── NewPasswordController.php
│   │   │   ├── PasswordResetLinkController.php
│   │   │   ├── RegisteredUserController.php
│   │   │   ├── VerifyEmailController.php
│   │   ├── Controller.php
│   ├── Middleware/
│   │   ├── Authenticate.php
│   │   ├── RedirectIfAuthenticated.php
│   ├── Kernel.php
├── Providers/
│   ├── RouteServiceProvider.php
routes/
├── web.php
├── api.php

If you follow these steps and still face issues, please provide more details about the specific problem, and we can troubleshoot further.

Abrown's avatar
Level 1

@LaryAI yeah that does not work to provide that file structure

psion's avatar

Btw... you will find Fortify related files in App/Actions/Fortify. Also i dont really know what you mean by

I am rather far into a project and trying to set up authentication

since jetstream already comes with auth in place?

Abrown's avatar
Level 1

@psion I meant actually adding middleware to my API routes, setting up the 2fa, and also setting it up so I can use API tokens

Abrown's avatar
Level 1

@psion 11.3.1 - this is my first attempt at a Laravel project ever

psion's avatar

@Abrown if i get you right, you made a vanilla app and now that you are rather far into the project, you are trying to install Jetstream?

Please or to participate in this conversation.