1. Go to this page and download the library: Download mmoreram/base-bundle 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/ */
mmoreram / base-bundle example snippets
use Symfony\Component\HttpKernel\Bundle\Bundle;
/**
* My bundle
*/
final class MyBundle extends Bundle
{
}
use Mmoreram\BaseBundle\BaseBundle;
/**
* My bundle
*/
final class MyBundle extends BaseBundle
{
/**
* Returns the bundle's container extension.
*
* @return ExtensionInterface|null The container extension
*
* @throws \LogicException
*/
public function getContainerExtension()
{
return new MyExtension($this);
}
}
use Mmoreram\BaseBundle\BaseBundle;
/**
* My bundle
*/
final class MyBundle extends BaseBundle
{
/**
* Returns the bundle's container extension.
*
* @return ExtensionInterface|null The container extension
*
* @throws \LogicException
*/
public function getContainerExtension()
{
return null;
}
}
php
/**
* Class AbstractBundle.
*/
abstract class BaseBundle extends Bundle
{
// ...
/**
* Get command instance array
*
* @return Command[]
*/
public function getCommands() : array
{
return [];
}
// ...
}
php
use Mmoreram\BaseBundle\Mapping\MappingBagProvider;
use Mmoreram\BaseBundle\SimpleBaseBundle;
use Symfony\Component\HttpKernel\KernelInterface;
/**
* Class TestSimpleBundle
*/
class TestSimpleBundle extends SimpleBaseBundle
{
/**
* get config files
*/
public function getConfigFiles() : array
{
return [
'services'
];
}
/**
* Get command instance array
*
* @return Command[]
*/
public function getCommands() : array
{
return [];
}
/**
* Return a CompilerPass instance array.
*
* @return CompilerPassInterface[]
*/
public function getCompilerPasses()
{
return [];
}
/**
* Create instance of current bundle, and return dependent bundle namespaces.
*
* @return array Bundle instances
*/
public static function getBundleDependencies(KernelInterface $kernel)
{
return [];
}
}
php
//...
/**
* Hook after pre-pending configuration.
*
* @param array $config Configuration
* @param ContainerBuilder $container Container
*/
protected function preLoad(array $config, ContainerBuilder $container)
{
// Implement here your bundle logic
}
/**
* Hook after load the full container.
*
* @param array $config Configuration
* @param ContainerBuilder $container Container
*/
protected function postLoad(array $config, ContainerBuilder $container)
{
// Implement here your bundle logic
}
//...