Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

IamManchanda's avatar

Getting Issue on Your First DI Container EPISODE 22 The PHP Practitioner

App.php

<?php

class App {
    protected static $registry = [];

    public static function bind($key, $value) {
        static::$registry[$key] = $value;
    }

    public static function get($key) {
        if (! array_key_exists($key, static::$registery)) {
            throw new Exception("No {$key} is bound in the container");
        }
        return static::$registery[$key];
    }
}

Bootstrap.php

<?php 

App::bind('config', require 'config.php');

dd(App::get('config'));

App::bind(
    'database', new QueryBuilder(
        Connection::make(App::get('config')['database'])
    )
);

Error:

PHP Fatal error:  Uncaught Error: Access to undeclared static property: App::$registery in /opt/lampp/htdocs/laracasts/php-mysql/core/App.php:11
Stack trace:
#0 /opt/lampp/htdocs/laracasts/php-mysql/core/bootstrap.php(5): App::get('config')
#1 /opt/lampp/htdocs/laracasts/php-mysql/index.php(6): require('/opt/lampp/htdo...')
#2 {main}
  thrown in /opt/lampp/htdocs/laracasts/php-mysql/core/App.php on line 11
0 likes
1 reply
Defrag's avatar
Defrag
Best Answer
Level 18

It looks like a minor typo. The bind method uses static::$registry but the get method is using static::$registery. That should at least fix the error you're getting.

1 like

Please or to participate in this conversation.