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

Pineco.de:
Basic Eloquent Search Techniques
Mar 28, 2018 @ 17:36:01

The Pineco.de blog has a new tutorial posted that the Laravel users out there will find particularly useful. In their latest post, they introduce some basic Eloquent searching techniques that can be used to easily locate data via currently available Eloquent functionality.

When our app is smaller – for example at the beginning – it’s enough to apply small, handmade solutions. It’s true for database searching as well. It’s not necessary to pull in a package instantly. Most of the time we can use some simple techniques to perform searches in Eloquent.

[...] Searching is a vital part of any application. A good interface helps the user to retrieve the information it needs. So it’s essential to bring a good solution both on front-end and back-end. In this post, we are not covering any UI or front-end related topics. [...] So for now, let’s talk about MySQL and Eloquent only.

In the post, they share a few methods for searching data that don't require any additional service or package. They're mostly just taking advantage of features the MySQL database supports but they're showing how to use them in a Laravel environment:

  • simple "where" clauses
  • using the fuzzy matching of the "like" keyword
  • searching JSON columns by a "path"
  • using "sounds like" to find similar values

Each item on the list comes with a few lines of code showing how to use it via an Eloquent model and a brief explanation of what's happening behind the scenes in the database.

tagged: laravel eloquent search where like json soundslike tutorial mysql database

Link: https://pineco.de/basic-eloquent-search-techniques/

CloudWays Blog:
Create Live Search In Laravel Using AJAX
Dec 07, 2017 @ 18:55:08

The Cloudways blog has posted a new tutorial for the Laravel users out there showing you how to create a "live search" box for the contents of your site. They use an e-commerce example and make use of some simple Javascript to return results from a backend script.

Whether you have a blog or an ecommerce store, a search bar is always an essential component of the UI. However, the days of simple search bar is over. These days, a live search bar is much more efficient than a simple search bar because it displays similar content in real time. This increases the chance of landing a sale because the customer could see the largest selection of related products.

The article starts off with the prerequisites for following along including an installation of PHP, MySQL, Apache and Laravel. They include an optional step of setting it all up on a Cloudways server but this isn't required if you want to do it locally. The tutorial then walks through the setup steps and creating the migration for the "products" table it will search. It also shows the creation of the controller and routes for the search endpoints and the view with the Javascript to make the Ajax request. It finishes with a way to test the result and a screenshot of what should be returned.

tagged: live search laravel tutorial ajax request ecommerce

Link: https://www.cloudways.com/blog/live-search-laravel-ajax/

Laravel News:
Command Line Search Tools for Programmers
Oct 30, 2017 @ 14:34:10

On the Laravel News site there's a new post sharing five command line tools that could be helpful for developers and make their workflow a bit simpler.

Over the last several years, I’ve improved my command line searches through a few tools geared towards programmers. These tools help developers find phrases and patterns in text files in an unfamiliar codebase without the complexity of grep.

The following is a list of five command line search tools that will help you as a developer if you are interested in using the command line more for finding code, text, and files quickly without relying on an editor or an IDE. Some of the tools are ‘nix only, but I’ve listed a few that are cross-platform and ridiculously fast!

His list describes the usage and benefits of:

