Example #1
0
 public function boot()
 {
     parent::boot();
     if (!$this->container->getParameter('bzion.miscellaneous.development')) {
         if ($this->getEnvironment() != 'prod' || $this->isDebug()) {
             throw new ForbiddenDeveloperAccessException('You are not allowed to access this page in a non-production ' . 'environment. Please change the "development" configuration ' . 'value and clear the cache before proceeding.');
         }
     }
     if (in_array($this->getEnvironment(), array('profile', 'dev'), true)) {
         Debug::enable();
     }
     Service::setGenerator($this->container->get('router')->getGenerator());
     Service::setEnvironment($this->getEnvironment());
     Service::setModelCache(new ModelCache());
     Service::setContainer($this->container);
     $this->setUpTwig();
     // Ratchet doesn't support PHP's native session storage, so use our own
     // if we need it
     if (Service::getParameter('bzion.features.websocket.enabled') && $this->getEnvironment() !== 'test') {
         $storage = new NativeSessionStorage(array(), new DatabaseSessionHandler());
         $session = new Session($storage);
         Service::getContainer()->set('session', $session);
     }
     Notification::initializeAdapters();
 }
Example #2
0
 public function __construct($environment = 'prod', $debug = false)
 {
     // dev, prod or schell
     define('Ki_ENVIRONMENT', $environment);
     define('Ki_DEBUG', is_bool($debug) ? $debug : false);
     if (Ki_DEBUG) {
         Debug::enable();
     } else {
         ini_set('display_errors', 0);
     }
     if (!in_array(Ki_ENVIRONMENT, array('dev', 'prod', 'shell'))) {
         throw new \Exception("El entorno '" . Ki_ENVIRONMENT . "' no está permitido en el sistema.");
     }
     // Agrega la instancia del kernel al contenedor de servicios.
     // Util para ser usada cuando de desde realizar una sub peticion dende en controlador.
     Service::instance('kernel', $this);
     // Registra la bolsa temporal en la session
     $session = Service::get('session');
     $session->registerBag(Service::get('temporary_bag'));
     $session->start();
     // Carga la configuracion del proyecto
     Service::get('config')->loadConfigGlobal();
     // Carga la configuracion de los bundles
     $this->registerBundles();
     // Carga la clase translator
     Service::get('translator')->loader(Service::get('session')->getLocale());
     $this->registerProviders();
     $this->registerListeners();
     if (Ki_ENVIRONMENT == 'shell') {
         Service::get('shell')->console();
         return;
     }
     parent::__construct(Service::get('event'), Service::get('kernel.resolver'));
 }
Example #3
0
 public function boot(Container $c)
 {
     // Confio no parametro 'debug' pois ele pode ter mudado durante
     // a fase de configuração por algum provider ou pelo proprio user
     if ($c['debug']) {
         Debug::enable($c['debug.error_level'], $c['debug.display_errors']);
     }
 }
Example #4
0
 public function __construct($apiKey, $secretKey, $debug = false)
 {
     $this->apiKey = $apiKey;
     $this->secretKey = $secretKey;
     if ($debug && class_exists('\\Symfony\\Component\\Debug\\Debug')) {
         \Symfony\Component\Debug\Debug::enable();
     }
 }
Example #5
0
 public function __construct($environment, $debug)
 {
     parent::__construct($environment, $debug);
     if ($debug) {
         Debug::enable();
     }
     $this->initPropel();
 }
Example #6
0
 public function __construct(array $values = array())
 {
     if ($values['debug']) {
         Debug::enable();
     }
     parent::__construct($values);
     $this->registerLogger($this);
     $this->registerTwig($this);
 }
Example #7
0
 public function __construct($environment = 'prod', $debug = false)
 {
     $this->environment = $environment;
     $this->debug = $debug;
     $this->packages = $this->registerPackages();
     if ($this->debug) {
         Debug::enable(-1, true);
     }
 }
Example #8
0
 public static function bootKernel()
 {
     $loader = (require_once __DIR__ . '/../../../../app/bootstrap.php.cache');
     Debug::enable();
     require_once __DIR__ . '/../../../../app/AppKernel.php';
     $kernel = new \AppKernel('dev', true);
     $kernel->loadClassCache();
     $kernel->boot();
     return $kernel;
 }
