Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Solr PHP client vs file_get_contents?

Tags:

I am using PHP to access Solr and I wonder one thing.

Why should I use Solr PHP client when I can use:

$serializedResult = file_get_contents(
                      'http://localhost:8983/solr/select?q=niklas&wt=phps');

to get the result in arrays and then print them out? I don't really get the difference. Are there any richer features with the PHP client?

like image 926
ajsie Avatar asked Dec 15 '09 13:12

ajsie


2 Answers

I think because of following reasons:

  • Flexibility
  • Error Handling
  • Security Issues
  • Extendibility

All issues are the headache of these pre-made scripts and frameworks. So if there is a solution for certain thing, i would recommend you to go with that rather than doing everything from your own.

Also since these scripts and frameworks have good community support, there are lesser bugs, security issues and more.

like image 74
Sarfraz Avatar answered Oct 02 '22 13:10

Sarfraz


The solr-php-client library actually has an adapter for file_get_contents (@see Apache_Solr_HttpTransport_FileGetContents), plus another for Curl. The solr-php-client library is an elaborate framework that allows you to do much more than post a URL w/ parameters so you can complete a search. SPC provides predictability, extensibility, and security. Furthermore, the solr-php-client is written to Zend Framework standards, so it compliments any ZF project.

If I have a choice between choosing a well-maintained, community-supported project, and writing my own script which will not be superior, I choose the well-maintained, community-supported project. If you have needs that are outside of that project, you can still write your own script, but again, this kind of library is build so you can extend it painlessly.

like image 28
webjawns.com Avatar answered Oct 02 '22 12:10

webjawns.com