<commit_before><?php
/* NameSpaces */
// ToDo: Change this to your Application Wrapper
use GoRemote\Application;

use Silex\Provider\UrlGeneratorServiceProvider;
use Silex\Provider\ServiceControllerServiceProvider;
use Silex\Provider\DoctrineServiceProvider;
use SilexMemcache\MemcacheExtension;
use Silex\Provider\SessionServiceProvider;
use Symfony\Component\HttpFoundation\Session\Storage\Handler\MemcachedSessionHandler;
use Silex\Provider\MonologServiceProvider;
use Silex\Provider\WebProfilerServiceProvider;
use Symfony\Component\HttpFoundation\Request;
use Knp\Provider\ConsoleServiceProvider;
use Silex\Provider\TwigServiceProvider;


/**
 * @var Symfony\Component\HttpFoundation\Session\Session $session
 * @var Silex\Application $app
 */

$app = new Application();
$app->register(new Igorw\Silex\ConfigServiceProvider(__DIR__ . '/../config/always.php'));

$app->register(new TwigServiceProvider(), [
    'twig.path'    => [__DIR__ . '/../views'],
    'twig.options' => [
        'cache' => (getenv('APP_DEBUG') == true) ? false : '/tmp/goremote-twig-cache/'
    ],
]);


$app['twig'] = $app->share($app->extend('twig', function($twig, $app) {
    $twig->getExtension('core')->setTimezone('UTC');
    
    $function = new Twig_SimpleFunction('slugify', function($string) use($app) {
        $string = preg_replace('/[^ a-zA-Z0-9\/\-]/', '', $string);
        return str_replace(
            [' ', '_', '/'],
            ['-', '-', '-'],
            strtolower($string)
            );
    });

    $twig->addFunction($function);

    return $twig;
}));

$app->register(new MonologServiceProvider(), [
    'monolog.logfile' => $app['config.monolog.logfile'],
]);

$app['monolog.name'] = 'goremote';
$app['monolog'] = $app->share($app->extend('monolog', function($monolog) {
    $handlers = $monolog->getHandlers();
    foreach($handlers as $handler) {
        $handler->setFormatter(new \Monolog\Formatter\LineFormatter(null, 'Y-m-d H:i:s', true));
    }
    return $monolog;
}));

$app->register(new SessionServiceProvider());

$app->register(
    new ConsoleServiceProvider(),
    array(
        'console.name' => 'GoRemoteCli',
        'console.version' => '1.0.0',
        'console.project_directory' => __DIR__ . "/GoRemote"
    )
);

$app->register(new Silex\Provider\SwiftmailerServiceProvider());
/**
 * This registers $app['memcache'] which is a Memcached instance
 */
$app->register(
    new MemcacheExtension(),
    [
        'memcache.library'    => 'memcached',
        'memcache.server' =>
            [
                [
                    '127.0.0.1',
                    11211
                ]
            ]
    ]
);

$app['session.storage.handler'] = $app->share(function ($app) {
    return new MemcachedSessionHandler($app['memcache']);
});

$app->register(new UrlGeneratorServiceProvider());
$app->register(new ServiceControllerServiceProvider());
$app->register(new DoctrineServiceProvider());

$app["db.options"] = [
    "driver" => "pdo_mysql",
    "host"      => getenv('APP_MYSQL_HOSTNAME') ?: 'localhost',
    "dbname"    => getenv('APP_MYSQL_DATABASE') ?: 'goremote',
    "user"      => getenv('APP_MYSQL_USERNAME') ?: 'goremote',
    "password"  => getenv('<PASSWORD>')
];

$app->register(new LewisB\PheanstalkServiceProvider\PheanstalkServiceProvider(), array(
    'pheanstalk.server' => '127.0.0.1'
));

if (getenv('APP_DEBUG') == true) {
    // enable the debug mode
    $app['debug'] = true;
    if ($app['config.enableProfiler'] == true) {
        $app->register($p = new WebProfilerServiceProvider(), [
            'profiler.cache_dir' => '/tmp/cache/profiler/',
        ]);
        $app->mount('/_profiler', $p);
    }

    // Doing the config stuff seems to remove the config, so let's save and reset it.
}

return $app;<commit_msg>show 404/500 errors, not debug info<commit_after><?php
/* NameSpaces */
// ToDo: Change this to your Application Wrapper
use GoRemote\Application;

