esanj/public-pages
Composer 安装命令:
composer require esanj/public-pages
包简介
Public pages for Laravel apps including home and error pages.
README 文档
README
esanj/public-pages is a Laravel package that gives your application a clean, ready-to-use home page and a
complete set of HTTP error pages (400, 401, 403, 404, 419, 429, 500, 502, 503, 504), with bundled assets
(CSS, background image), built-in English & Persian translations, and full control through a simple config file.
Everything works out of the box. You only publish files when you want to customize them.
✨ Features
- ✅ Pre-designed error pages for the 10 most common HTTP status codes
- 🏠 Optional, configurable home page route
- 📁 Bundled front-end assets (CSS + background image)
- 🌐 Multi-language support (English & Persian included, RTL-aware)
- 🎨 Fully customizable — publish and override views, assets, config & translations
- ⚡ Zero configuration required to get started
📋 Requirements
| Requirement | Version |
|---|---|
| PHP | 8.2, 8.3 or 8.4 |
| Laravel | 12.x or 13.x |
📦 Installation
1. Install via Composer:
composer require esanj/public-pages
That's it — the package auto-registers itself. The home page and error pages are already active.
2. (Optional) Publish files you want to customize:
php artisan publicpages:install
With no options, this publishes everything (views, assets, translations, and config). See Commands to publish only what you need.
🗂️ What Gets Published
| What | Published to |
|---|---|
| Home view | resources/views/vendor/publicpages/home.blade.php |
| Error views | resources/views/errors/ |
| Assets | public/assets/vendor/public-pages/ |
| Translations | lang/{locale}/publicpages.php |
| Config | config/esanj/public_pages.php |
File tree after a full install:
resources/
└── views/
├── vendor/publicpages/
│ └── home.blade.php
└── errors/
├── layout.blade.php
├── 404.blade.php
├── 500.blade.php
└── ...
public/
└── assets/vendor/public-pages/
├── style.css
└── background.png
lang/
├── en/publicpages.php
└── fa/publicpages.php
config/
└── esanj/public_pages.php
🧩 Commands
| Command | What it does |
|---|---|
php artisan publicpages:install |
Publishes everything (views, assets, lang, config) |
php artisan publicpages:publish-views |
Publishes views and assets |
php artisan publicpages:publish-lang |
Publishes translation files |
php artisan publicpages:publish-config |
Publishes the config file |
publicpages:install also accepts flags to publish only part of the package:
php artisan publicpages:install --views # views only php artisan publicpages:install --assets # assets only php artisan publicpages:install --lang # translations only php artisan publicpages:install --config # config only php artisan publicpages:install --all # everything (same as no flag)
ℹ️
publicpages:installalways overwrites existing files, so you can re-run it any time to pull in updates.
You can also publish directly with Laravel's vendor:publish using the package tags:
| Tag | Includes |
|---|---|
esanj-public-pages-views |
🎨 Views |
esanj-public-pages-assets |
🧩 Public assets |
esanj-public-pages-lang |
🌐 Translations |
esanj-public-pages-config |
⚙️ Config |
php artisan vendor:publish --tag=esanj-public-pages-views
⚙️ Configuration
Publish the config file:
php artisan publicpages:publish-config
This creates config/esanj/public_pages.php. The full default config:
<?php return [ // Name shown on the home and error pages. 'app_name' => env('APP_NAME', 'eSanj'), // Home page route. 'home' => [ 'enabled' => env('PUBLIC_PAGES_HOME_ENABLED', true), // register the home route? 'path' => env('PUBLIC_PAGES_HOME_PATH', '/'), // URI for the home page 'view' => 'publicpages::home', // view to render ], // Middleware applied to the package routes. 'routes' => [ 'middleware' => ['web'], ], // Custom error pages. 'errors' => [ 'enabled' => env('PUBLIC_PAGES_ERRORS_ENABLED', true), // use package error pages? 'layout' => 'errors.layout', // base layout for error views ], ];
Common tweaks
Disable the home route (you provide your own /):
PUBLIC_PAGES_HOME_ENABLED=false
Change the home page path:
PUBLIC_PAGES_HOME_PATH=/welcome
Use Laravel's default error pages instead of the package's:
PUBLIC_PAGES_ERRORS_ENABLED=false
Change the app name shown on the pages:
APP_NAME="My Startup"
Apply extra middleware to the home route — edit config/esanj/public_pages.php:
'routes' => [ 'middleware' => ['web', 'auth'], ],
🔁 To reset the configuration, delete
config/esanj/public_pages.phpand runphp artisan config:clear. The package falls back to its built-in defaults automatically.
🌐 Localization
Translations live in lang/{locale}/publicpages.php and ship with English (en) and Persian (fa).
The error layout automatically switches to RTL when the app locale is fa.
Publish them to customize:
php artisan publicpages:publish-lang
File structure:
<?php return [ 'home' => [ 'title' => 'Welcome to our website', 'description' => 'This is the home page provided by the esanj/public-pages package.', ], 'labels' => [ 'copyright' => '© :year :brand Platform. All rights reserved.', ], 'errors' => [ '404' => [ 'title' => 'Page Not Found', 'message' => "The page or resource you're looking for was not found.", ], '500' => [ 'title' => 'Internal Server Error', 'message' => 'An internal server error occurred. Please try again later.', ], // ... other status codes ], ];
Reference any string in Blade with the publicpages::publicpages.* key:
{{ __('publicpages::publicpages.errors.404.title') }}
Add another locale by creating lang/{locale}/publicpages.php (e.g. lang/es/publicpages.php) with the same
structure.
➕ Adding a New Error Page
Suppose you want to support 505 HTTP Version Not Supported.
1. Add the translations in lang/{locale}/publicpages.php under errors:
'505' => [ 'title' => 'HTTP Version Not Supported', 'message' => 'The server does not support the HTTP protocol version used in the request.', ],
2. Create the view resources/views/errors/505.blade.php:
@extends('errors::layout') @php $code = 505; @endphp
The shared errors::layout reads $code and pulls the matching title/message from your translation file —
no other wiring needed.
🎨 Customizing the Look
-
Views — after publishing, edit
resources/views/errors/layout.blade.php(the shared error layout) orresources/views/vendor/publicpages/home.blade.php(the home page). -
Styles — edit
public/assets/vendor/public-pages/style.cssand thebackground.pngnext to it. -
Use your own error layout — point the config at it:
'errors' => [ 'layout' => 'layouts.error-base', ],
then create
resources/views/layouts/error-base.blade.phpwith your own markup.
📖 For a complete, beginner-friendly, step-by-step walkthrough, see docs/GUIDE.md.
📄 License
MIT © 2025 — Esanj Team
esanj/public-pages 适用场景与选型建议
esanj/public-pages 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 109 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 07 月 21 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 esanj/public-pages 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 esanj/public-pages 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 109
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 15
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-07-21