Example #9
0
 /**
  * Constructs Application
  *
  * @param EventDispatcherInterface $dispatcher  The Symfony event dispatcher
  * @param string                   $name        The application name
  * @param string                   $version     The version
  * @param string                   $environment The environment
  * @param bool                     $debug       Whether to enable debug mode
  */
 public function __construct(EventDispatcherInterface $dispatcher, string $name, string $version, string $environment, bool $debug)
 {
     $this->environment = $environment;
     $this->debug = $debug;
     if ($this->debug) {
         Debug::enable();
     }
     parent::__construct($name, $version);
     $this->setDispatcher($dispatcher);
     $this->getDefinition()->addOption(new InputOption('--env', '-e', InputOption::VALUE_REQUIRED, 'The environment name'));
     $this->getDefinition()->addOption(new InputOption('--no-debug', null, InputOption::VALUE_NONE, 'Switches off debug mode'));
 }
 /**
  * @Route("/ss", name="homepage")
  */
 public function indexAction(Request $request)
 {
     Debug::enable();
     echo 'dddd';
     $category = new Category();
     $category->setName('ddd');
     $category->setDescription('dd');
     //$category->setSlug('dd');
     $em = $this->getDoctrine()->getManager();
     $em->persist($category);
     echo 'ddd';
 }
 public static function setUpBeforeClass()
 {
     /* init's the silex app and create the schema */
     global $app;
     Debug::enable();
     $app = new \Silex\Application();
     require 'config/test.php';
     /* seperate config for the test db */
     require 'src/app.php';
     self::createSchema();
     $app['session.test'] = true;
 }
 public static function doAppEngineCheck()
 {
     if (Environment::onDevAppServer()) {
         // turn on error reporting and debugging
         Debug::enable(E_ERROR | E_PARSE);
         // fix Dev AppServer XML-loading bug
         Environment::fixXmlFileLoaderBug();
     }
     if (self::onAppEngine() || self::onDevAppServer()) {
         self::checkBucketName();
     }
 }
Example #13
0
 public static function runCLI($environment = 'dev', $debug = true)
 {
     set_time_limit(0);
     $input = new ArgvInput();
     $environment = $input->getParameterOption(array('--env', '-e'), $environment);
     $debug = !$input->hasParameterOption(array('--no-debug', '')) && $environment !== 'prod';
     if ($debug) {
         Debug::enable();
     }
     $kernel = new static($environment, $debug);
     $application = new Application($kernel);
     $application->run($input);
 }
Example #14
0
 /**
  * Startet das Debugging. In diesem Modus werden alle Fehler
  * ausgegeben. Der Symfony-Debugger wird aktiviert und der
  * Cache wird deaktiviert
  */
 public function start()
 {
     Logging::info('Debug: ON');
     $this->active = true;
     $_SESSION['DEBUG'] = true;
     // Error-Ausgabe einschalten
     ini_set('display_errors', 1);
     ini_set('error_reporting', E_ALL);
     // Symfony Debugging aktivieren
     \Symfony\Component\Debug\Debug::enable();
     Cache::disable();
     Profiler::setActive(true);
 }
 /**
  * Initialize the Silex Application
  *
  * Register services and routes
  * Set basic properties
  *
  * @return Synapse\Application
  */
 public function initialize()
 {
     // Create the application object
     $app = new Application();
     $this->setEnvironment($app);
     $this->registerConfig($app);
     // Handle init config
     $initConfig = $app['config']->load('init');
     if ($initConfig['debug']) {
         Debug::enable();
         $app['debug'] = true;
     }
     return $app;
 }
Example #16
0
 /**
  * Runs Symfony2 in console mode.
  *
  * @param string $kernelClass Class name for the kernel to be ran.
  */
 public static function console($kernelClass)
 {
     set_time_limit(0);
     $input = new ArgvInput();
     // decide env and debug info based on cli params
     $env = $input->getParameterOption(['--env', '-e'], getenv('SYMFONY_ENV') ?: 'dev');
     $debug = getenv('SYMFONY_DEBUG') !== '0' && !$input->hasParameterOption(['--no-debug', '']) && $env !== 'prod';
     if ($debug) {
         Debug::enable();
     }
     $kernel = new $kernelClass($env, $debug);
     $application = new Application($kernel);
     $application->run($input);
 }
