silex

How to generate translation file (.po, .xliff, .yml,…) from a Symfony2/Silex project?

这一生的挚爱 提交于 2019-12-03 07:55:33
Im going to build a Silex/Symfony2 project and I have been looking around for a method to generate XLIFF/PO/YAML translation files based on texts-to-be-translated inside the project but not found any instruction or documentation on it. My question is: Is there an automated way to generate translation file(s) in specific format for a Symfony2/Silex project? If yes, please tell me how to generate the file then update the translation after that. If no, please tell me how to create translation file(s) then adding up more text for my project? I am looking for an editor desktop based or web-based

Silex SwiftMailer Not Making SMTP Connection Upon Execution

旧时模样 提交于 2019-12-03 05:21:28
问题 I am making a console application which uses the SwiftMail extension to send. Due to our policy, I have two virtual machines, one which serves as a SMTP relay and the other which is the application server. Sending mail manually through telnet to the relay works fine. When using SwiftMail, it's broken. The headers are returned and there are no entries returned in the $failure variable for send() Response of getHeaders()->toString() Message-ID: <1351104631.508838778dc03@swift.generated> Date:

How to Implement Resumable Download in Silex

狂风中的少年 提交于 2019-12-03 04:41:09
In silex I can do this to force-download a file: use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\ResponseHeaderBag; $app = new Silex\Application(); // Url can be http://pathtomysilexapp.com/download $app->get('/download', function (Request $request) use ($app) { $file = '/path/to/download.zip'; if( !file_exists($file) ){ return new Response('File not found.', 404); } return $app->sendFile($file)->setContentDisposition(ResponseHeaderBag::DISPOSITION_ATTACHMENT, 'download.zip'); }); $app->run(); This works well for

How to use a YAML config file in Silex Framework

▼魔方 西西 提交于 2019-12-03 04:22:40
问题 Is it possible to configure a Silex Application with YAML config files? I bet yes, but how is it done correctly? For instance I want to use different configurations according to the environment, like config.dev.yml and config.prod.yml. The config file should contain parameters for the app itself and for the registered extensions/services. Example: // Debug flag should be set in the config file $app['debug'] = true; // Extension options should also be set in config file $app->register(new

How to debug php fatal errors in Silex Framework

我怕爱的太早我们不能终老 提交于 2019-12-03 03:12:47
I wonder how can I see syntax errors like this (missing semicolon): <?php var_dump($app) ?> This will cause a WSOD (white screen of death). I tried to include a debug config file which look like this: use Symfony\Component\Debug\ErrorHandler; use Symfony\Component\Debug\Debug; // Include the prod configuration require __DIR__.'/prod.php'; // Enable PHP Error level error_reporting(E_ALL); ini_set('display_errors','On'); // Enable debug mode $app['debug'] = true; // Handle fatal errors ErrorHandler::register(); Debug::enable(); I included in composer json file: "symfony/debug": "~2.3", But still

Silex SwiftMailer Not Making SMTP Connection Upon Execution

北慕城南 提交于 2019-12-02 17:44:55
I am making a console application which uses the SwiftMail extension to send. Due to our policy, I have two virtual machines, one which serves as a SMTP relay and the other which is the application server. Sending mail manually through telnet to the relay works fine. When using SwiftMail, it's broken. The headers are returned and there are no entries returned in the $failure variable for send() Response of getHeaders()->toString() Message-ID: <1351104631.508838778dc03@swift.generated> Date: Wed, 24 Oct 2012 14:50:31 -0400 Subject: [YourSite] Feedback From: noreply@localhost.com To:

How to use a YAML config file in Silex Framework

不羁岁月 提交于 2019-12-02 17:37:54
Is it possible to configure a Silex Application with YAML config files? I bet yes, but how is it done correctly? For instance I want to use different configurations according to the environment, like config.dev.yml and config.prod.yml. The config file should contain parameters for the app itself and for the registered extensions/services. Example: // Debug flag should be set in the config file $app['debug'] = true; // Extension options should also be set in config file $app->register(new Silex\Extension\TwigExtension(), array( 'twig.path' => __DIR__.'/views', 'twig.class_path' => __DIR__.'

Silex/Symfony Security Firewall Access user token outside the secured area

十年热恋 提交于 2019-12-02 10:10:10
I use Silex and the SecurityProvider, my firewall : $app->register(new Silex\Provider\SecurityServiceProvider(), array( 'security.firewalls' => array( 'user' => array( 'pattern' => '^/user/', 'form' => array( 'login_path' => '/connexion', 'check_path' => '/user/login_check', 'default_target_path' => 'homepage_user' ), 'logout' => array('logout_path' => '/user/deconnexion') ... ) ) )); It works ! But I didn't find any way to access to the user object in the template, the symfony synthax doesn't work : {{ app.user }} So I add a new global in Twig like this : $app['twig'] = $app->share($app-

How can I catch errors and exceptions in Symfony2/Silex?

假如想象 提交于 2019-12-02 05:20:20
问题 I'd like to catch both errors and exceptions in my Silex app to wrap them in a custom JSON response that will always be returned to clients. I've found three basic methods: $app->error() Symfony\Component\Debug\ErrorHandler::register(); Symfony\Component\Debug\ExceptionHandler::register(); While I'm able to catch controller exceptions using error() I'm failing with php errors- they always end up in xdebug. I'm also failing to understand how error() and ExceptionHandler::register() interact

Silex 2 : Security firewall error with locale (Silex SecurityServiceProvider + Pmaxs\LocaleServiceProvider)

前提是你 提交于 2019-12-02 00:42:15
问题 I saw this solution but I can't make it works... So here is my code, what I tried and what I get : My code 1/ My Security Provider : $app->register(new Silex\Provider\SessionServiceProvider()); $app->register(new Silex\Provider\SecurityServiceProvider(), array( 'security.firewalls' => array( 'secured' => array( 'pattern' => '^/', 'anonymous' => true, 'logout' => true, 'form' => array( 'login_path' => '/login', 'check_path' => '/login_check'), 'users' => function () use ($app) { return new