Create WordPress Theme with Bazooka

Installation

Use the package manager composer to install BZK Core.

composer require fantassin/core

Usage in WordPress theme

If you want to create a theme you can easily start in you functions.php :

use Fantassin\Core\WordPress\Theme\ThemeKernel;

require_once __DIR__ . '/vendor/autoload.php';

class YourTheme extends ThemeKernel
{

	public function getTextDomain(): string
	{
		return 'your-theme-name';
	}
}

$theme = new YourTheme( wp_get_environment_type(), WP_DEBUG );
$theme->load();

Autoload services

To auto-register services you can add into root folder of your plugin or theme config/services.php file with this configuration :

<?php

use FantassinCoreWordPressVendor\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;

return function (ContainerConfigurator $configurator) {
	$services = $configurator->services()
		->defaults()
		->autowire()       // Automatically injects dependencies in your services.
		->autoconfigure(); // Automatically registers your services as commands, event subscribers, etc.

	// Makes classes in your-folder/ available to be used as services.
	// This creates a service per class whose id is the fully-qualified class name.
	$services->load('YourNamespace\\', '../your-folder/*')
		->exclude('../your-folder/{Entity,Tests,OrOtherFolderToNotRegister}');
};