Example #17
0
 /**
  * Bot constructor.
  *
  * @param array            $configuration
  * @param ContainerBuilder $containerBuilder
  */
 public function __construct(array $configuration, ContainerBuilder $containerBuilder = null)
 {
     $configuration = Processor::process($configuration);
     ini_set('memory_limit', $configuration['parameters']['memory_limit']);
     set_time_limit(0);
     $env = new SymfonyEnvironment();
     if ($env->isDebug()) {
         Debug::enable();
     }
     $kernel = new AppKernel($env->getType(), $env->isDebug());
     $kernel->setConfiguration($configuration);
     if ($containerBuilder !== null) {
         $kernel->setUserContainer($containerBuilder);
     }
     $this->kernel = $kernel;
 }
 /**
  * Registers services on the given container.
  *
  * This method should only be used to configure services and parameters.
  * It should not get services.
  *
  * @param \Pimple\Container $pimple An Container instance
  */
 public function register(\Pimple\Container $pimple)
 {
     $pimple['kernel.name'] = 'app';
     $pimple['kernel.info'] = function ($c) {
         return kernel_info($c['kernel.name']);
     };
     $pimple['kernel'] = function ($c) {
         $info = $c['kernel.info'];
         if (is_array($info['require_once'])) {
             $files = array_filter($info['require_once'], 'file_exists');
             if (!empty($files)) {
                 foreach ($files as $file) {
                     require_once $file;
                 }
             }
         }
         if ($info['arguments'][1]) {
             \Symfony\Component\Debug\Debug::enable();
         }
         if (class_exists($info['kernel class'])) {
             /* @var \Symfony\Component\HttpKernel\KernelInterface $kernel */
             if (!empty($info['arguments']) && is_array($info['arguments'])) {
                 $reflect = new ReflectionClass($info['kernel class']);
                 $kernel = $reflect->newInstanceArgs($info['arguments']);
             } else {
                 $kernel = new $info['kernel class']();
             }
             foreach ($info['calls'] as $method => $args) {
                 call_user_func_array(array($kernel, $method), $args);
             }
             return $kernel;
         } else {
             throw new \ErrorException($info['kernel class'] . ' is not found');
         }
     };
     $pimple['container'] = function ($c) {
         $c['kernel']->boot();
         return $c['kernel']->getContainer();
     };
     $pimple['router'] = function ($c) {
         return $c['container']->get('router');
     };
     $pimple['router.transformer'] = $pimple->protect(function ($path) {
         return array('path' => $path, 'page_callback' => 'kernel_callback', 'page_arguments' => array(\Symfony\Component\HttpFoundation\Request::createFromGlobals()), 'delivery_callback' => '', 'tab_parent' => '', 'tab_root' => $path, 'title' => '', 'type' => MENU_CALLBACK, 'include_file' => drupal_get_path('module', 'kernel') . '/kernel.pages.inc', 'href' => $path, 'tab_root_href' => $path, 'tab_parent_href' => '', 'access' => true, 'original_map' => arg(null, $path), 'map' => arg(null, $path));
     });
 }
Example #19
0
 /**
  * 初始化
  * @author Young <*****@*****.**>
  * @date   2016-07-08T10:24:17+0800
  * @param  [type]                   $config [description]
  */
 public function __construct($config)
 {
     parent::__construct();
     $this['config'] = function () use($config) {
         return new Config($config);
     };
     if ($this['config']['debug']) {
         if (class_exists(Debug::class)) {
             Debug::enable(E_ALL ^ E_NOTICE);
         } else {
             ini_set('display_errors', 'on');
             error_reporting(E_ALL ^ E_NOTICE);
         }
     }
     $this->regiestBase();
     $this->regiestProviders();
 }
 /**
  * Execute the code and modify the CodingExecutionResult
  *
  * @param string $rootDir Where all the files have been placed
  * @param string $entryPointFilename
  * @param CodingContext $context
  * @param CodingExecutionResult $result
  */
 public function executeCode($rootDir, $entryPointFilename, CodingContext $context, CodingExecutionResult $result)
 {
     // makes all notices/warning into exceptions, which is good!
     Debug::enable();
     $languageError = null;
     extract($context->getVariables());
     ob_start();
     try {
         require $rootDir . '/' . $entryPointFilename;
     } catch (\ErrorException $e) {
         $message = sprintf('%s in %s on line %s', $e->getMessage(), $e->getFile(), $e->getLine());
         $languageError = $message;
     }
     $contents = ob_get_contents();
     ob_end_clean();
     $result->setOutput($contents);
     $result->setLanguageError(ActivityRunner::cleanError($languageError, $rootDir));
     $result->setDeclaredVariables(get_defined_vars());
 }
 /**
  * Execute the code and modify the CodingExecutionResult
  *
  * @param string $rootDir Where all the files have been placed
  * @param string $entryPointFilename
  * @param CodingContext $context
  * @param CodingExecutionResult $result
  */
 public function executeCode($rootDir, $entryPointFilename, CodingContext $context, CodingExecutionResult $result)
 {
     Debug::enable();
     $errorHandler = TwigErrorHandler::register();
     $twig = $this->getTwigEnvironment($rootDir);
     try {
         $output = $twig->render($entryPointFilename, $context->getVariables());
         $result->setOutput($output);
     } catch (TwigException $error) {
         $result->setLanguageError($error->getMessage());
     } catch (\Twig_Error $error) {
         // not doing anything special here... but in the future, we might
         // fetch more information about line numbers, etc
         $result->setLanguageError($error->getMessage());
     } catch (\Exception $error) {
         $result->setLanguageError($error->getMessage());
     }
     $errorHandler->restore();
 }
 /**
  * AuthBridge constructor.
  * @param $symfonyRootPath
  * @param $symfonyUrl
  */
 function __construct($symfonyRootPath, $symfonyUrl, $groupManager = null)
 {
     global $wgHooks;
     $this->symfonyRootPath = $symfonyRootPath;
     $this->symfonyUrl = $symfonyUrl;
     // Set some MediaWiki Values
     // This requires a user be logged into the wiki to make changes.
     $GLOBALS['wgGroupPermissions']['*']['edit'] = false;
     // Specify who may create new accounts:
     $GLOBALS['wgGroupPermissions']['*']['createaccount'] = false;
     if (is_dir($this->symfonyRootPath)) {
         // Load Hooks
         $wgHooks['UserLoginForm'][] = array($this, 'onUserLoginForm', false);
         $wgHooks['UserLoginComplete'][] = $this;
         $wgHooks['UserLogout'][] = $this;
         $wgHooks['UserLoadFromSession'][] = array($this, 'AutoAuthenticateOverSymfony');
         $wgHooks['UserLogout'][] = array($this, 'logoutForm');
         $wgHooks['UserLoginForm'][] = array($this, 'loginForm');
         $loader = (require $this->symfonyRootPath . '/app/autoload.php');
         require_once $this->symfonyRootPath . '/var/bootstrap.php.cache';
         if (false) {
             Debug::enable();
             $kernel = new \AppKernel('dev', true);
         } else {
             $kernel = new \AppKernel('prod', false);
         }
         //Request::enableHttpMethodParameterOverride();
         $request = Request::createFromGlobals();
         $kernel->handle($request);
         $this->symfonyConatiner = $kernel->getContainer();
         if ($groupManager && $this->symfonyConatiner->has($groupManager)) {
             $groupBridge = new GroupBridge($this, $groupManager);
             $groupBridge->initGroups();
             $groupBridge->setUpGroupNamespaces();
         }
     } else {
         trigger_error("Symfony System not found! Login is not possible!", E_USER_NOTICE);
     }
 }
Example #23
0
 public function __construct($mode = null)
 {
     // Create Chrome logger bridge
     $this->initLogger();
     if (is_null($mode)) {
         $mode = 'sandbox';
     }
     //
     // Load App configs
     $values = $this->loadConfigs($mode);
     //
     // Enable debug
     if ($values['debug']) {
         Debug::enable();
         $this->logger->setMode(true);
     }
     \debug::info("Debug mode is " . var_export($values['debug'], true));
     parent::__construct($values);
     $this->registerLogger($this);
     $this->registerTwig($this);
     $this->registerBaseService(self::$mode);
 }
Example #24
0
 /**
  * Настраиваем окружение.
  */
 protected function setDefaultEnvironment()
 {
     if ($this->options['debug']) {
         Debug::enable();
     }
 }
