symfony官方所有文档代码都补全了

396 查看

看看这技术行不,希望找到能一起交流smyfony的人,symfony的难度亚于java框架,非得让我写200字,只有贴出一段代码了
上海php装逼大牛群 128026186
<?php
namespace AppBundle\DependencyInjection;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
use Symfony\Component\Config\FileLocator;
class AppExtension extends Extension {
public function load(array $configs, ContainerBuilder $container) {
$configuration = new Configuration();
$config = $this->processConfiguration($configuration, $configs);
//print_r($config);die;
$container->setParameter('myowoconfig.FOO', $config['foo']);
$loader = new YamlFileLoader(
$container, new FileLocator(DIR . '/../Resources/config')
);
$loader->load('services.yml');
}
public function getAlias() {
return 'myowoconfig'; //bundel名字去掉bundle
}
}
/*

  • Impossible to call set() on a frozen ParameterBag.
    You can't modify Container once it has been compiled, which is done before invoking the controller.
    The DIC parameters are intended for configuration purposes - not a replacement for global variables.
    In addition it seems you want to persist some kind of permanent modification. In that case consider
    using session if it's a per-user modification or persisting it (e.g. into DB) if it's supposed to be application-wide.
    If you need to modify DIC parameters or services, you can do so using a compiler pass.
    More info on how to write custom compiler passes can be found at
    http://symfony.com/doc/master/cookbook/service_container/compiler_passes.html
    */