What is the best way to create a search facility for static content in Symfony? -


i've built static website using symfony 2.6, has been translated 8 different languages , includes several forms.

it requires search facility, best way achieve this?

search facility can gained using:

  • special database requests, in mysql select * article article.body '%searched_query%'
  • full text search can achieved using tools like:

    but in both cases should save content in database or other files.

  • in case workaround suggest crawl own site , return links sites found searched text sort of stuff

    use symfony\component\domcrawler\crawler;  class internalcrawler {      private $crawler;     private $texttosearch;     private $matchedurls;      public function __construct($texttosearch)     {         $this->texttosearch = $texttosearch;     }      protected function requesturl($url)     {         //curl url crawl         //...          return $html;     }      protected function geturlstocrawl()     {         return array(             'url-to-homepage',             'url-to-an-article-page',             ...         );     }      protected function match($url, $html)     {         $this->crawler = new crawler($html);         $textexists = $this->crawler->filter("html:contains('{$this->texttosearch}')")->count();         if ($textexists) {             $this->matchedurls[] = $url;         }     }      public function getmatchedurls()     {          foreach ($this->geturlstocrawl() $url) {              $html = $this->requesturl($url);              $this->match($url, $html);          }           return $this->matchedurls;     } } 

as result have list of urls matched searched text.


Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -