Services Container

The Apex\Svc\ namespace contains various PSR compliant and other items that can be easily pulled in via attribute / constructor injection to aide in your development. You may view the ~/boot/container.php file to see and change the specific implementations being used for each PSR compliant service (eg. PSR-3 logger, PSR-6 cache, PSR-18 HTTP client, et al).

Loading Services

Services should always be loaded via attribute or constructor injection, for example:


namespace App\Demo;

use Apex\Svc\{Db, Cache, View};
use App\Demo\Models\Product;

 * Demo class
class MyDemoClass

    private Db $db;

    private Cache $cache;

    private View $view;

     * Do something
    public function doSomething():void

        $value = $this->db->getField("SELECT something from some_table WHERE id = 5");

        $this->view->assign('some_var', $value);


Available Services

The following services are available within the Apex\Svc namespace:

Service Description
App The central Apex App class, and is also a PSR15 compliant RequestHandlerInterface object.
Cache PSR-16 compliant simple cache. Defaults to symfony/cache with installation.
Container PSR-11 compliant dependency injection container.
Convert Conversion utility to format dates, amounts, and more for display to the end-user.
Db The SQL database connection.
Debugger Debugger. See the Debugger page for details.
Dispatcher Dispatch messages to event listeners.
Emailer Send e-mail messages.
FilesystemAA Instance of the league/flysystem package. Defaults to the ~/storage/ directory of the local macheine, but can be changed to support AWS, et al.
Firebase Client to send Firebase messages to Android / iOS devices.
HttpClient PSR-18 compliant HTTP client. Defaults to the guzzlehttp package with installation.
Logger PSR-3 compliant logger. Defaults to the monolog/monolog package with installation.
Psr6Cache PSR-6 compliant cache. Defaults to the symfony/cache package with installation.
Queue Queue any task / crontab job for later processing.
SmsClient Client to send SMS messages via Nexmo.
View Syrus template engine to parse and render views.
WsClient Client to send messages to the Web Socket server.