magicalella/yii2-sef
Composer 安装命令:
composer require magicalella/yii2-sef
包简介
Componente per gestire le Sef URL , i Meta description ed i Title delle pagine
关键字:
README 文档
README
Installazione
Il modo migliore per installare questa estensione è tramite composer.
Lancia
php composer.phar require --prefer-dist magicalella/yii2-sef "*"
o aggiungi
"magicalella/yii2-sef": "*"
nella sezione require del tuo file "composer.json".
E avvia la migrazione dei file
yii migrate/up --migrationPath=@vendor/magicalella/yii2-sef/migrations
Può essere creato manualmente. Vale a dire, la tabella sef ha solo 5 campi:
id(primaryKey, AUTO_INCREMENT); link(varchar(255)); link_sef(varchar(255)); meta_title(varchar(255)); meta_description(varchar(255));
Utilizzo
Nel file: config/web.php o frontend/config/main.php se yii advanced scrivi
'urlManager' => [
'enablePrettyUrl' => true,
'showScriptName' => false,
'rules' => [
// Ci sono delle regole qui.
[
'class' => 'magicalella\sef\SefRule',
'connectionID' => 'db',
],
],
],
Per il pannello di amministrazione, puoi creare un modello "Sef" oppure puoi utilizzare un modello "magicalella\sef\src\Sef" già pronto
'link' = questo è il campo del collegamento originale, ad esempio articolo/vista?id=49
'link_sef' = questo campo è sinonimo dell'URL
'meta_title' = Titolo della pagina
'meta_description' = Meta description della pagina
Memorizzazione automatica delle URL in db e sostituzione automatica Meta Title e Description
Inserire:
in _protected\ (Yii basic) o _protected\common\ (Yii advanced)
- models Sef.php e SefSearch.php
in _protected\backend\controllers
- controller SefController.php
in FrontendController
use app\models\Sef (Yii basic) use common\models\Sef (Yii advanced)
public function afterAction($action, $result) { $result = parent::afterAction($action, $result); $request = Yii::$app->request;
if ($request->isGet){
Sef::inserisciSef($action,$request);
}
return $result;
}
public function render ( $view, $params = [] ){
$request = Yii::$app->request;
$controller = Yii::$app->controller->id;
// ! SEO
$meta_titol = Sef::scriviMetaTitle($view,$controller,$request);
$meta_description = Sef::scriviMetaDescription($view,$controller,$request);
Yii::$app->view->title = $meta_titol;
Yii::$app->view->registerMetaTag([
'name' => 'description',
'content' => $meta_description,
]);
return parent::render($view, $params);
}
in params
//se impostato prende aggiunge prefisso 'add_prefix_meta_titol' => 1, //se non impostato prende di default il nome del sito sempre se add_prefix è a 1 'prefix_meta_titol' => 'prefix', //se non impostato prende di default ' | ' 'separazione_meta_titol' => ' | ', 'meta_description' => 'Default meta description',
magicalella/yii2-sef 适用场景与选型建议
magicalella/yii2-sef 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 17 次下载、GitHub Stars 达 1, 最近一次更新时间为 2023 年 12 月 20 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「extension」 「meta」 「yii2」 「sef」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 magicalella/yii2-sef 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 magicalella/yii2-sef 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 magicalella/yii2-sef 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A custom URL rule class for Yii 2 which allows to create translated URL rules
Harvest statistics and meta data from an URL or his source code (seo oriented).
Phalcon PHP Meta tags service
The Yii2 extension uses jQuery jquery.carousel-1.1.min.js and makes image carousel from php array of structure defined.
A SilverStripe module to optimise the Meta, crawling, indexing, and sharing of your website content (forked from Cyber-Duck/Silverstripe-SEO)
Help to manage meta data on Laravel Eloquent model
统计信息
- 总下载量: 17
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 20
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-12-20