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

How to connect ELK with Monolog
Oct 23, 2017 @ 10:48:59

On the Pehapkari.cz blog there's a new tutorial posted showing you how to integrate ELK and Monolog for simpler to use and more robust log handling.

ELK is awesome stack for logging. Monolog is awesome PHP logging library. Let's make them work together. [...] In a nutshell, Monolog offers you a logger, where you send your logs. This logger has multiple handlers, which send these logs wherever you need them. Monolog has many handlers, which enable you to to simply send logs to many destinations, e.g. files, e-mails, slack, logstash, and many more. [...] ELK stack (now known as Elastic stack) stands for Elasticsearch, Logstash, Kibana stack.

After briefly introducing both technologies the author then gets into the integration, showing how to use either the ElasticSearchHandler or Gelf to ship the logs over for handling. Monolong includes the handler to make this work and the post includes the code/configuration to use it. With the logs being sent out the next step is to set up where you're sending them to. In this case it's a RabbitMQ setup that will then send them along to Logstash. Configuration for this is included as well.

tagged: elk logstash elasticsearch kibana tutorial monolog package integration

Link: https://pehapkari.cz/blog/2017/10/22/connecting-monolog-with-ELK/

Laravel News:
Laravel and Elasticsearch
Jun 16, 2016 @ 09:08:22

The Laravel News site has posted a quick guide for those wanting to use ElasticSearch along with their Laravel applications. The post lists several libraries and resources that can help you get started quickly.

Elasticsearch allows you to search & analyze data in real time. Even though it’s extremely powerful working with delta’s and querying data is not that simple.

If you are using Laravel here is a list of packages and tutorials to help you easily integrate this into your app.

The packages include Plastic and Spatie Searchindex while the tutorials cover things like installing ElasticSearch on Homestead and integrating it with your application.

tagged: laravel elasticsearch integration tutorial library package links

Link: https://laravel-news.com/2016/06/laravel-and-elasticsearch/

SitePoint PHP Blog:
Monitoring WordPress Apps with the ELK Stack
Jun 13, 2016 @ 13:21:25

On the SitePoint PHP blog there's a new tutorial from Daniel Berman showing you how to use the ELK stack to monitor WordPress applications, a combination of Elastic Search, Logstash and Kibana. You can find out about setting this stack up in this previous tutorial.

When something does go wrong, one of the first things you’re going to want to look at are the log files. Not because you enjoy it — log files are not easy to decipher — but because they contain valuable information that can shed light on what exactly occurred.

While [you can use the WP Log Viewer], analyzing WordPress and PHP logs is simply not enough. There are also web server and database logs to sift through. To successfully query huge volumes of log messages coming in from various sources and identify correlations, a more solid solution is required.

Enter the ELK Stack.

He shows how to enable the logging features in your WordPress application (in the wp-config file) and ensure they're not output to the users of your site. He then shows you how to install Filebeat to ship the logs over to the ELK stack. He switches over to the ELK side and shows the configuration needed on Logstash to properly handle the WordPress log format. The remainder of the post helps you get started analyzing the log results and limit it down to only what you need via the Kibana query syntax.

tagged: elk stack monitor wordpress elasticsearch kibana logstash tutorial query

Link: https://www.sitepoint.com/monitoring-wordpress-apps-with-the-elk-stack/

SitePoint PHP Blog:
How Can the ELK Stack Be Used to Monitor PHP Apps?
May 12, 2016 @ 10:42:36

The SitePoint blog has posted a new tutorial from author Daniel Berman about using the ELK stack to monitor PHP applications. The ELK stack is made up of Elasticsearch, Logstash and Kibana to make for effective log storage and searching.

A modern web application environment consists of multiple log sources, which collectively output thousands of log lines written in unintelligible machine language. If you, for example, have a LAMP stack set up, then you have PHP, Apache, and MySQL logs to go through. Add system and environment logs into the fray — together with framework-specific logs such as Laravel logs — and you end up with an endless pile of machine data.