use Silex\Provider\UrlGeneratorServiceProvider;
use Silex\Provider\ServiceControllerServiceProvider;
use Silex\Provider\DoctrineServiceProvider;
use SilexMemcache\MemcacheExtension;
use Silex\Provider\SessionServiceProvider;
use Symfony\Component\HttpFoundation\Session\Storage\Handler\MemcachedSessionHandler;
use Silex\Provider\MonologServiceProvider;
use Silex\Provider\WebProfilerServiceProvider;
use Symfony\Component\HttpFoundation\Request;
use Knp\Provider\ConsoleServiceProvider;
use Silex\Provider\TwigServiceProvider;


/**
 * @var Symfony\Component\HttpFoundation\Session\Session $session
 * @var Silex\Application $app
 */

$app = new Application();
$app->register(new Igorw\Silex\ConfigServiceProvider(__DIR__ . '/../config/always.php'));

$app->register(new TwigServiceProvider(), [
    'twig.path'    => [__DIR__ . '/../views'],
    'twig.options' => [
        'cache' => (getenv('APP_DEBUG') == true) ? false : '/tmp/goremote-twig-cache/'
    ],
]);


$app['twig'] = $app->share($app->extend('twig', function($twig, $app) {
    $twig->getExtension('core')->setTimezone('UTC');
    
    $function = new Twig_SimpleFunction('slugify', function($string) use($app) {
        $string = preg_replace('/[^ a-zA-Z0-9\/\-]/', '', $string);
        return str_replace(
            [' ', '_', '/'],
            ['-', '-', '-'],
            strtolower($string)
            );
    });

    $twig->addFunction($function);

    return $twig;
}));

$app->register(new MonologServiceProvider(), [
    'monolog.logfile' => $app['config.monolog.logfile'],
]);

$app['monolog.name'] = 'goremote';
$app['monolog'] = $app->share($app->extend('monolog', function($monolog) {
    $handlers = $monolog->getHandlers();
    foreach($handlers as $handler) {
        $handler->setFormatter(new \Monolog\Formatter\LineFormatter(null, 'Y-m-d H:i:s', true));
    }
    return $monolog;
}));

$app->register(new SessionServiceProvider());

$app->register(
    new ConsoleServiceProvider(),
    array(
        'console.name' => 'GoRemoteCli',
        'console.version' => '1.0.0',
        'console.project_directory' => __DIR__ . "/GoRemote"
    )
);

$app->register(new Silex\Provider\SwiftmailerServiceProvider());
/**
 * This registers $app['memcache'] which is a Memcached instance
 */
$app->register(
    new MemcacheExtension(),
    [
        'memcache.library'    => 'memcached',
        'memcache.server' =>
            [
                [
                    '127.0.0.1',
                    11211
                ]
            ]
    ]
);

$app['session.storage.handler'] = $app->share(function ($app) {
    return new MemcachedSessionHandler($app['memcache']);
});

$app->register(new UrlGeneratorServiceProvider());
$app->register(new ServiceControllerServiceProvider());
$app->register(new DoctrineServiceProvider());

$app["db.options"] = [
    "driver" => "pdo_mysql",
    "host"      => getenv('APP_MYSQL_HOSTNAME') ?: 'localhost',
    "dbname"    => getenv('APP_MYSQL_DATABASE') ?: 'goremote',
    "user"      => getenv('APP_MYSQL_USERNAME') ?: 'goremote',
    "password"  => getenv('<PASSWORD>')
];

$app->register(new LewisB\PheanstalkServiceProvider\PheanstalkServiceProvider(), array(
    'pheanstalk.server' => '127.0.0.1'
));

if (getenv('APP_DEBUG') == true) {
    // enable the debug mode
    $app['debug'] = true;
    if ($app['config.enableProfiler'] == true) {
        $app->register($p = new WebProfilerServiceProvider(), [
            'profiler.cache_dir' => '/tmp/cache/profiler/',
        ]);
        $app->mount('/_profiler', $p);
    }
}

$app->error(function (\Exception $e, $code) {
    switch ($code) {
        case 404:
            $message = 'The requested page could not be found.';
            break;
        default:
            $message = 'We are sorry, but something went terribly, horribly, amazingly wrong.';
    }

    return new Response($message);
});

return $app;
{'fraction_non_alphanumeric': 0.17795960112503195, 'fraction_numerical': 0.0067757606750191764, 'mean_word_length': 3.343697945585786, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 84, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 4, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1006769', 'n_tokens_mistral': 2543, 'n_tokens_neox': 2506, 'n_words': 411}