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

Laravel News:
Building a Laravel Translation Package – The Database Driver
Dec 18, 2018 @ 16:54:52

On the Laravel News site they've posted the latest tutorial in their series covering the creation of a translation package. In this latest article they cover the creation of the database driver to replace the previous file-driven content handling.

In the previous article of the series, we talked about how to handle missing translations, which brings us very close to making the package feature complete. To finish up the build phase of this series, we will discuss how we go about adding a database driver.

Thanks to defining the interface for the data handling previously, redefining the handler for the database is simpler. He includes the code for:

  • the migrations to create the languages and translations tables
  • the models for both tables and their relations to each other
  • creation of the database driver using the interface

His code includes methods for getting either single or multiple translations including fetching them by language. He then updates the "resolve" method to allow defining the driver to use in the configuration rather than being hard-coded.

tagged: database driver translation package tutorial series

Link: https://laravel-news.com/building-database-driver

Derick Rethans:
Using the Right Debugging Tools
Oct 10, 2018 @ 14:47:42

Derick Rethans has a new post with his own suggestion about using the right debugging tools to help track down a problem (based on some of his own experience debugging the MongoDB PHP extension).

A while ago, we updated the MongoDB PHP driver's embedded C library to a new version. The C library handles most of the connection management and other low level tasks that the PHP driver needs to successfully talk to MongoDB deployments, especially in replicated environments where servers might disappear for maintenance or hardware failures.

After upgrading a related library, he ended up with a failing test related to Atlas connectivity. He walks through the process he took to try and debug the issue using GDB to see where the execution was failing using various techniques. This included looking through the backtrace and, not noticing anything out of the ordinary, going for a walk. Upon returning he noticed an odd line in the backtrace that, after some additional tracking using a GDB helper, showed the problem to be with how the query options are defined and not reset in a loop.

tagged: debugging tools gdb mongodb driver backtrace execution

Link: https://derickrethans.nl/debugging-with-tools.html

Christoph Rumpel:
The BotMan WebDriver explained
Feb 14, 2018 @ 16:23:10

In this post to his site Christoph Rumpel covers a feature of the Botman chatbot library in a bit more depth: the WebDriver making interaction with the bot in a current application simpler.

The WebDriver is one of the best features about the BotMan library. Still I see a lot of people struggling with the concept and how to use it. Let's clear things up and let me show you how I already used this driver in production.

He starts off by talking about chatbots in general and how they're "more than just messengers" and can provide more real-time information to visitors to your site. In order to enhance the basic bot functionality, it needs to work with another source - in this case an API accessed via the WebDriver. He then gets into some example code showing how to use the driver to access an API and some explanation of the pieces involved.

tagged: botman chatbot webdriver driver tutorial introduction example

Link: https://christoph-rumpel.com/2018/02/the-botman-webdriver-explained

Laravel News:
Install Microsoft SQL Drivers for PHP 7 in Docker
Jan 19, 2018 @ 18:51:05

The Laravel News site has a tutorial posted showing the Microsoft SQL Server users out there how to install the drivers and use it in a Laravel application in a Docker environment.

I started a project recently that required that I connect a Microsoft SQL Server database with a the final result when everything is up and running.

tagged: docker laravel microsoft sqlserver driver php7 tutorial

Link: https://laravel-news.com/install-microsoft-sql-drivers-php-7-docker

TutsPlus.com:
How to Create Custom Drivers in CodeIgniter
Sep 11, 2017 @ 15:36:54

On the TutsPlus.com site there's a new tutorial posted showing you how to create custom drivers in a CodeIgniter application. In this case the "drivers" are what lefts the application work with external technology or services.

The best way to understand the concept of drivers is to look at how caching is implemented in the core CodeIgniter framework. The main Cache class acts as a parent class and extends the CI_Driver_Library class. On the other hand, you'll end up finding child classes for APC, Memcached, Redis and the like, implemented as pluggable adapters. The child classes extend the CI_Driver class instead of the main driver class.

[...] Creating a custom driver in the CodeIgniter application is the aim of today's article. In the course of that, we'll go through a real-world example that creates a MediaRenderer driver used to render the media from different services like YouTube, Vimeo and similar. The different services will be implemented in the form of adapter classes.

He starts by listing the files that he'll be creating along the way and where they need to be located in the application structure. He then starts in on the configuration changes required and the contents of the files. He then walks through the code for each of them briefly explaining how they work. He starts with the drivers then moves to the adapters and, finally, how to put them together to make a functional renderer for either Vimeo our Youtube videos.

tagged: tutorial codeigniter custom driver video media renderer

Link: https://code.tutsplus.com/tutorials/how-to-create-custom-drivers-in-codeigniter--cms-29339