Talk about a needle in a haystack. [...] The ELK Stack (Elasticsearch, Logstash, and Kibana) is quickly becoming the most popular way to handle this challenge. Already the most popular open-source log analysis platform — with 500,000 downloads a month, according to Elastic — ELK is a great way to centralize logs from multiple sources, identify correlations, and perform deep-data analysis.

They walk you through the full installation of all three tools starting with Java (they all require it) followed by instructions for each piece. Once they're all up and running (and playing nice together) they help you configure it to pull in Apache access logs and search on the results. They then populate it with quite a bit more sample data and share some basic tips on searching using the custom searching "language". Finally they talk about the visualizations Kibana offers complete with an example showing browser percentages from users of the site.

tagged: elk stack tutorial monitor elasticsearch logstash kibana setup configure apache log

Link: http://www.sitepoint.com/how-can-the-elk-stack-be-used-to-monitor-php-apps/

CloudWays Blog:
Samantha Quiñones Shares Insights On APIs, Elasticsearch And R-Language Programming
Apr 18, 2016 @ 09:05:32

On the Cloudways blog they've posted another interview with a member of the PHP community. In this latest post they talk with Samantha Quiñones, a principal software engineer at AOL and user group organizer.

Samantha Quiñones is the principal software engineer at AOL, organizer of DC PHP user group and a speaker. She is a certified R-programmer with vast experience in developing REST APIs. In her interview with Cloudways she talks about the early years of her career, her experience as a speaker and in the end gives advice on who to follow in the PHP community.

In the interview Samantha answers questions about:

  • how she got started in her career as a developer
  • why she started speaking and where she'll be speaking
  • her experience as a security developer at Saint
  • what she enjoys doing when not programming

Finally, she makes a recommendation of someone to follow if you want to get involved in the wider PHP community or just want a good person to start with: Cal Evans.

tagged: cloudways interview samanthaquinones api rest elasticsearch rprogramming community

Link: http://www.cloudways.com/blog/samantha-quinones-interview/

SitePoint PHP Blog:
Introduction to Elasticsearch in PHP
Aug 04, 2015 @ 09:31:05

The SitePoint PHP blog has posted an introduction to using Elasticsearch in your PHP applications. In it author Wern Ancheta covers some of the basics of this powerful tool and helps you get an example script up and running for testing.

In this tutorial, we’re going to take a look at Elasticsearch and how we can use it in PHP. Elasticsearch is an open-source search server based on Apache Lucene. We can use it to perform super fast full-text and other complex searches. It also includes a REST API which allows us to easily issue requests for creating, deleting, updating and retrieving of data.

He starts by helping you get Elasticsearch itself installed via the apt-get package manager (may slightly differ depending on your OS of choice) and tested with a simple web-based request to the port the server is running on. With the server set up he then moves on to the PHP aspect, helping you get the elasticsearch library installed via Composer and creating a new client instance. He then includes code examples of some of the main operations you'll perform with entries in the Elasticsearch instance: inserting a document, updating a document, deleting and - of course - searching for documents matching certain simple and more complex criteria.

tagged: introduction tutorial elasticsearch install library insert update delete search

Link: http://www.sitepoint.com/introduction-to-elasticsearch-in-php/

SitePoint PHP Blog:
Integrate Elasticsearch with Silex
Apr 13, 2015 @ 08:38:55

The SitePoint PHP blog has continued their look at integrating Elasticsearch into a simple Silex-based PHP application. In this latest part of the series (part two) they move away from the full Drupal example in part one and go a bit more simple and create a basic site to show a node's detail (content and title).

In the previous article I started exploring the integration between Drupal 7 and the Elasticsearch engine. The goal was to see how we can combine these open source technologies to achieve a high performance application that uses the best of both worlds. [...] We’ll now create a small Silex application that reads data straight from Elasticsearch and returns it to the user.

