Genesis Laravel Starter Kit

repository·main·Indexed 23 days ago

https://github.com/thedevdojo/genesis

A Laravel starter kit built on the TALL stack (Tailwind, Alpine, Laravel, Livewire), utilizing Folio for page-based routing and Volt for single-file Livewire components. It includes pre-built UI components, multiple layouts (App, Marketing, and Main), and integrated testing with Pest.

Tokens
2K
Snippets
8
Records
13
Agent score
78%

What's inside Genesis

  1. Use Genesis layouts

    main

    Genesis provides three main layouts located in resources/views/components/layouts. You can use them as Blade components:

    1. App Layout (x-layouts.app): For authenticated application pages.
    2. Marketing Layout (x-layouts.marketing): For public-facing pages like the homepage or blog.
    3. Main Layout (x-layouts.main): The base HTML structure. Both app and marketing inherit from this. Use it directly for pages that need neither header nor footer (e.g., auth pages).

    Example usage:

    <x-layouts.app>
        <!-- content here... -->
    </x-layouts.app>
    <!-- App Layout -->
    <x-layouts.app>
        <!-- content here... -->
    </x-layouts.app>
    
    <!-- Marketing Layout -->
    <x-layouts.marketing>
        <!-- content here... -->
    </x-layouts.marketing>
    
    <!-- Main Layout -->
    <x-layouts.main>
        <!-- content here... -->
    </x-layouts.main>
  2. Protect pages with authentication middleware

    main

    To ensure a user is both authenticated and verified before accessing a page (like the Dashboard or Edit Profile pages), apply the following middleware in your Folio page file:

    middleware(['auth', 'verified']);
  3. Configure homepage redirection middleware

    main

    The homepage (resources/views/pages/index.blade.php) includes a redirect-to-dashboard middleware by default. This automatically redirects authenticated users to the dashboard.

    To disable this behavior and allow authenticated users to view the homepage, remove the following line from the top of the file:

    middleware(['redirect-to-dashboard']);
  4. Install Genesis via Laravel Installer

    main

    You can install the Genesis starter kit using the Laravel Installer. After installation, run the asset watcher to start developing.

    1. Install using the --using flag:
      laravel new my-app --using=devdojo/genesis
    2. Start the asset watcher:
      composer run dev
    laravel new my-app --using=devdojo/genesis
  5. Troubleshoot layout and NPM issues

    main

    View Line Numbers in Layout

    If line numbers appear in your rendered views, clear your view cache:

    php artisan view:clear

    NPM/Vite Errors

    If you encounter errors on http://localhost:5173, try upgrading your dependencies:

    npm upgrade

    Laravel Installation/URL Mismatches

    If APP_URL settings cause issues between Vite and the Laravel server, use the standard composer method:

    1. Create the project:
      composer create-project --prefer-dist laravel/laravel genesis-app
    2. Update .env:
      APP_URL=http://127.0.0.1:8000
    3. Start both servers:
      npm run dev
      php artisan serve
  6. Configure core application settings in app.php

    main

    The config/app.php file defines the fundamental behavior of the application. Most settings are driven by environment variables defined in your .env file. Key configuration areas include:

    • Identity: name sets the application name used in UI elements and notifications.
    • Environment & Debugging: env defines the current environment (e.g., production, local), and debug (boolean) toggles detailed error messages and stack traces.
    • Connectivity: url is used by the Artisan CLI to generate correct URLs.
    • Localization: locale sets the default language, fallback_locale provides a backup if a translation is missing, and faker_locale configures the data generator.
    • Security: key is the encryption key used by Laravel's encryption services. It should be a random 32-character string. previous_keys allows for seamless key rotation by providing a comma-separated list of older keys via APP_PREVIOUS_KEYS.
  7. Configure maintenance mode drivers

    main

    Maintenance mode can be managed using different drivers. This determines how the application's 'down' status is tracked and shared across instances.

    • file driver: Stores the maintenance status in a local file.
    • cache driver: Allows maintenance mode to be controlled across multiple machines/servers by using a shared cache.

    Configure these via the maintenance array in config/app.php or using the APP_MAINTENANCE_DRIVER and APP_MAINTENANCE_STORE environment variables.

  8. Reference: Genesis UI Components

    main

    Genesis includes several pre-built Blade components located in resources/views/components/ui.

    General Components:

    • button
    • checkbox
    • input
    • light-dark-switch
    • link
    • logo (Update this component to change the logo site-wide)
    • modal
    • nav-link
    • placeholder
    • select
    • text-link

    Layout-Specific Components:

    • app.header
    • marketing.header
    • marketing.breadcrumbs
  9. View application routes

    main
    Genesis uses Laravel Folio for page-based routing. To see all 11 default routes (including homepage, auth, dashboard, and profile) currently in your application, use the php artisan folio:list command.
    php artisan folio:list
  10. Configure application routing and middleware in bootstrap/app.php

    main

    The bootstrap/app.php file is the entry point for configuring the Laravel application instance. It uses a fluent API to define routing, middleware, and exception handling.

    To register custom middleware aliases, use the withMiddleware method and call $middleware->alias() with an associative array where the key is the alias name and the value is the fully qualified class name of the middleware.

    return Application::configure(basePath: dirname(__DIR__))
        ->withRouting(
            web: __DIR__.'/../routes/web.php',
            commands: __DIR__.'/../routes/console.php',
            health: '/up',
        )
        ->withMiddleware(function (Middleware $middleware) {
            $middleware->alias([
                'redirect-to-dashboard' => \App\Http\Middleware\RedirectToDashboard::class
            ]);
        })
        ->withExceptions(function (Exceptions $exceptions) {
            //
        })->create();
  11. Reference: Application configuration environment variables

    main

    The following environment variables are used to configure the application settings in config/app.php:

    Env VarDescription
    APP_NAMEThe name of your application
    APP_ENVThe current application environment (e.g., production)
    APP_DEBUGBoolean flag to enable/disable detailed error reporting
    APP_URLThe root URL of the application
    APP_LOCALEThe default locale for translations
    APP_FALLBACK_LOCALEThe fallback locale if a translation is missing
    APP_FAKER_LOCALEThe locale used by the Faker library
    APP_KEYThe primary encryption key
    APP_PREVIOUS_KEYSA comma-separated list of previous encryption keys for rotation
    APP_MAINTENANCE_DRIVERDriver for maintenance mode (file or cache)
    APP_MAINTENANCE_STOREThe storage location for maintenance mode status