PHP code example of proklung / bitrix-core-symfony
1. Go to this page and download the library: Download proklung/bitrix-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 / bitrix-core-symfony example snippets
use Prokl\ServiceProvider\ServiceProvider;
$serviceProvider = new ServiceProvider('local/configs/services.yaml');
class MyServiceProvider extends ServiceProvider
{
/**
* {@inheritDoc}
*/
protected function loadBitrixServiceLocatorConfigs(DelegatingLoader $loader) : void
{
}
}
use Bitrix\Main\Config\Configuration;
$this->config = Configuration::getInstance()->get('my_config') ?? [];
// Из модуля
$this->parameters = Configuration::getInstance('my.module')->get('parameters') ?? [];
$this->services = Configuration::getInstance('my.module')->get('services') ?? [];
use Local\ExampleBitrixActionController;
use Prokl\ServiceProvider\ServiceProvider;
use Bitrix\Main\Routing\Controllers\PublicPageController;
use Bitrix\Main\Routing\RoutingConfigurator;
onController::class), 'cacheAction'])
->default('country', 'Russia')
->name('first_bitrix_route')
;
$routes->get('/', new PublicPageController('/index.php')); // Старый роут на статике.
};
namespace Local;
use Bitrix\Main\Engine\Contract\RoutableAction;
use Bitrix\Main\Engine\Controller;
use Symfony\Component\HttpKernel\KernelInterface;
class ExampleBitrixActionController extends Controller implements RoutableAction
{
/**
* @var KernelInterface $kernel
*/
private $kernel;
public function __construct(KernelInterface $kernel)
{
$this->kernel = $kernel;
parent::__construct();
}
/**
* @return string|Controller
*/
public static function getControllerClass() {
return ExampleBitrixActionController::class;
}
/**
* @return string
*/
public static function getDefaultName() {
return 'testingAction';
}
public function cacheAction(string $country)
{
return ['cacheDir' => $this->kernel->getCacheDir(), 'country' => $country];
}
public function configureActions()
{
return [
'cache' => [
'prefilters' => [], 'postfilters' => [],
],
];
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.