Example #25
0
<?php

use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Debug\Debug;
// If you don't want to setup permissions the proper way, just uncomment the following PHP line
// read http://symfony.com/doc/current/book/installation.html#configuration-and-setup for more information
//umask(0000);
// This check prevents access to debug front controllers that are deployed by accident to production servers.
// Feel free to remove this, extend it, or make something more sophisticated.
//if (isset($_SERVER['HTTP_CLIENT_IP'])
//    || isset($_SERVER['HTTP_X_FORWARDED_FOR'])
//    || !(in_array(@$_SERVER['REMOTE_ADDR'], array('127.0.0.1', 'fe80::1', '::1')) || php_sapi_name() === 'cli-server')
//) {
//    header('HTTP/1.0 403 Forbidden');
//    exit('You are not allowed to access this file. Check '.basename(__FILE__).' for more information.');
//}
$loader = (require_once __DIR__ . '/../app/bootstrap.php.cache');
Debug::enable();
require_once __DIR__ . '/../app/AppKernel.php';
$kernel = new AppKernel('dev', true);
$kernel->loadClassCache();
$request = Request::createFromGlobals();
$response = $kernel->handle($request);
$response->send();
$kernel->terminate($request, $response);
Example #26
0
 /**
  * {@inheritdoc}
  */
 public function doRun(InputInterface $input, OutputInterface $output)
 {
     $output = new DrupalStyle($input, $output);
     $root = null;
     $commandName = null;
     $recursive = false;
     $config = $this->getConfig();
     $target = $input->getParameterOption(['--target'], null);
     if ($input && ($commandName = $this->getCommandName($input))) {
         $this->commandName = $commandName;
     }
     $targetConfig = [];
     if ($target && $config->loadTarget($target)) {
         $targetConfig = $config->getTarget($target);
         $root = $targetConfig['root'];
     }
     if ($targetConfig && $targetConfig['remote']) {
         $remoteResult = $this->getRemoteHelper()->executeCommand($commandName, $target, $targetConfig, $input->__toString(), $config->getUserHomeDir());
         $output->writeln($remoteResult);
         return 0;
     }
     if (!$target && $input->hasParameterOption(['--root'])) {
         $root = $input->getParameterOption(['--root']);
         $root = strpos($root, '/') === 0 ? $root : sprintf('%s/%s', getcwd(), $root);
     }
     $uri = $input->getParameterOption(['--uri', '-l']);
     /*Checking if the URI has http of not in begenning*/
     if ($uri && !preg_match('/^(http|https):\\/\\//', $uri)) {
         $uri = sprintf('http://%s', $uri);
     }
     $env = $input->getParameterOption(['--env', '-e'], getenv('DRUPAL_ENV') ?: 'prod');
     if ($env) {
         $this->env = $env;
     }
     $debug = getenv('DRUPAL_DEBUG') !== '0' && !$input->hasParameterOption(['--no-debug', '']) && $env !== 'prod';
     if ($debug) {
         Debug::enable();
     }
     $drupal = $this->getDrupalHelper();
     $this->getCommandDiscoveryHelper()->setApplicationRoot($this->getDirectoryRoot());
     if (!$root) {
         $root = getcwd();
         $recursive = true;
     }
     /* validate drupal site */
     $this->container->get('site')->isValidRoot($root, $recursive);
     if (!$drupal->isValidRoot($root, $recursive)) {
         $commands = $this->getCommandDiscoveryHelper()->getConsoleCommands();
         if ($commandName == 'list') {
             $this->errorMessage = $this->trans('application.site.errors.directory');
         }
         $this->registerCommands($commands);
     } else {
         $this->getKernelHelper()->setRequestUri($uri);
         $this->getKernelHelper()->setDebug($debug);
         $this->getKernelHelper()->setEnvironment($this->env);
         $this->prepare($drupal, $commandName);
     }
     if ($commandName && $this->has($commandName)) {
         $command = $this->get($commandName);
         $parameterOptions = $this->getDefinition()->getOptions();
         foreach ($parameterOptions as $optionName => $parameterOption) {
             $parameterOption = [sprintf('--%s', $parameterOption->getName()), sprintf('-%s', $parameterOption->getShortcut())];
             if (true === $input->hasParameterOption($parameterOption)) {
                 $option = $this->getDefinition()->getOption($optionName);
                 $command->getDefinition()->addOption($option);
             }
         }
     }
     $skipCheck = ['check', 'init'];
     if (!in_array($commandName, $skipCheck) && $config->get('application.checked') != 'true') {
         $requirementChecker = $this->getContainerHelper()->get('requirement_checker');
         $phpCheckFile = $this->getConfig()->getUserHomeDir() . '/.console/phpcheck.yml';
         if (!file_exists($phpCheckFile)) {
             $phpCheckFile = $this->getDirectoryRoot() . 'config/dist/phpcheck.yml';
         }
         $requirementChecker->validate($phpCheckFile);
         if (!$requirementChecker->isValid()) {
             $command = $this->find('check');
             return $this->doRunCommand($command, $input, $output);
         }
         if ($requirementChecker->isOverwritten()) {
             $this->getChain()->addCommand('check');
         } else {
             $this->getChain()->addCommand('settings:set', ['setting-name' => 'checked', 'setting-value' => 'true', '--quiet']);
         }
     }
     return parent::doRun($input, $output);
 }
