silex webprofiler不显示日志

时间:2014-05-01 18:54:52

标签: php symfony composer-php silex

我正在设置一个silex应用程序,我无法弄清楚为什么我无法从Web Profiler查看日志。它始终不显示日志。我的作曲家里有monolog-bridge,它已安装......

  

composer.json的相关部分

"minimum-stability": "dev",
    "prefer-stable": true,
    "autoload":{
        "psr-4":{
            "Yamiko\\": ["src", "test"]
        }
    },
    "require": {
        "php": ">=5.4.0",
        "silex/silex": "~1.2",
        "symfony/yaml": "v2.3.11",
        "twig/twig": ">=1.8,<2.0-dev",
        "symfony/twig-bridge": "~2.3",
        "doctrine/dbal": "2.2.*",
        "swiftmailer/swiftmailer": ">=4.1.2,<4.2-dev",
        "monolog/monolog": ">=1.0.0",
        "symfony/form": "~2.3",
        "symfony/validator": "~2.3",
        "symfony/config": "~2.3",
        "symfony/translation": "~2.3",
        "symfony/security": "~2.3",
        "kriswallsmith/assetic": "v1.1.2",
        "symfony/finder": "v2.3.11",
        "natxet/CssMin": "3.0.2",
        "silex/web-profiler": "~1.0",
        "symfony/monolog-bridge": "v2.4.2"
    }
  

的index.php

<?php
require './vendor/autoload.php';

use Yamiko\App;

$app = new App();

$app->get('/', function(){
    return 'its working!';
});

$app->run();
?>
  

我的应用程序类

<?php
namespace Yamiko;
use Silex\Application;
use Silex\Provider\TwigServiceProvider;
use Silex\Provider\UrlGeneratorServiceProvider;
use Silex\Provider\SessionServiceProvider;
use Silex\Provider\ValidatorServiceProvider;
use Silex\Provider\FormServiceProvider;
use Silex\Provider\HttpCacheServiceProvider;
use Silex\Provider\HttpFragmentServiceProvider;
use Silex\Provider\SecurityServiceProvider;
use Symfony\Component\Security\Core\Encoder\BCryptPasswordEncoder;
use Silex\Provider\RememberMeServiceProvider;
use Silex\Provider\SwiftmailerServiceProvider;
use Silex\Provider\MonologServiceProvider;
use Silex\Provider\TranslationServiceProvider;
use Symfony\Component\Translation\Loader\YamlFileLoader;
use Silex\Provider\DoctrineServiceProvider;
use Silex\Provider\ServiceControllerServiceProvider;
use Silex\Provider\WebProfilerServiceProvider;

class App extends Application{
    use Application\TwigTrait;
    use Application\SecurityTrait;
    use Application\FormTrait;
    use Application\UrlGeneratorTrait;
    use Application\SwiftmailerTrait;
    use Application\MonologTrait;
    use Application\TranslationTrait;

    public function __construct(array $values = array()) {
        parent::__construct($values);

        // monolog
        $this->register(new MonologServiceProvider(), array(
            'monolog.name' => 'yamiko',
            'monolog.level' => 100,
            'monolog.logfile' => __DIR__ . 'Yamiko/cache/yamiko.log',
        ));

        // http cache
        $this->register(new HttpCacheServiceProvider(), array(
            'http_cache.cache_dir' => __DIR__ . '/cache/http/',
        ));

        // http fragments used for ESI and hincludes
        $this->register(new HttpFragmentServiceProvider());

        // UrlGeneratorServiceProvider
        $this->register(new UrlGeneratorServiceProvider());

        // service controller
        $this->register(new ServiceControllerServiceProvider());

        // TranslationServiceProvider
        $this->register(new TranslationServiceProvider(), array(
            'locale_fallbacks' => array('en'),
        ));
        $this['translator'] = $this->share($this->extend('translator', function($translator, $this) {
            $translator->addLoader('yaml', new YamlFileLoader());
            $translator->addResource('yaml', 'Yamiko/locales/en.yml', 'en');
            $translator->addResource('yaml', 'Yamiko/locales/es.yml', 'es');
            $translator->addResource('yaml', 'Yamiko/locales/fr.yml', 'fr');
            return $translator;
        }));

        // FormServiceProvider
        $this->register(new FormServiceProvider());

        // validator
        $this->register(new ValidatorServiceProvider());

        // SecurityServiceProvider
        $this->register(new SecurityServiceProvider());
        $this->register(new RememberMeServiceProvider());
        // @TODO configure remember me provider
        $this['security.firewalls'] = array(
            'admin' => array(
                'pattern' => '^/admin',
                'http' => true,
                'users' => array(
                    // raw password is foo
                    'admin' => array('ROLE_ADMIN', '5FZ2Z8QIkA7UTZ4BYkoC+GsReLf569mSKDsfods6LYQ8t+a8EW9oaircfMpmaLbPBh4FOBiiFyLfuZmTSUwzZg=='),
                ),
            ),
        );
        $this['security.encoder.digest'] = $this->share(function ($this) {
            // use the sha1 algorithm
            // don't base64 encode the password
            // use only 1 iteration
//            return new MessageDigestPasswordEncoder('sha1', false, 1);
            return new BCryptPasswordEncoder(10);
        });

        // twig
        $this->register(new TwigServiceProvider(), array(
            'twig.path' => 'Yamiko/views',
            'twig.options' => array(
                'debug' => $this['debug'],
                'cache' => 'Yamiko/cache/views/',
                'optimizations' => -1,
                'strict_variables' => true,
                'autoescape' => true,
                'charset' => 'utf-8',
                'auto_reload' => $this['debug']
            )
        ));
        $this['twig'] = $this->share($this->extend('twig', function($twig, $app) {
//            $twig->addGlobal('pi', 3.14);
//            $twig->addFilter('levenshtein', new \Twig_Filter_Function('levenshtein'));
            return $twig;
        }));

        // sessions
//        $this['cookie_lifetime'] = 0;// can be used to set an explicit cookie lifetime.
        $this->register(new SessionServiceProvider());

        // swift mailer
        $this->register(new SwiftmailerServiceProvider());
        $this['swiftmailer.options'] = array(
            'host' => 'localhost',
            'port' => '25',
            'username' => '',
            'password' => '',
            'encryption' => null,
            'auth_mode' => null
        );

        // profiler
        $this->register($p = new WebProfilerServiceProvider(), array(
            'profiler.cache_dir' => __DIR__ . 'Yamiko/cache/profiler',
            'profiler.mount_prefix' => '/_profiler', // this is the default
        ));
        $this->mount('/_profiler', $p);
    }
}

1 个答案:

答案 0 :(得分:0)

这是由一个错误引起的。不再是问题。 https://github.com/silexphp/Silex-WebProfiler/pull/38