use Symfony\Component\HttpKernel\Kernel; class AppKernel extends Kernel { // ... public function __construct($environment, $debug) { parent::__construct($environment, $debug); $this->loadClassCache(); // Generate class cache } // ... }
use Symfony\Component\HttpKernel\Kernel; class AppKernel extends Kernel { // ... public function registerBundles() { $bundles = [ new AppBundle(), ]; if (in_array($this->getEnvironment(), ['dev', 'test'], true)) { // Add development and testing bundles $bundles[] = new DebugBundle(); $bundles[] = new WebProfilerBundle(); $bundles[] = new SensioDistributionBundle(); $bundles[] = new SensioGeneratorBundle(); $this->loadClassCache(); // Generate class cache } return $bundles; } // ... }In this example, the `registerBundles` method is used to register bundles for the application. It also checks if the environment is development or testing and adds additional bundles for these environments. The `loadClassCache` method is called inside the conditional statement, generating a class cache only if the environment is development or testing. Package Library: `Symfony\Bundle\FrameworkBundle`