Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Page Loader Laravel Package

creative-syntax/page-loader

Add a simple customizable page loading indicator to your Laravel app. Install via Composer, optionally register the service provider, publish the config, and toggle the loader or change its color in config/page-loader.php.

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Setup

  1. Installation

    composer require dev-arindam-roy/laravel-page-loader-package
    

    Publish the config file (if needed):

    php artisan vendor:publish --provider="DevArindamRoy\PageLoader\PageLoaderServiceProvider"
    
  2. Basic Usage Define a page in config/page-loader.php:

    'pages' => [
        'home' => [
            'view' => 'pages.home',
            'middleware' => ['web'],
            'data' => ['title' => 'Home Page'],
        ],
        'about' => [
            'view' => 'pages.about',
            'middleware' => ['web'],
        ],
    ],
    
  3. First Use Case Load a page dynamically in a controller:

    use DevArindamRoy\PageLoader\Facades\PageLoader;
    
    public function loadPage($pageName)
    {
        return PageLoader::load($pageName);
    }
    

    Route it:

    Route::get('/{page}', [PageController::class, 'loadPage']);
    

Implementation Patterns

Dynamic Page Loading

  • Route-Based Pages Useful for marketing sites or CMS-like structures where pages are defined in config but rendered dynamically.

    Route::get('/{page}', function ($page) {
        return PageLoader::load($page);
    })->where('page', 'home|about|contact');
    
  • Conditional Page Loading Load pages based on user roles or other logic:

    if (auth()->check()) {
        return PageLoader::load('dashboard');
    }
    return PageLoader::load('home');
    

Data Injection

Pass dynamic data to pages:

PageLoader::load('home', [
    'posts' => Post::latest()->take(5)->get(),
]);

Middleware Integration

Attach middleware per page (defined in config) or globally:

// In config/page-loader.php
'global_middleware' => ['auth'],

Fallback Pages

Define a fallback page for 404s:

// In config/page-loader.php
'fallback_page' => 'not-found',

Gotchas and Tips

Pitfalls

  1. Missing Config Ensure config/page-loader.php exists and is properly structured. The package may silently fail if misconfigured.

  2. View File Not Found Double-check the view key in the config matches an existing Blade file (e.g., resources/views/pages/home.blade.php).

  3. Middleware Conflicts If a page’s middleware conflicts with route middleware, the last defined middleware takes precedence. Test thoroughly.

  4. Caching Issues If using Laravel’s cache, clear it after updating the config:

    php artisan cache:clear
    

Debugging Tips

  • Check Loaded Pages Temporarily add logging to verify pages are loading correctly:

    PageLoader::load('home')->withDebug(function ($page) {
        \Log::info('Loaded page:', ['page' => $page]);
    });
    
  • Validate Config Use php artisan config:clear if changes to page-loader.php aren’t reflected.

Extension Points

  1. Custom Page Resolvers Extend the package by binding a custom resolver to load pages from a database or API:

    // In a service provider
    $this->app->bind(\DevArindamRoy\PageLoader\Contracts\PageResolver::class, CustomPageResolver::class);
    
  2. Event Listeners Listen for page load events (if the package emits them) to log or modify page data:

    // In EventServiceProvider
    protected $listen = [
        \DevArindamRoy\PageLoader\Events\PageLoaded::class => [
            \App\Listeners\LogPageLoad::class,
        ],
    ];
    
  3. Dynamic Config Loading Override the config dynamically (e.g., from a database) by extending the PageLoader facade or service.

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
jayeshmepani/jpl-moshier-ephemeris-php
elnasnato/laraliveui
labrodev/rest-sdk
sampaui/sampaui
babelqueue/php-sdk
facebook/capi-param-builder-php
babelqueue/symfony
hamzi/corewatch
minionfactory/raw-hydrator
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle