Create Your Own PHP Extensions

Introduction to Extensions

Extensions are pre-compiled codes or libraries which enable specific functions to be used in your PHP code. These extensions may be either a PHP extension or a Zend  extension.We can see extensions in php.ini file.

; syntax:

; extension=modulename.extension

; For example, on Windows:

; extension=msql.dll

; under UNIX:


Why we need to create Extensions

  • To create our own efficient and high performance PHP code which adds  missing features to the language.
  • When there are  limitations in PHP where we cannot make call to some library or OS specific calls.
  • When we have our own set of intelligent business logic which we want to sell and execute but do not want this to be viewed by others.
  • When we want to make PHP software to behave in a superior manner

How to create an Extension

The following system requirements need to be present to  create your own PHP extensions:

  • Text editor
  • PHP
  • Source code file and
  • C compiler.

Required files:

config. m4: The first required file to store the basic configuration data used by PHP to compile your custom extension.


[Whether to enable the “my_code” extension],

[-enable-my_code  Enable “my_code” extension support])

if test $PHP_my_code != “no”; then // 1st argument declares the module

PHP_SUBST(my_code_SHARED_LIBADD) // 2nd tells what all files to compile

PHP_NEW_EXTENSION(my_code,my_code.c,$ext_shared)  // $ext_shared is counterpart of PHP_SUBST()


In this case my_code.c is source code file and its content is :


#include “config.h”


#include “php.h”

#define PHP_MY_CODE_VERSION “1.0”

#define PHP_MY_CODE_EXTNAME “my_code”

extern zend_module_entry my_code_module_entry;

#define phpext_my_code_ptr &my_code_module_entry

// declaration of a custom my_code_function()


// list of custom PHP functions provided by this extension

// set {NULL, NULL, NULL} as the last record to mark the end of list

static function_entry my_code_functions[] = {

PHP_FE(my_code_function, NULL)



// the following code creates an entry for the module and registers it with Zend.

zend_module_entry my_code_module_entry = {

#if ZEND_MODULE_API_NO >= 20010901





NULL, // name of the MINIT function or NULL if not applicable

NULL, // name of the MSHUTDOWN function or NULL if not applicable

NULL, // name of the RINIT function or NULL if not applicable

NULL, // name of the RSHUTDOWN function or NULL if not applicable

NULL, // name of the MINFO function or NULL if not applicable

#if ZEND

Add to php.ini file

The last thing you need to do is to add the following line to your php.ini to load your extension on PHP startup:

Testing the Extension

You can test your PHP extension by typing the following command:

  1. $ php -r “echo my_code_function();”

The Why, What, and, How of Fleet Management Solutions


‘Fleet’ is a group of motor vehicles operating together under the same ownership or leased by a business, government agency or other organization. A group of motor vehicles can mean any mode of transportation such as ships, buses, warships, but which are operating together or under the same ownership.

Understand Fleet Management Solutions (FMS)

FMS are designed to augment operational efficiency and business productivity. They aim to optimize the usage of shared resources by automating business processes.  These solutions are also proven to reduce costs, save lives, improve competitive positioning, maximize fleet utilization and increase customer satisfaction.

FMS help to analyze driving behavior to reduce idling time and enforce safety driving. You can also plan efficient route and time schedules to maximize fleet utilization.

There are several companies which manufacture vehicle tracking devices. A sample list of such companies are Calamp, Positionlogic, Assettrackr, Trackyourtruck, Imarda and Pragativts among others.

A Few Sample Devices

Devices come in several models and each model will have a unique and advance feature. These devices provide data based on the configurable time intervals. Data may be all or combinations of some parameters based on the device model. The communication method may be GPRS, SMS or GSM. This data can be collected on the Cloud server, parsed and stored in a database. This data can then be represented online in formats such as a map, graph, report etc. Real-time vehicle position can also be seen in maps.

Device Features
  • Programming/updating over air
  • Sleep mode for GPRS cost/power saving
  • Wide range power supply (6-37 Volt)
  • Alarm inputs
  • Panic input/automatic emergency dial-out
  • Speeding report
  • Analog input for temperature/ fuel/air pressure monitoring
  • Driver ID checking
  • Hands-free voice communication
  • Back-up battery (4-8 hrs)
  • Door release output
  • Bluetooth for GPS data output (navigation)
  • 6-pin Connector methods
  • Water Proof device
  • Automotive use
  • Internal Backup battery
  • Battery voltage
  • Internal battery voltage
  • Battery status
  • LED indicators
  • Analog input for fuel
  • Ignition
  • Immobilizer
  • In-Built distance calculation
  • Odometer pulse-counter sensor
  • Main power disconnect alert
  • In-built GPS/GSM antenna
  • GPS receiver
  • Over-the-air device configuration through SMS
  • Secondary server option in case of failure
  • Harsh braking, accident alert
  • GSM details
  • Power saving mode
  • Power supply
  • SMS-based location
  • Internal memory
  • Geo fence settings
  • Voice monitoring
  • Location-based service
  • Two-way communication
  • Cut-Off engine
  • Shock alert

General advantages of FMS

  • Live Tracking: Displays the location of the tracked assets on a map in real time. Example: Bus # 340 is currently running (active) @ location State Hwy with speed of 58 miles per hour heading towards east.
  • Replay / History: Displays the path taken by a vehicle with historical vehicle activity, status, speed and alerts.
  • Alert/Notification: Real-time with configurable rules-based alerts sent to your screen, email or phone.
  • Geo Location: Ability to create complex shapes around different areas and record entry and exit activity, and time spent inside.
  • Service Management: Flexibility to plan, schedule and record vehicle maintenance costs and history.
  • Incident Manager: Exact information on what happened in the event of an incident with a black-box solution.
Example: Bus No.340

Each point shows driving speed and the time the vehicle arrives.

Blue icons are defined major landmarks such as schools, depot, service station where the bus stops, at planned time.

Red icons are defined stops.

White icons indicate where bus was idle for 7 min.


Industry-based Advantages of FMS


Reducing cost and maximizing fleet utilization are the keys for logistics industries. It helps you to analyze driving behavior to reduce idling time and enforce safety driving. It also helps you to view location and work status in real time and plan efficient route and time schedules to maximize fleet utilization.


  •  See the historical route of each vehicle in the fleet. One can compare actual driver activity with driver time-cards or logs. By using the ‘Drive Time Summary’ report it is possible to see daily and weekly fleet statistics, information such as total mileage, maximum recorded speed, number of stops, and distance traveled.
  • Get detailed information on each vehicle, including miles traveled, engine hours, number of trips, and more. Analyze individual vehicle utilization and identify overall fleet efficiency.
  • Use fuel usage and mileage reports to see fuel consumption patterns and identify areas for improvement. Fuel Guard transaction reports shows you fuel transaction details, including location, time, number of gallons and total cost.
  • Alert about problems requiring action and log activities.
  • Make continuous improvements. No more excel reports.
  • Find problems with graphical reports with hints for improvement.
  • Employee attendance can be captured with the RFID reader.Provide high security and safety for employees by tracking your fleet and monitoring driving behavior.
Example: Bus No. 340
  • Route analysis for a day, ie. actual v/s planned.
  • Blue line planned route for bus.
  • Red line is actual bus run for that day


  • Providing convenient bus solutions for parents.
  • Providing exactly ETA – Expedited Time of Arrival.
  • Dramatically reduces the workload of school bus administrators.
  • Attendance can be captured with the RFID / Keypad reader.
  • Real time tracking and tracing of position on Google MAP