Each includes command examples and, where required, the commands to install the library (as it's not standard for Linux builds).

tagged: commandline tool search programmer tutorial grep ack

Link: https://laravel-news.com/command-line-search-tools-programmers

Scotch.io:
Achieving Geo-search with Laravel Scout and Algolia
Jul 19, 2017 @ 14:38:24

The Scotch.io site has posted a tutorial from author Julien Bourdeau showing you how to combine Laravel Scout, a tool that enables full-text searching on Eloquent models and the Algolia searching service to create a geo-search to locate items in your data based on physical location.

Laravel Scout makes it very easy to setup an external search engine to create consumer-grade search quickly. The package comes with Algolia as a default search engine. I'd like to demonstrate how to make use of the geo-location search feature with Scout.

In this tutorial, you'll learn how to prepare your data for Algolia and Laravel Scout to retrieve items based on location.

We recommend you use front-end search for your app because this implementation model is most efficient. That being said, there are cases where you need backend search, for instance, if you want to generate reports.

The tutorial is then broken up into several steps towards the goal of creating the application:

  • Install Scout
  • Format your data for indexing
  • Search for your records
  • Leveraging Macros

The searching they create allows for location of data either by searching in a given location (coordinates and radius) or locating items inside of a "zone" (a rectangle defined by at least two points). All code is included as well as examples of the data structure Algolia requires for your data input.

tagged: geosearch search geography tutorial laravel laravelscout algolia geolocation

Link: https://scotch.io/tutorials/achieving-geo-search-with-laravel-scout-and-algolia

SitePoint PHP Blog:
How to Build a Lyrics Website with Laravel Scout and Algolia
Jul 06, 2017 @ 17:06:11

On the SitePoint PHP blog they've posted a new tutorial showing you how to create a lyrics website with the combination of Laravel Scout and the Algolia data search service.

In this tutorial, we will create a minimal lyrics web site using Laravel Scout and Algolia. To do so, we need a CRUD app to work with our data, and a search interface to let users search through the content. However, instead of creating the full app from scratch, let’s just install the finished CRUD app that we’ve created for this tutorial.

Algolia is a hosted search engine API, providing us with all the tools and resources we’ll ever need to create products with awesome search capabilities.

The end result is a site with a simple search box that displays the matching album/songs for the search string provided. They start in on the code by bootstrapping the project and setting up the database (including loading it with the included SQL file). Next they install the Laravel Scout package and update the "Song" model to be searchable. The tutorial then walks you through the creation of a Algolia account, indexing the current data and importing it into Algolia. Finally it circles back around to the site and helps you create the pieces (controller/view/etc) to make the frontend search work with the Algolia API for searching the indexed data.

tagged: tutorial algolia search laravel scout lyrics integration api

Link: https://www.sitepoint.com/build-lyrics-website-laravel-scout-algolia/

SitePoint PHP Blog:
How to Search on Securely Encrypted Database Fields
Jun 02, 2017 @ 17:53:59

On the SitePoint PHP blog today they've reposted an article that was originally posted on the ParagonIE blog about searching encrypted information in database fields from author Scott Arciszewski.

This question shows up from time to time in open source encryption libraries’ bug trackers. This was one of the “weird problems” covered in my talk at B-Sides Orlando (titled Building Defensible Solutions to Weird Problems), and we’ve previously dedicated a small section to it in one of our white papers.

You know how to search database fields, but the question is, How do we securely encrypt database fields but still use these fields in search queries?

Our secure solution is rather straightforward, but the path between most teams asking that question and discovering our straightforward solution is fraught with peril: bad designs, academic research projects, misleading marketing, and poor threat modeling.

They start off with some of the examples of bad ways to perform the searching of encrypted information, mostly around either using poor encryption levels or custom created encryption solutions. With those out of the way, the tutorial moves on to their recommended method: using an authenticated encryption scheme (libsodium) and blind indexing. The key to the method is to use a secondary column for the actual searching process, encrypting the value provided and running the search against that, not the encrypted value itself. The article then covers two questions that need to be asked before putting this method to use. The article ends with a method to enhance the previous searching to allow for "fuzzier" searching through the generation of some additional index values in a joined table.

tagged: search security encryption database field tutorial libsodium

Link: https://www.sitepoint.com/how-to-search-on-securely-encrypted-database-fields/

SitePoint PHP Blog:
Taming the Snoo: Playing with the Reddit API
Feb 14, 2017 @ 17:56:58

The SitePoint PHP blog has a new tutorial posted by author Claudio Ribeiro looking at how to "tame the snoo" - using PHP to work with the Reddit API via an OAuth application.

Reddit is a social networking, entertainment, and news website where the content is almost exclusively submitted by users.

[...] Reddit also offers its own API. This way, we can use all the information available on Reddit to enrich our own websites or build our own Reddit clients. In this article, we will tackle some basic Reddit API usage with PHP.

The tutorial starts with a brief overview of the Reddit API and the functionality they're focusing on: the "search" method. Example URLs are included showing the searching of terms, pagination options, sorting and other restrictions. They then bring PHP into the mix, using the Guzzle HTTP library to create a basic "Searcher" class. They also use the Twig templating system to output the results (simple template included). Finally they show how to make the OAuth application on your Reddit account, pull in the "adoy/oauth2" package and the code to connect your service via OAuth to the Reddit API.

tagged: snoo reddit api tutorial guzzle twig search

Link: https://www.sitepoint.com/taming-the-snoo-playing-with-the-reddit-api/

SitePoint PHP Blog:
Build Your Own Dropbox Client with the Dropbox API
Nov 04, 2016 @ 14:36:55

On the SitePoint PHP blog there's a new tutorial posted by author Wern Ancheta showing you how to make your own DropBox client with the help of a bit of PHP and the DropBox API.

There are lots of file hosting solutions out there, but few things compare to Dropbox because of its simplicity, auto-sync feature, cross-platform support and other cool features.

As a PHP developer you can even take advantage of their API in order to create apps that use its full capabilities. In this article, you’ll learn how to build one such app to perform different operations in a user’s Dropbox account. You will be using the Dropbox API version 2 in this tutorial. If you want to follow along, you can clone the project from Github.

They start off by walking you through the creation of an application on the DropBox side (required to connect to the API) and how to get its credentials (complete with screenshots). With that set up they get into the application - a simple Laravel-based setup that lets you connect to your account and get information like current file lists, user info and even upload new files. The tutorial includes all of the code for the controllers, models, views, routes, etc. you'll need to make it all work. There's even search functionality letting you look through current files/folders and locate certain items.

tagged: dropbox client api tutorial laravel application upload search list crud

Link: https://www.sitepoint.com/build-your-own-dropbox-client-with-the-dropbox-api/

Laravel News:
Learn how to use the TNTSearch driver with Laravel Scout
Oct 19, 2016 @ 16:52:50

On the Laravel News site there's a new tutorial posted showing you how to hook in the TNTSearch package with the Laravel Scout functionality replacing the default Algolia driver.

Laravel Scout provides a simple, driver-based solution for adding full-text search to your Eloquent models.

Out of the box, Laravel 5.3 ships with Algolia driver. However, we can easily write custom drivers; that’s exactly what TeamTnt has done by providing a TNTSearch driver for Laravel Scout.

The tutorial then walks you through getting the TNTSearch driver installed and integrated into your Laravel application (via Composer). They they show it in use on a sample database of film information and creating the related models. They show how to add in the "Searchable" trait for Scout, indexing the data and using the "search" method to locate matching results.

tagged: tntsearch driver scout laravel tutorial search

Link: https://laravel-news.com/2016/10/tntsearch-with-laravel-scout/

Laravel News:
Laravel Scout is now open for developer testing
Aug 16, 2016 @ 15:37:38

The Laravel News site has a new post with an update for those looking forward to trying out Laravel "Scout", the search handling to be released along side the next Laravel framework release. The post announces that Laravel Scout is now open for developer testing directly from the live repository.

Laravel Scout is a driver based full-text search for Eloquent that is going to be available when Laravel 5.3 launches.

The driver is not officially released yet, however, the repository is now live and available for those that want to play with more engines. Taylor said he would be working on docs this week in anticipation of the official 5.3 release and this first release should only be used in testing until it’s officially launched.

If you're interested in more details about Scout, check out this post from Matt Stauffer with details and code examples.

tagged: laravel scout developer testing search functionality

Link: https://laravel-news.com/2016/08/laravel-scout-is-now-open-for-developer-testing/


Trending Topics: