承接 szajens/pece 相关项目开发

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

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

szajens/pece

Composer 安装命令:

composer require szajens/pece

包简介

Pece routing for Codeigniter 4 - This library modifies the host for the URL helper and URI Service

README 文档

README

This library modifies the host for the URL helper and URI Service

How to use in Routes:

There are new options in CI4 routing, you can use all or some

Example:

$routes->get('/test/(:any)', 'Test::index/$1', ['pSubdomain'=> '[a-z]+', 'pDomain'=>'ci.loc', 'pSSL' => null, 'pSubhost' => false]);

Limit to subdomain:

When the subdomain option is present, the system will restrict the routes to only be available on that sub-domain. The route will only be matched if the subdomain is the one the application is being viewed through:

Regular Expressions If you prefer you can use regular expressions to define your subdomain rules. Any valid regular expression is allowed

Example:

// Limit to media.example.com
$routes->add('from', 'to', ['pSubdomain' => 'media']); or
$routes->add('from', 'to', ['pSubdomain' => '[a-z]+']);

Limit to Domain

You can restrict groups of routes to function only in certain domain of your application by passing the “pDomain” option along with the desired domain to allow it on as part of the options array: Example:

$routes->get('from', 'to', ['pDomain' => 'example.com']);

Limit to SSL

If you need limiting to https use true, to http set false or not limiting set null Example:

$routes->get('from', 'to', ['pSSL' => true]);

Setting subdomain+domain as host

if you want to use subdomain and domain as host in CI4 set this option as true or false with otherwise Example:

$routes->get('from', 'to', ['pSubhost' => true]);

How to use in your app e.g. controller:

Change host from subdomain to domain: Services::pece()->setDomainInCI();

xxx.host.com => host.com

Change host from domain to subdomain (if the request is from a subdomain, reverse setDomainInCI()): Services::pece()->setSubdomainInCI();

host.com => xxx.host.com

Change subdomain in host: Services::pece()->changeSubdomainInCI('new.sub.domain');

host.com => new.sub.domain.host.com
abc.host.com => new.sub.domain.host.com

Add to subdomain in host Services::pece()->addSubdomainInCI('new.sub.domain');

host.com => new.sub.domain.host.com
abc.host.com => new.sub.abc.domain.host.com

Other methods:

Services::pece()->
getDomain(): - return request domain
getSubdomain(): - request subdomain
getScheme(): - request scheme e.g. 'https://' or 'http://'

Instalation:

  • Composer
composer require szajens/pece

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-05-22

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固