PHP code example of justdev / jd-support

1. Go to this page and download the library: Download justdev/jd-support 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/ */

    

justdev / jd-support example snippets


// 1. Create service in src/Services/
class NewService
{
    public function __construct(Container $container)
    {
        $this->config = $container->get('config');
    }
    
    public function doSomething()
    {
        // Your logic
    }
}

// 2. Register in Container.php
$this->register('new', NewService::class);

// 3. Use in HookManager.php
$this->addAction('hook_name', [$this->container->get('new'), 'doSomething']);

// 1. Create controller in src/Admin/Controllers/
class NewController
{
    public function registerHooks()
    {
        add_action('admin_menu', [$this, 'addMenuPage']);
    }
}

// 2. Add to AdminManager.php
$this->newController = new NewController($this->container);
$this->newController->registerHooks();