定制 previewtechs/website-utilities 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

previewtechs/website-utilities

Composer 安装命令:

composer require previewtechs/website-utilities

包简介

Website utilities based on PSR

README 文档

README

composer require previewtechs/website-utilities

General robots.txt

<?php
require "vendor/autoload.php";

$rulesOne = new \Previewtechs\WebsiteUtilities\RobotsDotTxtGenerator\RobotsDotTxtRules('*');
$rulesOne->allow('/test')
    ->allow('/me')
    ->disallow('/thanks');

$rulesTwo = new \Previewtechs\WebsiteUtilities\RobotsDotTxtGenerator\RobotsDotTxtRules('GoogleBot');
$rulesTwo->allow('/test')
    ->allow('/me')
    ->disallow('/thanks');

$robotGenerator = new \Previewtechs\WebsiteUtilities\RobotsDotTxtGenerator\RobotsDotTxtGenerator();
$robotGenerator->addRules($rulesOne);
$robotGenerator->addRules($rulesTwo);

//To print directly
echo $robotGenerator;

//To send response directly
return $robotGenerator->respondAsTextFile(\Psr\Http\Message\ResponseInterface $response);

Output:

User-Agent: *
Allowed: /test
Allowed: /me
Disallow: /thanks

User-Agent: GoogleBot
Allowed: /test
Allowed: /me
Disallow: /thanks

Generate sitemap.xml

<?php
require "vendor/autoload.php";

$urls = [
    'https://site.com/test.php' => [
        'changefreq' => 'daily',
        'priority' => 1,
        'lastmod' => date('Y-m-d')
    ],
    'https://test.com/another_test.php' => [
        'changefreq' => 'daily',
        'priority' => 2,
        'lastmod' => date('Y-m-d')
    ],
];

$gen = new \Previewtechs\WebsiteUtilities\SitemapGenerator\SitemapGenerator();
$gen->loadUrls($urls);
//If you want to send xml response directly
return $gen->respondAsXML(\Psr\Http\Message\ResponseInterface $response);

//Or, if you want to just print the sitemap
echo $gen;

Output:

<?xml version='1.0' encoding='UTF-8'?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9
			    http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">
	<url>
		<loc>https://site.com/test.php</loc>
		<changefreq>daily</changefreq>
		<priority>1</priority>
		<lastmod>2017-09-30</lastmod>
	</url>
	<url>
		<loc>https://test.com/another_test.php</loc>
		<changefreq>daily</changefreq>
		<priority>2</priority>
		<lastmod>2017-09-30</lastmod>
	</url>
</urlset>

301 Redirect

<?php
require "vendor/autoload.php";

//Application wide middleware
$oldAndNewPathMapping = [
    '/oldPath1' => 'newPath1',
    '/oldPath2' => 'newPath2'
];
$threeZeroOneRedirect = new ThreeZeroOneRedirectPsrMiddleware();
$threeZeroOneRedirect->setPaths($oldAndNewPathMapping);
$app->add($threeZeroOneRedirect);
//End of 301 redirect middleware

Bug & Issues

Please submit issues, questions in GitHub Issues.

Contributors

Shaharia Azam from Preview Technologies Limited. To see all contributers click here

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-09-29

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固