Derick Rethans:
HHVM and MongoDB
May 31, 2017 @ 16:56:50

Derick Rethans has a post on his site with an update about the MongoDB driver for HHVM - mostly that, because of feedback he received, it will no longer be maintained.

At the start of 2015 we began work on an HHVM driver for MongoDB, as part of our project to renew our PHP driver. Back then, HHVM was in its ascendancy and outperforming PHP 5.6 two to one. With such a huge performance difference it was reasonable to assume that many users would be switching over.

[...] With PHP 7 released, we saw very little use of the HHVM driver for MongoDB. Some months ago I did a twitter poll, where very few people were indicating that they were using HHVM—and even if they were, they would likely not choose to switch to HHVM given the current climate.

He includes some of the responses in his post ranging from people saying that HHVM only "masked slow code" for them. Another mentioned that, while Hack has some nice features, PHP moves on and integrates some of these ideas anyway. As a result of this disinclination towards HHVM on new development and the low adoption of the HHVM MongoDB extension, it will no longer be maintained. If you're a user and are interested in keeping development going, contact Derick for more information.

tagged: hhvm mongodb driver support discontinued

Link: https://derickrethans.nl/mongodb-hhvm.html

DotDev.co:
Creating a custom queue driver for Laravel
Feb 10, 2017 @ 01:21:04

On the DotDev.co blog there's a new post showing you how to create a custom queue driver for Laravel allowing you to define the logic and handling for background job processing with the framework.

Ever needed to use a queue service not supported by Laravel? No, me neither! However, recently I needed to tweak the config for the SQS driver in order to utilise a couple of the Amazon configuration settings. Unfortunately, these settings are not natively exposed by Laravel, so I decided to build my own driver. Here’s how it went.

The tutorial walks you through the creation of the queue class that extends the "Queue" interface already built into Laravel (and what methods it requires). It then mentions the custom connector class it'll require and the service provider to link it all together. There's also a section covering the configuration you'll need to define the queue properties and what changes you'll need to make.

tagged: tutorial custom queue driver laravel interface configuration serviceprovider

Link: https://dotdev.co/creating-a-custom-queue-driver-for-laravel-3ec6463fa881#.grumknpj8

Derick Rethans:
Natural Language Sorting with MongoDB 3.4
Dec 16, 2016 @ 15:28:33

Derick Rethans (of MongoDB) has posted an update to his site sharing the details about an improvement that comes with MongoDB 3.4 and is supported by the PHP driver: natural language sorting.

Arranging English words in order is simple—most of the time. You simply arrange them in alphabetical order. Sorting a set of German words, or French words with all of their accents, or Chinese with their different characters is a lot harder than it looks.

[...] Years ago I wrote about collation and MongoDB. There is an old issue in MongoDB's JIRA tracker, SERVER-1920, to implement collation so that sorting and indexing could work depending on the different sorting orders as described for each language (locale). Support for these collations have finally landed in MongoDB 3.4 and in this article we are going to have a look at how they work.

He starts off by explaining a bit about how Unicode collation works and PHP's support through the intl extension in the Collator class. He provides a code example using the class, showing the difference in sorting them first as English words then as Norwegian words. He moves into the MongoDB world and shows how the queries using this new collation support would be structured before moving back to PHP and using the MongoDB client to make the same requests. He also includes examples showing how to set the default locale, the "strength" (for the level of comparison), sorting and some interesting quirks with certain locales.

tagged: mongodb derickrethans natural language sorting tutorial driver

Link: https://derickrethans.nl/mongodb-collation-revised.html

Derick Rethans:
Not Finding the Symbols
Dec 01, 2016 @ 15:58:22

In this new post to his site Derick Rethans about an issue that was discovered with the newer version of the PHP MongoDB driver dealing a JSON encoding/decoding error.

Yesterday we released the new version of the MongoDB Driver for PHP, to coincide with the release of MongoDB 3.4. Not long after that, we received an issue through GitHub titled "Undefined Symbol php_json_serializable_ce in Unknown on Line 0".

The driver makes use of the JSON extension's "JsonSerializable" interface to handle some of the BSON types (like binary data). They were surprised that, despite running their tests on a wide range of builds they never came up with this same issue, compiling them from source. The key here is that the JSON extension is bundled along with the binary when compiled this way however some linux distributions do things differently. They ship it as a separate module and, because this could potentially be missing, a JSON error like the one reported could occur. He goes on to talk about some specific examples from various distributions and the simple fix - ensure the JSON extension is loaded before the MongoDB driver is loaded in your installation. This prevents the JSON handling from being missing and the JSON-related error message from popping up.

tagged: mongodb driver undefined symbol error message extension troubleshoot

Link: https://derickrethans.nl/undefined-symbol.html

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/


Trending Topics: