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
szajens/pece 适用场景与选型建议
szajens/pece 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 6 次下载、GitHub Stars 达 0, 最近一次更新时间为 2022 年 05 月 22 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 szajens/pece 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 szajens/pece 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 6
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-05-22