Hi, i'm just thinking on generating an sitemap.xml to my /public folder
My code:
<?php
class SitemapController extends \Phalcon\Mvc\Controller
{
public function generujSitemap() {
$response = $this->response;
$response->setHeader('Content-Type', "application/xml; charset=UTF-8");
$sitemap = new \DOMDocument("1.0", "UTF-8");
/* generating sitemap.xml */
$sitemap->appendChild($urlset);
$response->setContent($sitemap->saveXML());
$response->setFileToSend($_SERVER["DOCUMENT_ROOT"].'/public/sitemap.xml', null, false);
return $response->send();
}
}
class IndexController extends \Phalcon\Mvc\Controller
{
public function sitemapAction(){
$this->view->disableLevel(View::LEVEL_MAIN_LAYOUT);
$SiteMap = new SitemapController();
return $SiteMap->generujSitemap();
}
}
It gives me a proper sitemap in browser, but how to save it into to the server?