Example #27
0
 /**
  * @param string     $env
  * @param bool|false $debug
  * @param $drupal
  * @param string     $uri
  */
 private function bootDrupal($env = 'prod', $debug = false, $drupal, $uri = '')
 {
     if ($debug) {
         Debug::enable();
     }
     $kernelHelper = $this->getKernelHelper();
     $kernelHelper->setRequestUri($uri);
     $kernelHelper->setDebug($debug);
     $kernelHelper->setEnvironment($env);
     $kernelHelper->setClassLoader($drupal->getAutoLoadClass());
     $kernelHelper->bootKernel();
 }
Example #28
0
<?php

use Symfony\Component\HttpFoundation\Request;
$env = getenv('SF_ENVIRONMENT');
$debug = $env !== 'prod';
/** @var Composer\Autoload\ClassLoader */
$loader = (require __DIR__ . '/../app/autoload.php');
if ($debug) {
    \Symfony\Component\Debug\Debug::enable();
} else {
    include_once __DIR__ . '/../var/bootstrap.php.cache';
}
$kernel = new AppKernel($env, $debug);
if (!$debug) {
    $kernel->loadClassCache();
}
$request = Request::createFromGlobals();
$response = $kernel->handle($request);
$response->send();
$kernel->terminate($request, $response);
 /**
  * @param string     $env
  * @param bool|false $debug
  * @param $drupal
  */
 private function bootDrupal($env = 'prod', $debug = false, $drupal)
 {
     if ($debug) {
         Debug::enable();
     }
     $kernelHelper = $this->getKernelHelper();
     $kernelHelper->setDebug($debug);
     $kernelHelper->setEnvironment($env);
     $kernelHelper->setClassLoader($drupal->getAutoLoadClass());
     if ($drupal->isInstalled()) {
         $kernelHelper->bootKernel();
     }
 }
Example #30
0
<?php

use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Debug\Debug;
// If you don't want to setup permissions the proper way, just uncomment the following PHP line
// read http://symfony.com/doc/current/book/installation.html#checking-symfony-application-configuration-and-setup
// for more information
//umask(0000);
// This check prevents access to debug front controllers that are deployed by accident to production servers.
// Feel free to remove this, extend it, or make something more sophisticated.
if (isset($_SERVER['HTTP_CLIENT_IP']) || isset($_SERVER['HTTP_X_FORWARDED_FOR']) || !(in_array(@$_SERVER['REMOTE_ADDR'], array('127.0.0.1', 'fe80::1', '::1')) || php_sapi_name() === 'cli-server')) {
    header('HTTP/1.0 403 Forbidden');
    exit('You are not allowed to access this file. Check ' . basename(__FILE__) . ' for more information.');
}
/**
 * @var Composer\Autoload\ClassLoader $loader
 */
$loader = (require __DIR__ . '/../app/autoload.php');
Debug::enable(E_ALL & E_STRICT & ~E_DEPRECATED);
$kernel = new AppKernel('dev', true);
$kernel->loadClassCache();
$request = Request::createFromGlobals();
$response = $kernel->handle($request);
$response->send();
$kernel->terminate($request, $response);