esanj/public-pages

Public pages for Laravel apps including home and error pages.

v0.0.1 2025-06-11 13:54 UTC

This package is auto-updated.

Last update: 2025-07-21 05:44:52 UTC


README

esanj/public-pages is a Laravel package providing clean and customizable public-facing pages such as error views (404, 500, 403, etc.), along with localized messages and frontend assets (CSS/JS/images).

Built for maintainability and full flexibility, this package integrates quickly into any Laravel 10+ or 12 project with a few commands.

✨ Features

  • βœ… Pre-designed error templates (404, 500, 403, etc.)
  • πŸ“ Includes public assets (CSS, icons…)
  • 🌐 Supports multi-language via Laravel's lang system
  • 🎨 Full ability to customize views, assets, config & messages
  • ⚑ Works out-of-the-box with Blade or Livewire
  • 🧼 Clean UI with minimal setup time

πŸ“¦ Installation

1️⃣ Install via Composer:

composer require esanj/public-pages

2️⃣ Then publish the views and assets with:

php artisan publicpages:install

This command will publish:

Blade views β†’ resources/views/vendor/publicpages/

Assets β†’ public/assets/vendor/publicpages/

You’re ready to go!

πŸ“‚ File Structure (after install)

resources/
β”œβ”€β”€ views/
β”‚   β”œβ”€β”€ vendor/publicpages/home.blade.php
β”‚   └── errors/
β”‚       β”œβ”€β”€ 404.blade.php
β”‚       β”œβ”€β”€ 500.blade.php
β”‚       └── ...
public/
β”œβ”€β”€ assets/
    β”œβ”€β”€ vendor/
        β”œβ”€β”€ public-pages/
            β”œβ”€β”€ style.css
            └── background.png

🧩 Commands Overview

⬇️ Installs views and assets (required)

php artisan publicpages:install

πŸ“„ Publishes ONLY views + assets

php artisan publicpages:publish-views

🌐 Publishes language/translation files

php artisan publicpages:publish-lang

βš™οΈ Publishes config file

php artisan publicpages:publish-config

You can rerun them anytime using --force.

🌐 Localization

This package supports multiple languages.

To publish translation files:

php artisan publicpages:publish-lang

This will create:

πŸ“„ /lang/*/publicpages.php

Sample structure:

return [
   'errors' => [
         '404' => [
            'title' => 'Page not found',
            'message' => 'The page you’re looking for does not exist.',
         ],
         '500' => [
            'title' => 'Internal Server Error',
            'message' => 'Something went wrong. Please try again later.',
         ],
         // Add more codes...
   ]
];

You can create files for other locales (e.g. fa, es, etc.) as needed.

βž• Add New Error Page

To support a new status code like 505 (HTTP Version Not Supported):

1️⃣ Add entry in your lang file:

'505' => [
   'title' => 'HTTP Version Not Supported',
   'message' => 'The server does not support the HTTP protocol version used in the request.',
],

2️⃣ Then create a new blade file:

resources/views/errors/505.blade.php

This file can extend the base layout and use the dynamic error message like so:

@extends('errors::layout')

@php
    $code = 505;
@endphp

πŸ›  Config File (optional)

If the package provides a config file:

php artisan publicpages:publish-config

It will land in:

config/publicpages.php

You can override default behavior there.

πŸ“¦ Publishing Summary

You can always run a specific tag manually:

Tag Includes

public-pages-views 🎨 Views only

public-pages-assets 🧩 Public assets only

public-pages-lang 🌐 Language files

public-pages-config βš™οΈ Configuration file

Example:

php artisan vendor:publish --tag=public-pages-views

πŸ“„ License

MIT Β© 2025 β€” Esanj Team