PHP code example of serlo-org / athene2-class-resolver

1. Go to this page and download the library: Download serlo-org/athene2-class-resolver library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

serlo-org / athene2-class-resolver example snippets


    'class_resolver'  => [
        'My\ClassInterface' => 'My\CrazyClass'
    ]

$classResolver = $serviceManager->get('ClassResolver\ClassResolver');
$className     = $classResolver->resolveClassName('My\ClassInterface');
$class         = $classResolver->resolve('My\ClassInterface');

echo $className; // prints "My\CrazyClass"
echo get_class($class); // prints "My\CrazyClass"

$classResolver = $serviceManager->get('ClassResolver\ClassResolver');
$class         = $classResolver->resolve('My\ClassInterface', true);

echo get_class($class); // prints "My\CrazyClass"