News Feed
Jobs Feed
Sections




News Archive
feed this:

Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Michael Dowling:
Favor Hash Lookups Over Array Searches
March 21, 2014 @ 10:47:34

Michael Dowling has a recent post to his site comparing the performance of hash lookups versus array searches.

A common programming requirement is to match a string against a set of known strings. For example, let's say you were iterating over the words in a forum post and testing to see if a word is in a list of prohibited words. A common approach to this problem is to create an array of the known prohibited words and then use PHP's in_array() function to test if the string is found in the list. However, there's a simple optimization you can make to significantly improve the performance of the algorithm.

He includes two pieces of sample code - one showing the searching of an array using in_array and the other running an isset to locate a key. He points out that the in_array method is quite a bit slower than the hash (key) lookup and includes a benchmark script to prove it.The results are pretty clear, with the hash lookup coming in about 480% faster than the in_array. He also points out that as the size of the strings you're comparing grows, the performance of in_array drops even more.

0 comments voice your opinion now!
hash lookup search array inarray benchmark

Link: http://mtdowling.com/blog/2014/03/17/hash-lookups-over-array-search/

Gary Sieling:
Scraping Google Maps Search Results with Javascript and PHP
July 29, 2013 @ 12:23:21

Gary Sieling has a new post to his site about scraping Google Maps data with a combination of PHP and some simple Javascript. It makes use of callbacks and timers to get the data already returned from their API.

Google Maps provides several useful APIs for accessing data: a geocoding API to convert addresses to latitude and longitude, a search API to provide locations matching a term, and a details API for retrieving location metadata. For many mapping tasks it is valuable to get a large list of locations (restaurants, churches, etc) - since this is valuable, Google places a rate limiter on the information, and encourages caching query results.

He includes the code (both front- and back-end) that you'll need to make the system work. It makes a request to the Google Maps API as usual but then adds a listener with a callback. This takes the latitude/longitude data and runs a "get details" method to get more information. The result is then POSTed to PHP and written out to a file.

0 comments voice your opinion now!
googlemaps google search results scraping api javascript tutorial

Link: http://garysieling.com/blog/scraping-google-maps-search-results-with-javascript-and-php

Lorna Mitchell:
Twitter Search API Using PHP and Guzzle
July 11, 2013 @ 12:49:45

Lorna Mitchell has a new post to her site today showing how she connected to Twitter with Guzzle, the popular PHP-based HTTP client (also used in the Amazon Web Services PHP client).

In case you missed it, Twitter updated their APIs recently, so that you have to authenticate to use even their search APIs to return publicly-available results. This is an increasing trend for API providers, to provide either very limited or nonexistent access for unauthenticated users, I think so they can rate limit consumers that swamp them. To cut a long story short, that meant I needed to update my dashboards that keep an eye on twitter searches to do more than just call file_get_contents in the general direction of the right URL.

She walks you through the creation of the client complete with the OAuth plugin (included with Guzzle) to make an OAuth request to api.twitter.com. With the client created, she shows a simple search call to the "tweets" endpoint.

0 comments voice your opinion now!
twitter search guzzle tutorial http client oauth api

Link: http://www.lornajane.net/posts/2013/twitter-search-api-using-php-and-guzzle

System Architect:
Integrate PHP application with Solr search engine
March 12, 2013 @ 12:01:43

On the "System Architect" site there's a recent post showing you how to integrate PHP and Solr, the searching tool from the Apache project.

So why do you need a search engine, is database not enough? If you create a small website it might not matter. With medium or big size applications it's often wiser to go for a search engine. Saying that, even a small websites can benefit from Solr if you desire a high level of relevance in search results.

Their example involves an ecommerce website and a search for a term (iPhones) and how difficult it could be to match against the possible multiple variations on the models. Solr makes this kind of searching easier. He shows you how to get a Solr instance all set up and configured as well as the PHP PECL extension from here. A sample PHP script is also included showing connecting to Solr, inserting a new document and searching for a simple query of "hello".

0 comments voice your opinion now!
solr search engine tutorial integration pecl extension


Jeroen van Dijk:
Multi-select faceting in Solr with Solarium
November 07, 2012 @ 12:14:14

If you're a user of the Solarium tool for querying Solr database already and have been wondering how to work with faceting, you should take a look at this new post from Jeroen van Dijk. He covers using Solarium to do multi-select faceting in a Solr query.

Solarium is a library I often use at Enrise for querying Solr. For one of the projects I work on, AutoTrack.nl a second hand car site, I was having issues on advanced faceting with Solr which I could easily solve using Solarium. [...] Faceting is a technique for guided navigation where search results are separated into categories, often including counts on those categories. The user can then select from those categories to restrict their search step by step.

