Backpack Demo

repository·main·Indexed 43 days ago

https://github.com/laravel-backpack/demo

A comprehensive showcase application for Laravel Backpack containing all premium and free packages. It provides a realistic 'Pet Shop' environment for developers to explore UI components, CRUD operations, and various add-ons, including a 'Crazy Stuff' page featuring every available field, column, filter, and button.

Tokens
2.4K
Snippets
8
Records
11
Agent score
56%

What's inside Backpack Demo

  1. Understand the Demo Organization and Features

    main

    The demo is structured to showcase various Backpack capabilities through a Pet Shop theme:

    • Dashboard: A realistic Pet Shop dashboard (resources/views/admin/dashboard.blade.php).
    • Core Features: Demonstrates UI (Widgets, Themes, Skins, etc.) and CRUD operations. CRUD pages can show explainer cards by appending ?explainer=<key> to the URL (text defined in config/demo.php).
    • Free & Paid Add-ons: Showcases every available package. Paid add-ons with live examples link directly to them; others link to /admin/paid/<key>.
    • Examples: Includes 'Pet Shop' (realistic app) and 'Crazy Stuff' (a single page containing every field, column, filter, and button for testing).

    Customization Drawer: Users can pick skins, layouts, and text directions via a drawer. These choices are stored in a cookie and applied by App\Http\Middleware\Theme. To force the drawer to open on page load, append ?open_drawer=true to any URL.

  2. Access and Login to the Backpack Demo

    main

    Once installed, the admin panel is typically available at http://localhost/backpack-demo/admin (or your configured local URL).

    Default Credentials:

    • Email: admin@example.com
    • Password: admin

    Note on Registration: By default, user registration is only enabled in local environments. You can modify this behavior in config/backpack/base.php.

    Email: admin@example.com
    Password: admin
  3. Run the Backpack Demo using Docker

    main

    The demo provides a docker-compose.yml file for an easy setup.

    1. Prepare the environment:
      composer install
      cp .env.example .env
      php artisan key:generate
    2. Update .env with these specific Docker values:
      • APP_URL=http://localhost
      • DB_CONNECTION=mysql
      • DB_HOST=db
      • DB_PORT=3306
      • DB_DATABASE=backpackdemo
      • DB_USERNAME=root
      • DB_PASSWORD=asdf
    3. Launch the containers:
      docker-compose up -d
    4. Create the database:
      docker-compose exec db mysql -u root -pasdf -e "create database if not exists backpackdemo;"
    5. Run migrations and seeds:
      php artisan migrate --seed

    Access the demo at http://localhost/admin. To stop the server, run docker-compose down.

    Tip: When connecting to the database from a GUI (like TablePlus or Sequel Ace), use 127.0.0.1 as the host instead of localhost.

    composer install
    cp .env.example .env
    php artisan key:generate
    docker-compose up -d
    docker-compose exec db mysql -u root -pasdf -e "create database if not exists backpackdemo;"
    php artisan migrate --seed
  4. Install the Backpack Demo locally

    main

    To run the full Backpack demo on your own machine without restrictions (like uploads or user edits), follow these steps.

    Prerequisite: This demo requires all premium Backpack packages. You must have purchased all premium add-ons individually or the GOLD bundle to successfully install it.

    1. Clone the repository:
      git clone https://github.com/Laravel-Backpack/demo.git backpack-demo
    2. Configure your .env file using .env.example as a template. Ensure APP_URL matches your local access URL (e.g., http://127.0.0.1:8000).
    3. Install dependencies and initialize the database:
      composer install
      php artisan key:generate
      php artisan migrate
      php artisan db:seed
    git clone https://github.com/Laravel-Backpack/demo.git backpack-demo
    # ... configure .env ...
    composer install
    php artisan key:generate
    php artisan migrate
    php artisan db:seed
  5. Configure SSL settings for the PHP service

    main

    The php service is configured to support SSL for local development. You can control the SSL mode and specify the paths to your certificate and private key files using these environment variables:

    • SSL_MODE: Set to full to enable SSL.
    • SSL_CERTIFICATE_FILE: Path to the SSL certificate (e.g., certs/local-dev.pem).
    • SSL_PRIVATE_KEY_FILE: Path to the SSL private key (e.g., certs/local-dev-key.pem).
    environment:
      SSL_MODE: "full"
      SSL_CERTIFICATE_FILE: "certs/local-dev.pem"
      SSL_PRIVATE_KEY_FILE: "certs/local-dev-key.pem"
  6. Configure docker-php auto-run settings

    main

    The php service in the docker-compose.yml file supports several AUTORUN_* environment variables to automate Laravel setup tasks when the container starts. These settings allow you to control which Laravel optimizations and setup commands are executed automatically.

    Available AUTORUN_ environment variables:

    • AUTORUN_ENABLED: Enables or disables the auto-run feature (true/false).
    • AUTORUN_LARAVEL_MIGRATION: Automatically runs php artisan migrate.
    • AUTORUN_LARAVEL_CONFIG_CACHE: Automatically runs php artisan config:cache.
    • AUTORUN_LARAVEL_EVENT_CACHE: Automatically runs php artisan event:cache.
    • AUTORUN_LARAVEL_ROUTE_CACHE: Automatically runs php artisan route:cache.
    • AUTORUN_LARAVEL_STORAGE_LINK: Automatically runs php artisan storage:link.
    • AUTORUN_LARAVEL_VIEW_CACHE: Automatically runs php artisan view:cache.
    # Example configuration for the php service
    environment:
      AUTORUN_ENABLED: "true"
      AUTORUN_LARAVEL_MIGRATION: "true"
      AUTORUN_LARAVEL_STORAGE_LINK: "true"
      AUTORUN_LARAVEL_CONFIG_CACHE: "false"
  7. Configure class aliases

    main

    The aliases array allows you to register class aliases that are lazily loaded when the application starts. This provides a shorthand way to access certain classes. The configuration uses Facade::defaultAliases() as a base and allows merging additional aliases into the array.

    'aliases' => Facade::defaultAliases()->merge([
        // Other Aliases...
    ])->toArray(),
  8. Register service providers

    main

    The providers array in config/app.php contains the list of service providers that are automatically loaded on every application request. You can add your own service providers to this array to extend the application's functionality. The list includes both Laravel framework providers (e.g., DatabaseServiceProvider, AuthServiceProvider) and application-specific providers (e.g., App\Providers\AppServiceProvider).

    'providers' => [
        // Laravel Framework Service Providers...
        Illuminate\Auth\AuthServiceProvider::class,
        Illuminate\Database\DatabaseServiceProvider::class,
        // ...
    
        // Application Service Providers...
        App\Providers\AppServiceProvider::class,
        App\Providers\AuthServiceProvider::class,
        // ...
    ],
  9. Configure MariaDB environment variables

    main

    The mariadb service uses standard MariaDB environment variables to initialize the database. These values are typically injected via your host environment or a .env file using the following mapping:

    • MYSQL_ROOT_PASSWORD: Set via ${DB_ROOT_PASSWORD}.
    • MYSQL_DATABASE: Set via ${DB_DATABASE}.
    • MYSQL_USER: Set via ${DB_USERNAME}.
    • MYSQL_PASSWORD: Set via ${DB_PASSWORD}.
    • MYSQL_ROOT_HOST: Hardcoded to % to allow connections from any host.
    • MYSQL_ALLOW_EMPTY_PASSWORD: Hardcoded to no.
    mariadb:
        image: mariadb:11
        environment:
            MYSQL_ROOT_PASSWORD: '${DB_ROOT_PASSWORD}'
            MYSQL_DATABASE: '${DB_DATABASE}'
            MYSQL_USER: '${DB_USERNAME}'
            MYSQL_PASSWORD: '${DB_PASSWORD}'
  10. Configure core application settings

    main

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

    • Environment & Debugging: Control the application environment (APP_ENV) and whether detailed error traces are shown (APP_DEBUG).
    • URL & Timezone: Set the base URL for Artisan commands (APP_URL) and the default PHP timezone (timezone).
    • Localization: Define the primary application locale (locale) and the fallback locale used when translations are missing (fallback_locale).
    • Security: The key (set via APP_KEY) is used for encryption via the AES-256-CBC cipher. This must be a random 32-character string for security.
    • Logging: Configure the log driver (e.g., single, daily, syslog, errorlog) using APP_LOG.
  11. Use Local-only Developer Helper Routes

    main

    The demo includes helper routes that are only available in local environments (not production) to assist with development and testing:

    • /dev/login-as/{email?}: Logs you in without a password. Defaults to admin@example.com if no email is provided.
    • /dev/preview/{skin}/{layout?}: Logs you in with a specific skin and layout, useful for generating screenshots.