承接 sitegeist/base-url 相关项目开发

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

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

sitegeist/base-url

最新稳定版本:v1.1.7

Composer 安装命令:

composer require sitegeist/base-url

包简介

Determinates base URL from site configurations for scripts where no FE or BE context is available like commands or tasks

README 文档

README

In in scripts where no FE or BE context is available and you want to build URLs its a good idea to get the absolute URL from a site configuration. This extension provides a helper class to get there.

Where to use

  • commands which are called via cli
  • scheduler tasks

Features

  • get base URL depending on site configurations
  • absolute a relative URL

Getting Started

use the static functions from BaseUrl helper Class

\Sitegeist\BaseUrl\Helper\BaseUrl::get(); // https://example.com/
\Sitegeist\BaseUrl\Helper\BaseUrl::prepend('home.html'); // https://example.com/home.html

use the viewhelpers in your fluid templates e. g. for mails

<baseurl:get /> <!-- https://example.com/ -->
<baseurl:prepend>home.html</baseurl:prepend> <!-- https://example.com/home.html -->

Multiple site configuration setups

if your system has more than one site configuration, you can specify which site configuration should be used by:

  • specify site configuration identifier

    BaseUrl::get('mysite');
    BaseUrl::prepend('home.html', 'mysite');
    <baseurl:get identifier="mysite" />
    <baseurl:prepend identifier="mysite" />home.html</baseurl:prepend>
  • specify a pageUid (anywhere in the pageTree)

    BaseUrl::get(null, 1);
    BaseUrl::prepend('home.html', null, 1);
    <baseurl:get pageId="1" />
    <baseurl:prepend pageId="1" />home.html</baseurl:prepend>

Getting further

Disable $asString return type to get an TYPO3\CMS\Core\Http\Uri object. Now you can get or change specific parts of the url.

BaseUrl::get(null, null, true, false);

BaseUrl::prepend('home.html', null, null, true, false);
/*
TYPO3\CMS\Core\Http\Uri prototype object
   scheme => protected "https" (5 chars)
   supportedSchemes => protected array(2 items)
      http => 80 (integer)
      https => 443 (integer)
   authority => protected "" (0 chars)
   userInfo => protected "" (0 chars)
   host => protected "example.com" (11 chars)
   port => protected NULL
   path => protected "home.html" (9 chars)
   query => protected "" (0 chars)
   fragment => protected NULL
*/

统计信息

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

GitHub 信息

  • Stars: 2
  • Watchers: 3
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: GPL-2.0-or-later
  • 更新时间: 2020-08-24