silex

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

让人想犯罪 __ 提交于 2019-12-31 05:48:07
问题 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

silex and twig localization

孤街醉人 提交于 2019-12-25 13:16:11
问题 I'm trying to implement translation in my web application with silex framework. So, i've come up with this <?php require_once __DIR__.'/../vendor/autoload.php'; $app = new Silex\Application(); $app['debug'] = true; $app->register(new Silex\Provider\UrlGeneratorServiceProvider()); $app->register(new Silex\Provider\TwigServiceProvider(), array( 'twig.path' => __DIR__.'/../views', )); $app->register(new Silex\Provider\TranslationServiceProvider(array( 'locale_fallbacks' => array('hr'), ))); $app

Inject other parameters to an action when using controllers in classes pattern?

巧了我就是萌 提交于 2019-12-25 01:37:51
问题 I have a class called ApplicationDecorator , which inherits Application and adds some often used methods. At the moment each controller action contains at the beginning a line like $appDec = new ApplicationDecorator($app); Is it possible to tell Silex to pass the instance as parameter to the action like it is done for Application and Request ? So it would look like the following: public function switchAction(ApplicationDecorator $appDec, Request $request) { I am already using Controllers in

BigCommerce PHP hello world app installation error

六月ゝ 毕业季﹏ 提交于 2019-12-24 18:23:35
问题 I am trying to create a BigCommerce app and used hello world app from here >> https://github.com/bigcommerce/hello-world-app-php-silex As per its documentation, I have to write localhost URL in callback URL. I have done the same, but when I am trying to install app from my trial store, I am getting error in console and the page shows installing... . Console error is: Mixed Content: The page was loaded over HTTPS, but requested an insecure form action 'http://localhost/hello-test/auth/callback

Dokku deployed Silex can't find PdoServiceProvider

核能气质少年 提交于 2019-12-24 12:08:28
问题 I have a project done with Silex, and I was using herrera-io/silex-pdo as the PDO provider, but I faced random crashes with socket errors (I connect to the DB via socket), since that lib is abandoned, I changed to csanquer/pdo-service-provider , and it works just fine on my localhost server, but when I deploy to remote, I get the following error: PHP Fatal error: Class 'Csanquer\Silex\PdoServiceProvider\Provider\PdoServiceProvider' not found in /app/web/index.php on line 52 Here is the code

.htaccess rewrite rule with static files gives me 404, what I'm missing?

余生颓废 提交于 2019-12-24 10:56:10
问题 My project (Silex) has a front controller web/index.php and assets in web/css/* , web/img/* and so on. I've placed the following .htaccess file in the root of the public html folder: <IfModule mod_rewrite.c> Options -MultiViews RewriteEngine On RewriteBase web RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^ index.php [QSA,L] </IfModule> Every request should be rewrited to web folder ( RewriteBase web directive) and if file doesn't exist ( !-f ) it should be routed to the front controller.

Redirect dynamic urls including querystring with htaccess

天涯浪子 提交于 2019-12-23 03:47:36
问题 I need to redirect some urls from an old version of a web-site to new urls. I didn't find problem with simple urls, but I can't get the urls with querystrings to work: Redirect 301 /product_detail.php?id=1 http://www.mysite.com/product/permalink It simply returns a 404, not found. I'm also tried with a route on Silex (the PHP micro-framework I'm using) but it didn't work either: $app->get('/product_detail.php?id={id}', function($id) use ($app) { $prodotto = Product::getPermalink($id); return

Mockery - call_user_func_array() expects parameter 1 to be a valid callback

自作多情 提交于 2019-12-21 06:58:29
问题 I have a class I need to mock: class MessagePublisher { /** * @param \PhpAmqpLib\Message\AMQPMessage $msg * @param string $exchange - if not provided then one passed in constructor is used * @param string $routing_key * @param bool $mandatory * @param bool $immediate * @param null $ticket */ public function publish(AMQPMessage $msg, $exchange = "", $routing_key = "", $mandatory = false, $immediate = false, $ticket = null) { if (empty($exchange)) { $exchange = $this->exchangeName; } $this-

How to handle Swift_TransportException in Silex

删除回忆录丶 提交于 2019-12-21 06:06:49
问题 I'm having quiet weird problem with catching SwiftMailer's exceptions in Silex. I want to send an email like this: try { $message = \Swift_Message::newInstance() ->setSubject('subject') ->setFrom(array('form')) ->setTo(array('to')) ->setBody('body'); $app['mailer']->send($message); } catch (\Swift_TransportException $e) { $app['logger']->addError('Unable to send welcome email'); } I know it's not going to send any email on localhost and I'm expecting it to fail but why I can't catch the Swift

Attempted to call method “share” on class “Silex\Application” in Silex 2

£可爱£侵袭症+ 提交于 2019-12-21 03:29:25
问题 I am developing a project with silex-skeleton in its most recent version. When trying to use the share method shows me the following error: Code: $app['login'] = $app->share(function() use($app) { return new Model\UserModel($app); }); Error: Attempted to call method "share" on class "Silex\Application" Any suggestions or possible cause of this failure 回答1: Silex 2.0 is using Pimple 3.0 which has removed the shared method, now all services are shared by default, if you want a new instance you