jdz/metas
Composer 安装命令:
composer require jdz/metas
包简介
JDZ head metas manager
README 文档
README
Utility to manage the head metas of a web page
Installation
To install the library, use Composer:
composer require jdz/metas
Usage
Here is an example of how to use the JDZ Metas manager:
<?php $standalone = true; $cacheSupport = true; $appleSupport = true; $msieSupport = true; $baseUrl = 'https://localhost'; $data = []; # base $data['title'] = 'Page title'; $data['base'] = $baseUrl; $data['charset'] = 'utf-8'; $data['ua-compatible'] = 'IE=edge'; $data['content-style-type'] = ''; $data['content-script-type'] = ''; $data['fragment'] = '!'; $data['viewport'] = 'width=device-width, initial-scale=1'; $data['theme-light-color'] = '#888'; $data['theme-dark-color'] = '#222'; if (true === $cacheSupport) { $data['cache-control'] = 'private, max-age=86400'; } else { $data['cache-control'] = 'no-cache, no-store, must-revalidate'; } # base,og $data['title'] = 'Page title'; $data['url'] = $baseUrl . 'page-url/'; $data['description'] = 'My page description'; # base,google $data['robots'] = 'noindex,nofollow'; # base,article $data['author'] = 'Page author'; # base,msie $data['theme-color'] = '#F9F9F9'; # base,apple $data['application-name'] = 'AppName'; if (false === $standalone) { $data['mobile-web-app-capable'] = 'yes'; } # google $data['google'] = ''; $data['google-site-verification'] = ''; # og $data['image'] = $baseUrl . 'image.jpg'; $data['site-name'] = 'My own website'; $data['type'] = 'website'; $data['locale'] = 'fr-FR'; $data['brand'] = 'My Brand'; $data['availability'] = ''; $data['standard-price-amount'] = ''; # facebook $data['facebook-admins'] = ''; $data['facebook-app-id'] = ''; # twitter $data['twitter-card'] = 'summary'; $data['twitter-creator'] = ''; $data['twitter-site'] = ''; # pinterest $data['pinterest'] = ''; $data['pinterest-domain-verify'] = ''; $data['pinterest-block-rich-pins'] = ''; # product $data['plural-title'] = ''; $data['price-amount'] = ''; $data['price-currency'] = ''; # article $data['section'] = ''; $data['published-time'] = ''; $data['modified-time'] = ''; # msie if (true === $msieSupport) { $data['msapplication-config'] = $baseUrl . 'browserconfig.xml'; } else { $data['msapplication-config'] = 'none'; } # apple if (true === $appleSupport) { $data['mobile-web-app-title'] = 'MyApp'; $data['mobile-web-app-status-bar-style'] = 'black'; } try { $metas = new \JDZ\Metas\Metas(); $metas->register(new \JDZ\Metas\Manager\BaseManager()); $metas->register(new \JDZ\Metas\Manager\AppleManager($appleSupport)); $metas->register(new \JDZ\Metas\Manager\MsManager($msieSupport)); $metas->register(new \JDZ\Metas\Manager\GoogleManager()); $metas->register(new \JDZ\Metas\Manager\OgManager()); // ... article, facebook, pinterest, product, twitter $metas->sets($data); $documentHead = $metas->getElements(); $documentNamespaces = $metas->getNamespaces(); function printHead(array $elements): string { $head = ''; foreach ($elements as $element) { $head .= '<' . $element['tag']; foreach ($element['attrs'] as $key => $value) { $head .= ' ' . $key . '="' . $value . '"'; } if (!empty($element['closed'])) { $head .= '>'; if (!empty($element['content'])) { $head .= $element['content']; } $head .= '</' . $element['tag'] . '>' . "\n"; } else { $head .= ' />' . "\n"; } } return $head; } echo 'HTML namespaces' . "\n\n"; echo '<html prefix="' . $documentNamespaces . '"> ' . "\n\n"; echo '<head>' . "\n\n"; echo printHead($documentHead); } catch (\Throwable $e) { echo $e->getMessage(); } exit();
License
This project is licensed under the MIT License - see the LICENSE file for details.
Author
Joffrey Demetz - joffreydemetz.com
jdz/metas 适用场景与选型建议
jdz/metas 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 28 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 01 月 07 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「template」 「html」 「share」 「head」 「JDZ」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 jdz/metas 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 jdz/metas 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 jdz/metas 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Texy converts plain text in easy to read Texy syntax into structurally valid (X)HTML. It supports adding of images, links, nested lists, tables and has full support for CSS. Texy supports hyphenation of long words (which reflects language rules), clickable emails and URL (emails are obfuscated again
Improves silverstripes html meta data options.
HTML and form generation
Autogenerated open graph images for your entries.
A helper module for pdf-print, print and social share functionality based on bootstrap to custom modules.
Simple ASCII output of array data
统计信息
- 总下载量: 28
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 32
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-01-07