承接 claudiojr96/pagetitle 相关项目开发

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

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

claudiojr96/pagetitle

Composer 安装命令:

composer require claudiojr96/pagetitle

包简介

Manage page title in Laravel views

README 文档

README

Build Status Latest Stable Version Scrutinizer Code Quality License

Often, you'll find yourself in situations, where you want to have more to control how to set a page title for your different views. Although it is possible to yield your page title in a master view it can be a hassle to deal with the format like a delimeter usage or to append/prepend a default page title.

This package simplifies the process.

Installation

Begin by installing this package through Composer:

composer require rephlux/pagetitle

Laravel Users

If you are a Laravel user, then there is a service provider that need to add to your config/app.php file.

'providers' => [
    '...',
    Rephlux\PageTitle\PageTitleServiceProvider::class
];

This package also provides a facade, which you may also register in your config/app.php as well if you want to use the facade in your controllers and views:

 'aliases' => [
     '...'
     'PageTitle' => Rephlux\PageTitle\Facades\PageTitle::class,
 ]

In Laravel 5.5, service providers and aliases are automatically registered. If you're using Laravel 5.5, you can skip these steps.

Version 2.0

If you still use PHP 7.0 or 5.6 you need to use version 1.0 of this package. Version 2.0 and above is only compatible with PHP 7.1 or newer.

Version 2.0 of this package is also compatible with Laravel 5.5 and newer.

Useage

To simple add a single page title, call the appropiate add() method with passing a string as a parameter:

public function index()
{
    \PageTitle::add('Welcome to our Homepage');

    return view('hello');
}

You can also make use of the global pagetitle helper function.

public function index()
{
    pagetitle('Welcome to our Homepage');

    return view('hello');
}

To add multiple page title parts at once just pass an array as a parameter.

public function index()
{
    pagetitle([
        'About us',
        'Profile'
    ]);

    return view('hello');
}

Add the pagetitle to a blade view

Now you can display the fully concatenated page title in your view. The best way is to use it in your master layout file.

<head>
    <meta charset="UTF-8">
    <title>{{ pagetitle()->get() }}</title>
    ...
</head>

To display the fully concatenated page title in reverse order just pass the reverse parameter.

<head>
    <meta charset="UTF-8">
    <title>{{ pagetitle()->get('reverse') }}</title>
    ...
</head>

The downward mode first concatenates all page title parts in reverse order and then appends the page name ( if set in options )

<head>
    <meta charset="UTF-8">
    <title>{{ pagetitle()->get('downward') }}</title>
    ...
</head>

Defaults

If using Laravel, there are three configuration options that you'll need to worry about. First, publish the default configuration with the following command:

php artisan vendor:publish --provider="Rephlux\PageTitle\PageTitleServiceProvider"

This will add a new configuration file to: config/pagetitle.php.

<?php

return [

    /*
    |--------------------------------------------------------------------------
    | Page name
    |--------------------------------------------------------------------------
    |
    | Type your page name for your website.
    | This will be used when there are more titles to concatenate with.
    |
    */
    'page_name' => '',

    /*
    |--------------------------------------------------------------------------
    | Default title when empty
    |--------------------------------------------------------------------------
    |
    | This will be used when therer is no other title.
    | Mainly used for the home page of your website.
    |
    */
    'default_title_when_empty' => '',

    /*
    |--------------------------------------------------------------------------
    | Delimiter
    |--------------------------------------------------------------------------
    |
    | Titles will be concatenated using this delimiter.
    |
    */
    'delimiter' => ' :: ',
];

page_name

If you want you can enter your page name to this key if you want to append/prepend the name to your concatenated page title.

default_title_when_empty

This text will be used when there is are no page title parts in the collection.

delimiter

When you want to use a delimeter just update this key and add the string you want to use as an delimeter.

Change the configuration values

Each of the configuration parameters can be changed on the page title object instance with the correspondig setter methods:

  • setDelimeter(delimeter)
  • setPageName(pageName)
  • setDefault(default)

Example usage:

public function index()
{
    pagetitle('My Blog Post')->setPageName('My Blog')->setDelimeter(' / ');

    return view('hello');
}

To retrieve the current configuration values use the corresponding getter methods on the page title object instance:

  • getDelimeter()
  • getPageName()
  • getDefault()

License

View the license for this repo.

claudiojr96/pagetitle 适用场景与选型建议

claudiojr96/pagetitle 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 7 次下载、GitHub Stars 达 0, 最近一次更新时间为 2019 年 12 月 09 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

围绕 claudiojr96/pagetitle 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 10
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-12-09