承接 archtechx/laravel-pages 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

archtechx/laravel-pages

Composer 安装命令:

composer require archtechx/laravel-pages

包简介

Easily add routes to your Laravel app by creating Markdown or Blade files.

关键字:

README 文档

README

This package lets you create pages using Markdown or Blade without having to worry about creating routes or controllers yourself.

Essentially, you create either content/pages/foo.md or resources/views/pages/foo.blade.php and the page will be accessible on the /foo route.

Markdown files use a pre-defined Blade view to get rendered. Blade files are meant for pages which don't follow the default layout and need more custom styling.

For instance, you could have the /pricing route use a Blade file (pages/pricing.blade.php) with a pretty design that accompanies your pricing copy.

Whereas for /about, you could have a simple Markdown file (content/pages/about.md) that describes your service using pure text without any special graphical elements.

We use this on the ArchTech website — the About, Careers, and Open Source pages are simple Markdown files.

Installation

Require the package via composer:

composer require archtechx/laravel-pages

Publish the config file:

php artisan vendor:publish --tag=archtech-pages-config

And finally, add this line to the end of your routes/web.php file:

ArchTech\Pages\Page::routes();

This line will register the routes in a way that ensures that your routes take precedence, and the page route is only used as the final option.

Important: Before attempting to visit URLs managed by this package, make sure that you configure it to use the correct layout (see the section below). Otherwise you might get an error saying that the view cannot be found.

Usage

Markdown pages

To create a markdown file, create a file in content/pages/. The route to the page will match the file name (without .md).

For example, to create the /about page, create content/pages/about.md with this content:

---
slug: about
title: 'About us'
updated_at: 2021-05-19T19:09:02+00:00
created_at: 2021-05-19T19:09:02+00:00
---

We are a web development agency that specializes in ...

Blade pages

To create a Blade page, create a file in resources/views/pages/. Like in the Markdown example, the route to the page will match the file name without the extension.

Therefore to create the /about page, you'd create resources/views/pages/about.blade.php:

<x-app-layout>
    This view can use any layouts or markup.
</x-app-layout>

Configuration

You'll likely want to configure a few things, most likely the used layout.

To do that, simply modify config/pages.php.

The config file lets you change:

  • the used model
  • the used controller
  • the layout used by the markdown views
  • the view file used to render Markdown pages
  • routing details

The layout is used by the vendor (package-provided) Markdown view. You'll likely want to set it to something like app-layout or layouts.app.

If you'd like to change the file that renders the Markdown itself, create resources/views/pages/_markdown.blade.php (the _ prefix is important as it prevents direct visits) and change the pages.views.markdown config key to pages._markdown.

And if you'd like to customize the routing logic more than the config file allows you, simply register the route yourself (instead of calling Page::routes()):

Route::get('/{page}', ArchTech\Pages\PageController::class);

Ecosystem support

The package perfectly supports other tools in the ecosystem, such as Laravel Nova or Lean Admin.

For example, in Laravel Nova you could create a resource for the package-provided Page model (ArchTech\Pages\Page) and use the following field schema:

public function fields(Request $request)
{
    return [
        Text::make('slug'),
        Text::make('title'),
        Markdown::make('content'),
    ];
}

Git integration & Orbit

This package uses Orbit under the hood — to manage the Markdown files as Eloquent models. If you'd like to customize some things related to that logic, take a look at the Orbit documentation.

The package also uses another package of ours, Laravel SEO, to provide meta tag support for Markdown pages. We recommended that you use this package yourself, since it will make handling meta tags as easy as adding the following line to your layout's <head> section:

<x-seo::meta />

Password-protected routes

The package also lets you protect certain routes with passwords. To add a password to a page, simply specify the password key in the YAML front matter:

password: 'foo'

Now if a user wants to visit the page, he will have to include ?password=foo in the URL, otherwise he'll be presented with a 403 error.

- /about
+ /about?password=foo

archtechx/laravel-pages 适用场景与选型建议

archtechx/laravel-pages 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 5.34k 次下载、GitHub Stars 达 119, 最近一次更新时间为 2021 年 08 月 06 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「laravel」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 archtechx/laravel-pages 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 archtechx/laravel-pages 我们能提供哪些服务?
定制开发 / 二次开发

基于 archtechx/laravel-pages 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 5.34k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 119
  • 点击次数: 15
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 119
  • Watchers: 2
  • Forks: 4
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-08-06