oussema/hidebycountries
Composer 安装命令:
composer require oussema/hidebycountries
包简介
Hide Content Elements depends on the frontend user country
关键字:
README 文档
README
A TYPO3 extension that lets you show or hide content elements based on visitor’s country.
Features
- Hide or show any content element (CE) depending on visitor’s country code.
- Uses a pluggable GeoIP service API for country detection.
- Cookie-based tracking for visitor’s country for performance.
- Caching support to reduce repeated lookups.
- Optional indicator in backend page preview indicating restricted CEs.
- Compatible with TYPO3 v13.
Requirements
- TYPO3 CMS v13
- PHP 8.1+
- MySQL / MariaDB (or supported database driver)
- Composer to install dependencies (if using Composer mode)
Installation
via composer
composer require oussema/hidebycountries
Manual Installation
- Upload the extension folder to typo3conf/ext/hidebycountries
- Activate the extension via the Extension Manager
- Configure via Admin Tools → Settings → Extension Configuration → hidebycountries
Extension Configuration
In the Extension Configuration you will find the following settings:
| Options | Description | Default Values |
|---|---|---|
| developmentMode | Use fixed IP for testing instead of actual client IP | 1 |
| publicIpAddressForTesting | IP address used when development mode is active (its recomand to overwrite this) | 234.162.28.227 |
| classNameSpace | Fully qualified class-name of the GeoIP service implementation | \Oussema\HideByCountries\Utility\Apis\AetherEpiasGeoLocationService |
| showBackendRestrictionIndicator | Show a marker in backend preview for content elements with restrictions | 1 |
How It Works
- A PSR-15 middleware intercepts frontend requests, detects visitor country (by IP or cookie)
- The content element filter logic (configured via EventListener) checks each CE’s tx_hidebycountries field and either renders or hides the CE for the visitor’s country.
- If enabled, the backend preview displays a visual indicator for CEs that have country restrictions.
Developer Guide
Using a custom GeoIP service
1- Extend or replace the default service by implementing the GeoLocationApiInterface. Example:
<?php declare(strict_types=1); namespace Vendor\Extension\Utility\Apis; use Oussema\HideByCountries\Utility\Apis\GeoLocationApiInterface; class CustomGeoService implements GeoLocationApiInterface { public function getCountryForIp(string $ipAddress): string { // custom logic for fetching country code } }
2- In the extension configuration implement ur fully qualified class-name
Backend preview indicator event
If you’ve enabled the showBackendRestrictionIndicator option, the event listener will hook into the backend module preview and add a visual marker for restricted content elements.
Contributing
Contributions are very welcome! Please fork the repository and issue a pull request. Make sure to follow the coding standards and add tests for new features.
Testing
Unit and functional tests are located under /Tests. Make sure to have a valid testing database and correct environment variables configured.
Author
oussema/hidebycountries 适用场景与选型建议
oussema/hidebycountries 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 0 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 11 月 02 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「extension」 「countries」 「typo3」 「hide」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 oussema/hidebycountries 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 oussema/hidebycountries 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 oussema/hidebycountries 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A custom URL rule class for Yii 2 which allows to create translated URL rules
List of all countries with names and ISO 3166-1 codes in all languages and data formats for Laravel
Set Links with a specific language parameter
Laravel 5.2 package that provides basic geographical data like Countries, Regions and Cities.
The Yii2 extension uses jQuery jquery.carousel-1.1.min.js and makes image carousel from php array of structure defined.
TYPO3 CMS extension to create gallery content element with preset crop ratios and pagination
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 17
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: GPL-2.0-or-later
- 更新时间: 2025-11-02