He includes an example of what kind of results this sort of searching could return and how you can use the "facet.mincount" to restrict the results to an even finer set. There's a bit of code included showing how to use this filtering method with a combination of "addFilterQuery" and "createFacetField" calls before executing the select through Solarium.

0 comments voice your opinion now!
solr search solarium facet mincount tutorial


WebSpeaks.in:
Search Google Plus Profiles using PHP and Google Plus API
June 01, 2012 @ 09:05:05

In this new tutorial to the WebSpeaks blog, Arvind Bhardwj shows you how to hook up to the Google+ API and search profiles for your desired terms.

The main aim of this application is to go familiar with the Google Plus API usage. Google Plus provides an extremely easy to use API to access the public contents on it. Here we will create a simple search application to search user profiles on Google Plus.

Complete code is provided in the post (PHP) and instructions on setting up an "application" on G+ so you can get the keys needed to connect to the API. You can see it in action in the live demo or just download the source to get started.

0 comments voice your opinion now!
googleplus api search profile demo


Joshua Thijssen's Blog:
Bloom Filters
April 09, 2012 @ 11:13:32

In this new post to his blog Joshua Thijssen describes something that can help when processing large amounts of data (like, in his example, the text of a book) to search through the information and find if a certain piece of data is in the set - a bloom filter.

Most of my co-workers never really heard of bloom filters, and I'm continuously need to explain what they are, what their purpose is and why it's a better solution than other ones. So let's do an introduction on bloom filters. [...] Bloom filters have the property of being exceptionally fast AND exceptionally small compared to other structures but it comes with a price: it MIGHT be possible that our bloom filter thinks that an element is inside our set, when it really isn't. Luckily, the reverse is not possible: when a bloom filter says something is NOT in the set, you are 100% sure that it isn't part of the set.

He explains how the filter works, noting how it's better for memory consumption and how it's possible for it to give a "maybe" response instead of ab absolute "yes" or "no". He also points out a PHP extension, bloomy that takes the hard work out of it for you.

0 comments voice your opinion now!
bloom filter search memory consumption speed


Design Aeon:
Cake PHP Search Component
April 02, 2012 @ 09:56:32

On the Design Aeon blog there's a new post sharing a CakePHP component that can be used to easily add searching to your framework-based application.

Cake Php Search Component is used to implement search in your cake php projects.The component provide highly reusability. component is meant to use across all the controllers. you just include this search component in your Controller and call a component function to fetch your conditions types in search form and refine the data .

The component (available for download here) is simple to install and full instructions for implementing it are included in the post - including it in the controller, creating search and pagination elements, making a controller action and finally making a view to tie it all together.

0 comments voice your opinion now!
cakephp framework search tutorial


PHPClasses.org:
PHP Zeitgeist 2012
January 18, 2012 @ 10:04:24

On the PHPClasses.org blog there's a new post with a "zeitgeist" they've generated from statistics on the site (such as search queries and overall popularity of packages).

For those that are not yet aware of this probably because they only arrived to the PHPClasses site recently, PHP Zeitgeist is an initiative that aims to study what were the last year trends regarding what PHP developers have been searching for.

According to their results, some of the trends ramping up (or still going strong) for 2012 include:

  • Social media sites
  • Sites like Groupon, Foursquare and Bitcoin
  • jQuery plugins
  • Doctrine
  • MODX
  • SugarCRM
0 comments voice your opinion now!
zeitgeist2011 phpclasses zeitgeist search


PHPMaster.com:
Practicing Regular Expressions with Search and Replace
November 23, 2011 @ 14:27:59

On PHPMaster.com today there's a new tutorial that shares a few regular expression tips about doing some search and replace in your content.

So how can you practice using regex if you are limited to just using them in your code? The answer is to use a utility, of which there are many, that uses regex for performing search and replace. I'm sure everyone is familiar with the standard "find x and replace it with y" type of search and replace. Most IDEs and text editors have built in regex engines to handle search and replace. In this article I'd like to walk through a series of exercises to help you practice using regex.

His examples are based on Netbeans but can be used in just about any IDE that supports regex (or even just your code). He shows how to match word boundaries, do some grouping, work with back references and doing some search/replace based on multiple groupings.

0 comments voice your opinion now!
regular expression practice search replace boundaries group backreference



Community Events











Don't see your event here?
Let us know!


composer component language opinion performance application series database security release unittest facebook install introduction podcast hack framework hhvm symfony2 package

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework