1. Go to this page and download the library: Download x-wp/di 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/ */
x-wp / di example snippets
use XWP\DI\Decorators\Module;
#[Module(
container: 'my-plugin', // Unique identifier for the container
hook: 'plugins_loaded', // Hook to initialize the a
priority: 10, // Hook priority
imports: array(), // List of classnames imported by this module
handlers: array(), // List of classnames which are used as handlers
)]
class My_Plugin {
/**
* Returns the PHP-DI container definition.
*
* @see https://php-di.org/doc/php-definitions.html
*
* @return array<string,mixed>
*/
public static function configure(): array {
return array(
'my.def' => \DI\value('my value'),
);
}
}