samdark / sitemap Goto Github PK
View Code? Open in Web Editor NEWSitemap and sitemap index builder
License: BSD 3-Clause "New" or "Revised" License
Sitemap and sitemap index builder
License: BSD 3-Clause "New" or "Revised" License
I was reading your code, and if I am understanding for good, I haven't found a method that does a spider thing to build the whole sitemap, you must put one per one?
Hello,
I installed the package with composer (composer require samdark/sitemap
) so I'm running version 2.2.0. My environment is Windows 7, PHP 7.2.13.
Here's the code I tested:
use samdark\sitemap\Sitemap;
$sitemap = new Sitemap(__DIR__ . '/sitemap.xml');
$sitemap->addItem('http://example.com/mylink1');
$sitemap->write();
And this is the output I get:
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>http://example.com/mylink1</loc>
</url>
</urlset>
I think the
is a bug... or did I miss something?
Hi, how to append new items in 'sitemap.xml' after finished.
Sorry, but my english is not so good.
Thanks you.
Google has support of XML Sitemap rel=alternate elements for relationship between web site and mobile app.
https://developers.google.com/app-indexing/reference/deeplinks?hl=en
Seems that when a NavItem langugae is deleted, the $navItem->lang
object is null. So accessing the short_code
attributes gives an error.
It will be good to have sitemap minified into one long line without space between tags. Idea is the same as JS, HTML, CSS minification.
Hello,
Thanks you for all this, you did a good job :)
In the futur, if you can remove the "@" from unlink (Sitemap.php, inside createNewFile()) to make your code compliant with the strict dev environnement, it would be nice.
if(is_file($filePath)){ unlink($filePath);}
Best regards,
V
I need to add an xml-stylesheet
to the sitemap, but can't access the $writer
.
Is there a way to add a Pi?
Thanks!
Or it can support mysqli?
filter_var($location, FILTER_VALIDATE_URL)
`Your requirements could not be resolved to an installable set of packages.
Problem 1
- Can only install one of: samdark/sitemap[2.0.0, dev-master].
- Can only install one of: samdark/sitemap[2.0.1, dev-master].
- Can only install one of: samdark/sitemap[2.0.2, dev-master].
- Can only install one of: samdark/sitemap[2.0.3, dev-master].
- Can only install one of: samdark/sitemap[2.0.4, dev-master].
- Can only install one of: samdark/sitemap[2.0.5, dev-master].
- Can only install one of: samdark/sitemap[2.0.6, dev-master].
- Can only install one of: samdark/sitemap[2.0.7, dev-master].
- Installation request for samdark/sitemap dev-master -> satisfiable by samdark/sitemap[dev-master].
- Installation request for samdark/sitemap ^2.0 -> satisfiable by samdark/sitemap[2.0.0, 2.0.1, 2.0.2, 2.0.3, 2.0.4, 2.0.5, 2.0.6, 2.0.7].
Installation failed, reverting ./composer.json to its original content.`
при мультиязыковой карте, количество ссылок в Число языков больше
нужно
$this->urlsCount = $this->urlsCount + count($location);
Hi,
I like this repo - so far the simpliest (no stupid requirements) with best documentation. Can you add support for image sitemap? Kindly see this:
Since self::flush accepts an int as a parameter but a bool is provided here:
Line 184 in a7ba091
It seems that it's a typo of some kind. Probably
$this->flush(0);
should be there.
This is based on discussion in #24 where I want to be able to write the sitemaps and index to Amazon S3.
I think a very simple interface like this may work:
interface FilesystemAdapterInterface
{
/**
* Create a file or update if exists.
*
* @param string $path The path to the file.
* @param string $contents The file contents.
*
* @return bool True on success, false on failure.
*/
public function put($path, $contents);
}
And then a FilesystemAdapter could be passed into the constructor and used when writing files.
This is more a comment than an issue. I'm using this with Yii2.
I found I need:
use samdark\sitemap\Sitemap;
use samdark\sitemap\Index;
When I used:
use samdark\sitemap
classes Sitemap and Index were not found. Might be a stupid error on my part, but in case others are having the same issue, I thought I'd mention it.
hi dear
i download sitemap and update with composer update command line
i am amator and need help you for run this script
for example i create index.php and set this code
////////////////
I'd love to see some unit tests validating behaviour but that's up to you. Could be merged w/o it.
I was planning to add these covering tests as part of v3 or as an additional issue post-merge.
I'll create an issue for the example sitemap and further tests (assuming it is not going to be re-written in 3.x)
Originally posted by @craftyshaun in #63 (comment)
Change type from private
to protected
for extending classes.
When i to add URL on Cyrylica - on Russian language", i get error from validation URL.
Why do you make validation URL? I think than it need removed. Validation must don't be related with this lib.
Fatal error: Uncaught InvalidArgumentException: The location must be a valid URL. You have specified: https://wxm/кекеё5. in ...vendor\samdark\sitemap\Sitemap.php:243 Stack trace: #0 ...vendor\samdark\sitemap\Sitemap.php(297): samdark\sitemap\Sitemap->validateLocation('https://wxm..')
...vendor\samdark\sitemap\Sitemap.php(272): samdark\sitemap\Sitemap->addSingleLanguageItem('https://wxm_...', 1524153061, 'weekly', 0.3) #2
.../index.php(13): samdark\sitemap\Sitemap->addItem('https://wxm/...', 1524153061, 'weekly', 0.3) #3 {main}
...vendor\samdark\sitemap\Sitemap.php on line 243
На данный момент вижу что скрипт дописывает если файл сайтмап существует уже верно ?
Я так понимаю надо удалять файлы сайтмап перед регенерацией верно ?
The problem lays in flush() function.
When a sitemap is truncated by size here:
Line 232 in a7ba091
finishFile() functions is called which leads to zeroing urlsCount variable, but right after that a remaining chunk is appended to a file here (with contains up to $bufferSize URLs):
Line 240 in a7ba091
Those URLs in that chunk aren't counted anywhere and a next sitemap overflows.
Google has support management multiple sitemap files and allow to submit them as one .
Need to create sitemap.index.xml file with list of sitemap files
Example:
<?xml version="1.0" encoding="UTF-8"?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<sitemap>
<loc>http://www.example.com/sitemap1.xml.gz</loc>
<lastmod>2004-10-01T18:23:17+00:00</lastmod>
</sitemap>
<sitemap>
<loc>http://www.example.com/sitemap2.xml.gz</loc>
<lastmod>2005-01-01</lastmod>
</sitemap>
</sitemapindex>
Sitemap.php : 171 throws Error, if an url contains either of ä, ü or ö.
Unfortunately there is no way of overriding, so I would suggest to extract the validation into a separate function, so that it could be overriding in a deriving class.
Смысл в том, что когда приходится генерировать сразу карту сайта большого размера (более 1 млн. строк) приходится делать ее генерацию рекурсией и отдавать вашему скрипту порциями по 25 тыс. строк за раз, чтобы скрипту не приходилось долго ждать ответа от сервака. Так вот при каждой отправке порции строк он тупо перезаписывает файл, а не дополняет его. Нельзя ли доработать так, чтобы скрипт добавлял записи, а не перезаписывал их по новой?
We have an error at Travis job:
PHP 5.3 is supported only on Precise.
See https://docs.travis-ci.com/user/reference/trusty#PHP-images on how to test PHP 5.3 on Precise.
Solution is to add php 5.3 to matrix:
matrix:
include:
- php: 5.3
dist: precise
I am not sure but this throws an exception because of special chars in url. But it seems that special chars are very common now (i just asked my self when it was the time this switched...)
The location must be a valid URL. You have specified: https://example.com/künstliche-intelligenz
File: samdark/sitemap/Sitemap.php
Line: 243
(The original domain was: https://heartbeat.gmbh, which is a valid domain)
It would be nice if the last modified date for each additional sitemap was determined automatically. For the sitemap-index, I mean...
Hi, I found really helpful this package, but since I need to use a different writer I was wondering if its possible to add a method to export the XML as a string for both the classes Sitemap and Index.
Здравствуйте. Подскажите пожалуйста как можно интегрировать этот скрипт для https://softbigkey.ru
Hi,
while researching packages for building sitemap XMLs I've found this neat feature in this package https://github.com/nilportugues/php-sitemap#block4.1
I think that would be interesting in this package? (at this moment I dont need it, but if I find the time I could implementing in this package and found out if it works).
Thanks for the package and have a great day,
Sitemaps can be compressed by gzip
http://www.sitemaps.org/faq.html#faq_compression
Thanks for well coded library. I successfully installed and using this library in Symfony2 framework. Just want to share my code that can be merged into readme and useful for someone else.
// app/config/services.yml
services:
sitemap.generator:
class: samdark\sitemap\Sitemap
arguments: ["%kernel.root_dir%/../web/sitemap.xml"]
Use it as a service
$sitemap = $this->getContainer()->get('sitemap.generator');
Здесь https://github.com/samdark/sitemap/blob/master/Sitemap.php#L97 должно быть:
return $this->writtenFilePaths;
Версия 2.0.5 битая, в последнем коммите закоммитили баг. Нужен хотфикс.
https://www.sitemaps.org/ru/protocol.html#lastmoddef
Дата последнего изменения файла. Эта дата должна быть в формате W3C Datetime. Этот формат позволяет при необходимости опустить сегмент времени и использовать формат ГГГГ-ММ-ДД.
I have using this composer for my project but I don't know how to add xhtml:link into sitemap, please help me when you have time, thanks a lot!
Hi,
please add the dependency on XMLWriter explicitely into your composer.json:
"ext-xmlwriter": "*",
It would be useful to have an ability to update a sitemap. The use case is where URLs are being added dynamically. Currently, I can't easily append just one URL to the sitemap.
http://www.sitemaps.org/faq.html#faq_compression
Since sitemap size is limited to 10mb http://www.sitemaps.org/faq.html#faq_sitemap_size it is also good to gzip sitemap after minification.
Here is a difference in files, there are two start sequences in multi-time-write.gz
:
It works fine with 7Zip decompressing, but browsers couldn't get it. So I'm worrying whether all search engines would correctly handle it for now and for future comparability.
I've prepared a workaround for my project with disabling gzip for Sitemap instances and compressing already generated files:
<?php
$tempfile = fopen('php://temp/', 'r+');
$sitemapRead = fopen($path, 'r');
stream_copy_to_stream($sitemapRead, $tempfile);
fclose($sitemapRead);
rewind($tempfile);
$sitemapWrite = fopen('compress.zlib://' . $path, 'w');
stream_copy_to_stream($tempfile, $sitemapWrite);
fclose($sitemapWrite);
fclose($tempfile);
And I can't figure out any ways to fix this issue inside a library. Can you share your thoughts, so I can prepare a PR with a fix?
Why is the validateLocation function protected and not private?
Line 259 in 17dc560
Can the output format of the lastmod tag support Y-m-d
For example, if it is not an integer format parameter, let him use it directly as a string.
This makes Google think it's blackhat/spam if the lastmod date for every single post is the same date/time when the site was compiled. I can't figure out how to get it to not do that without just removing , time()
from the generator.
Fatal error: Class 'samdark\sitemap\Sitemap' not found
Почитал аналогичные описания у Вас в ветке но так и не понял почему вылазит ошибка: немспейсы стоят корректно, шторм ошибок не показывает. Использовал пример с Вашего описания.
If it exceeds 10 MB, next sitemap should be used.
As discussed in #63 it would be great to have a stylesheet example for the developers to use using the setStylesheet()
implemented in #63
An example has been provided @ParitoshBh
sitemap.txt
@samdark has confirmed that we can add some attribution back to the GitHub repo to grow the audience.
Originally posted by @ParitoshBh in #63 (comment)
hello when i write
composer require samdark/sitemap
i see
composer: command not found
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.