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

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


Trending Topics: