PHP code example of proklung / wp-core-symfony

1. Go to this page and download the library: Download proklung/wp-core-symfony 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/ */

    

proklung / wp-core-symfony example snippets


use Prokl\ServiceProvider\LoadEnvironment;

/** Загрузить окружение. Параметр конструктора - путь к .env файлам */
$environment = new LoadEnvironment($_SERVER['DOCUMENT_ROOT']);
$environment->load();

$environment->process();

use Prokl\ServiceProvider\ServiceProvider;

$serviceProvider = new ServiceProvider(
    'app/symfony/services.yaml',
    $_ENV['APP_ENV'],
    (bool)$_ENV['APP_DEBUG'],
    '/config/bundles.php'
);

use Prokl\ServiceProvider\Services\AppKernel;

class MyKernel extends AppKernel
{
   protected $cacheDir = '/bitrix/cache/mycache';
    
   protected $logDir = '/logs-saver';
}

class MyServiceProvider extends ServiceProvider
{
    protected $kernelServiceClass = MyKernel::class;
    
    protected $cacheDir = '/wp-content/my-cache';

}

use Symfony\Component\DependencyInjection\ContainerBuilder;
use Prokl\ServiceProvider\Micro\AbstractStandaloneServiceProvider;
use Prokl\ServiceProvider\Micro\ExampleAppKernel;

class ExampleMicroServiceProvider extends AbstractStandaloneServiceProvider
{
    /**
     * @var ContainerBuilder $containerBuilder Контейнер.
     */
    protected static $containerBuilder;

    /**
     * @var string $pathBundlesConfig Путь к конфигурации бандлов.
     */
    protected $pathBundlesConfig = '/src/Micro/example.config/standalone_bundles.php';

    /**
     * @var string $configDir Папка, где лежат конфиги.
     */
    protected $configDir = '/src/Micro/example.config/example.config/example.yaml';
    
     /**
     * @var string $kernelServiceClass Класс, реализующий сервис kernel.
     * Нужен для того, чтобы экземпляры контейнеров в kernel сервисе не перемешивались.
     */
    protected $kernelServiceClass = ExampleAppKernel::class;

}

/**
 * Class ExampleAppKernel
 * @package Prokl\ServiceProvider\Micro
 */
use Prokl\ServiceProvider\Micro\AbstractKernel;

class ExampleAppKernel extends AbstractKernel
{
    protected static $kernelContainer;
}

$micro = new ExampleMicroServiceProvider(
    'src/SymfonyDI/Micro/example.config/example.yaml',
    $_ENV['APP_ENV'],
    (bool)$_ENV['APP_DEBUG']
);

var_dump(container($micro)->getParameter('example'));

return [
            'labels' => [
                'name' => __('Instagram'),
                'singular_name' => __('Instagram'),
            ],

            'public' => true,
            'publicly_queryable' => true,
            'show_ui' => true,
            'show_in_menu' => true,
            'query_var' => true,
            'rewrite' => 'instagram',
            'capability_type' => 'post',
            'has_archive' => 'instagram',
            'hierarchical' => false,
            'menu_position' => null,
            'supports' => ['title', 'editor', 'author', 'thumbnail', 'excerpt', 'comments'],
        ];

$kernel = container()->get('kernel');

$moduleService = delegatedContainer()->get('my_module_id.service');