Using a service class will be done by a function which chooses the right service automatically by passing the service type name (not the class name):

$serviceObj = t3lib_div::makeInstanceService('my_service_type');

The difference is that the class name itself and its usage is not hardcoded. The same service can be provided by different extensions. The service with the highest priority and quality is chosen automatically.

Two reasons to use Services

1. Freedom of implementation

A service might be implemented multiple times because of different environments like operating systems (Unix, Windows), available PHP extensions or other dependencies like Perl.

An example could be a service extension depending on a Perl script which gives very good results. Another extension can implement the same service by using pure PHP. This implementation might not give as good results (because of a less good implementation) as the Perl solution but it makes the service available where Perl is not available.

2. Extend functionality with extensions

Services are able to handle service subtypes. This means, a service of the type ‘fileMeta” which extracts meta data from files, provides information for which file type the service is implemented.

This way the code don’t has to be changed for new file types. An extension can implement a fileMeta service for the file type ‘mp3’ and it will be used automatically by code that uses the fileMeta service.

ext_localconf.php

In ext_localconf.php the services will be registered to the system which looks like this: