agence-adeliom/easy-page-bundle 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

agence-adeliom/easy-page-bundle

Composer 安装命令:

composer require agence-adeliom/easy-page-bundle

包简介

A simple lightweight CMS bundle for Symfony

README 文档

README

Adeliom Quality gate

Easy Page Bundle

A basic CMS system for Easyadmin.

Installation with Symfony Flex

Add our recipes endpoint

{
  "extra": {
    "symfony": {
      "endpoint": [
        "https://api.github.com/repos/agence-adeliom/symfony-recipes/contents/index.json?ref=flex/main",
        ...
        "flex://defaults"
      ],
      "allow-contrib": true
    }
  }
}

Install with composer

composer require agence-adeliom/easy-page-bundle

Versions

Repository Branch Version Symfony Compatibility PHP Compatibility Status
3.x 3.x 6.4, and 7.x 8.2 or higher New features and bug fixes
2.x 2.x 5.4, and 6.x 8.0.2 or higher Bug fixes
1.x 1.x 4.4, and 5.x 7.2.5 or higher No longer maintained

Setup database

Using doctrine migrations

php bin/console doctrine:migration:diff
php bin/console doctrine:migration:migrate

Without

php bin/console doctrine:schema:update --force

Documentation

Manage pages in your Easyadmin dashboard

Go to your dashboard controller, example : src/Controller/Admin/DashboardController.php

<?php

namespace App\Controller\Admin;

...
use App\Entity\EasyPage\Page;

class DashboardController extends AbstractDashboardController
{
    ...
    public function configureMenuItems(): iterable
    {
        ...
        yield MenuItem::section('easy.page.admin.menu.contents'); // (Optional)
        yield MenuItem::linkToCrud('easy.page.admin.menu.pages', 'fa fa-file-alt', Page::class);

        ...

View page

The PageController handles some methods to view pages with a single index().

The URI for both is simply /{slug} where slug is the... page.

If your page has one parent, then the URI is the following: /{parentSlug}/{slug}.

You can notice that we respect the pages hierarchy in the generated url.

You can navigate through a complex list of pages, as long as they are related as parent and child.

This allows you to have such urls like this one : http://www.mysite.com/about/company/team/members for instance, will show only the members page, but its parent has a parent, that has a parent, and so on, until you reach the "root" parent. And it's the same behavior for categories.

Note: this behavior is the precise reason why you have to use a specific rules for your routing, unless you may have many "404" errors.

Generate a route based on a single page

If you have a Page object in a view or in a controller, you can get the whole arborescence by using the getTree() method, which will navigate through all parents and return a string based on a separator argument (default /, for urls).

Let's get an example with this kind of tree:

/ - Home (root url)
├─ /welcome       - Welcome page (set as "homepage", so "Home" will be the same)
│  ├─ /welcome/our-company            - Our company
│  ├─ /welcome/our-company/financial  - Financial
│  └─ /welcome/our-company/team       - Team
└─ Contact

Imagine we want to generate the url for the "Team" page. You have this Page object in your view/controller.

{# Page : "Team" #}
{{ path('easy_page_index', {"slugs": page.tree}) }}
{# Will show : /welcome/our-company/team #}

Or in a controller:

// Page : "Team"
$url = $this->generateUrl('easy_page_index', ['slugs' => $page->getTree()]);
// $url === /welcome/our-company/team

Homepage

The homepage is always the first Page object with its template attribute set to homepage. Be sure to have only one element defined as homepage, or you may have unexpected results.

Design

You have some options to customize the design of your simple CMS.

Using different layouts

Obviously, the default layout has no style.

To change the layout, simply change the OrbitaleCmsBundle configuration to add your own layout:

# config/packages/easy_page.yml
easy_page:
    layouts:
        front: { resource: @App/layout.html.twig } # The Twig path to your layout

Without overriding anything, you can easily change the layout for your CMS!

Take a look at the default layout to see which Twig blocks are mandatory to render correctly the pages.

Advanced layout configuration

The basic configuration for a layout is to specify a template to extend.

But if you look at the Configuration reference you will see that there are many other parameters you can use to define a layout:

Prototype of a layout configuration:

  • name (attribute used as key for the layouts list):
    The name of your layout. Simply for readability issues, and maybe to get it directly from the config (if you need it).
  • resource:
    The Twig template used to render all the pages (see the above section)
  • assets_css and assets_js:
    Any asset to send to the Twig asset() function. The CSS is rendered in the stylesheets block, and js in the javascripts block.
  • host:
    The exact domain name you want the layout to match with.
  • pattern:
    The regexp of the path you want to match with for this layout. It's nice if you want to use a different layout for pages. For example, you can specify a layout for the ^/page/ pattern, and another for ^/about-us/. If you specify a very deep pattern, you can even change the layout for a single page!

Take another look on the config reference if you need to get the prototype defaults.

⚠️ Warning! The first matching layout will be used, as well as routing would do, so be sure to configure them in the right order!
Empty values won't be taken in account.

Configuration reference

# config/packages/easy_page.yml
easy_page:
    page_class: ~              # Required, must extend Easy Page class
    page_repository:      Adeliom\EasyPageBundle\Repository\PageRepository
    page_controller:      Adeliom\EasyPageBundle\Controller\PageController
    layouts:
        # Prototype
        name:
            name: ~             # Optional, it's automatically set from the key if it's a string
            resource: ~         # Required, must be a valid twig template
            assets_css: []      # Injected with the `asset()` twig function
            assets_js: []       # Injected with the `asset()` twig function
            assets_webpack: []  # Injected with the `encore_entry_link_tags()` and `encore_entry_script_tags()` twig functions
            pattern: ~          # Regexp
            host: ~             # Exact value
    cache:
        enabled: false
        ttl: 300

License

MIT

Authors

Thanks to

Orbitale/CmsBundle

agence-adeliom/easy-page-bundle 适用场景与选型建议

agence-adeliom/easy-page-bundle 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 8.87k 次下载、GitHub Stars 达 10, 最近一次更新时间为 2021 年 09 月 23 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

围绕 agence-adeliom/easy-page-bundle 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

  • 总下载量: 8.87k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 10
  • 点击次数: 4
  • 依赖项目数: 3
  • 推荐数: 0

GitHub 信息

  • Stars: 10
  • Watchers: 1
  • Forks: 7
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-09-23