Using Silex and the same Elasticsearch PHP SDK they create this simple site. The tutorial walks you through the installation of both tools, the configuration of the Elasticsearch client and creating the controllers to respond to the view requests. They also show how to use the Twig templating engine to render the results as a simple page containing the node title, any images attached to it and the body content. The tutorial ends with a brief mention of how this same data could also be rendered as JSON output with a different view handler.

tagged: silex tutorial elasticsearch simple twig template json node drupal

Link: http://www.sitepoint.com/integrate-elasticsearch-silex/

SitePoint PHP Blog:
Install and Integrate Elasticsearch with Drupal
Apr 10, 2015 @ 10:37:55

The SitePoint PHP blog has a recent tutorial posted showing you how to integrate Drupal and Elasticsearch to make for more effective searching of your content. This is the second part of this series.

In this tutorial I am going to look at the possibility of using Drupal 7 as a content management system that powers another high performance application. To illustrate the latter, I will use the Silex PHP microframework and Elasticsearch as the data source. The goal is to create a proof of concept, demonstrating using these three technologies together. [...] The tutorial will be split into two pieces, because there is quite a lot of ground to cover. In this part, we’ll set up Elasticsearch on the server and integrate it with Drupal by creating a small, custom module that will insert, update, and delete Drupal nodes into Elasticsearch.

They assume you already have an Elasticsearch install set up and ready to go but do offer some suggestions on how to configure it to be a little bit more secure. Then, in your Drupal application (again, already installed) they show you how to use the Elasticsearch module to connect to the ES instance and, once connected, insert, update and delete data for the data in your nodes.

tagged: tutorial elasticsearch drupal integrate node storage

Link: http://www.sitepoint.com/install-integrate-elasticsearch-drupal/

Efficient Chinese Search with Elasticsearch
Dec 19, 2014 @ 11:56:41

On the SitePoint PHP blog a new tutorial has been posted showing you how to effectively search Chinese content with ElasticSearch. ElasticSearch is a "powerful open source search and analytics engine that makes data easy to explore" and plays nice with PHP via a JSON based query format.

If you have played with Elasticsearch, you already know that analyzing and tokenization are the most important steps while indexing content, and without them your pertinency is going to be bad, your users unhappy and your results poorly sorted. Even with English content you can lose pertinence with a bad stemming, miss some documents when not performing proper elision and so on. And that’s worse if you are indexing another language; the default analyzers are not all-purpose. When dealing with Chinese documents, everything is even more complex, even by considering only Mandarin which is the official language in China and the most spoken worldwide.

He starts by explaining exactly what the problem is with searching Chinese content including the fact that some words can actually be a combination of two or more characters (words). He then lists out a few plugins and tools that can be integrated with ElasticSearch to help with analyzing the content. He goes through each of them and provides instructions on installation and usage. He ends the post with a sample of the results for a set of three search terms, comparing the matches each found.

tagged: chinese search elasticsearch tutorial tokenization analysis

Link: http://www.sitepoint.com/efficient-chinese-search-elasticsearch/

VG Tech Blog:
Using Elastica to Query ElasticSearch
Jul 03, 2012 @ 08:55:10

On the VG Tech blog today there's a new post by Christer Edvartsen about using the Elastica PHP Elastic Search client to do more than just pull information out of the data source. He dug into the source of the tool itself and figured out a way to perform actual queries.

The last couple of months I have been playing around with elasticsearch, an open source, distributed, RESTful search engine built on top of Apache Lucene. To interact with elasticsearch in PHP I have been using a client called Elastica. This was all fun and games until I needed to do actual queries, which is what our users will be doing most of the time. Elastica’s documentation does not (yet) say anything about how to search using the client, so I needed to dig through the code to see if I could find some solutions.

He includes a sample mapping structure and shows how to take both a simple, single-term query and turn it into a request and how to make a more complex request with filters, facets, sorting and a few other things thrown in. He also shows how you can manually create a query (define the JSON structure yourself) and push that into the "query builder" for handling.

tagged: elastica elasticsearch query tutorial