silex

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

谁说胖子不能爱 提交于 2019-12-02 00:13:52
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 Myapp\DAO\UserDAO($app['db']); }, ), ), )); 2/ My Translator Provider I use : https://github.com/pmaxs

Silex : allow user to change langage by clicking on html element and keeping clean URL

こ雲淡風輕ζ 提交于 2019-12-01 21:58:22
I am using Silex and Twig for a website and I want to allow the user to change the langage of the site. My problem Right now, it works if I change the locale in the URL : /my-account : my page content is in English (default _locale) /fr/my-account : my page content is in French /en/my-account : my page content is in English How can I do the do the same by clicking on an html element? I am looking for some idea to solve my problem and some good practice to do this "the right way" if possible. My code Here is the Silex component I use to manage the multilangue : // TRANSLATION $app->register(new

Silex : allow user to change langage by clicking on html element and keeping clean URL

五迷三道 提交于 2019-12-01 20:13:34
问题 I am using Silex and Twig for a website and I want to allow the user to change the langage of the site. My problem Right now, it works if I change the locale in the URL : /my-account : my page content is in English (default _locale) /fr/my-account : my page content is in French /en/my-account : my page content is in English How can I do the do the same by clicking on an html element? I am looking for some idea to solve my problem and some good practice to do this "the right way" if possible.

Flexible dynamic routing with Silex

拜拜、爱过 提交于 2019-12-01 05:52:09
问题 Is it possible to have an unknown number of arguments for a get request? Example, this works but isn't ideal. $app->get('/print/{template}/{arg1}/{arg2}', function ($template, $arg1, $arg2) use ($app) { $str = $template . " " . $arg1 . " " . $arg2; return $str; }) ->value('template', FALSE) ->value('arg1', FALSE) ->value('arg2', FALSE); What I'd like is an array of arguments returned for anything entered after the template variable. I can't see more than 4 or 5 arguments being required, but i

Silex + Doctrine2 ORM + Dropdown (EntityType)

元气小坏坏 提交于 2019-11-30 22:35:07
I have a controller that renders a form that is suppose to have a dropdown with titles mapped against a client_user entity. Below is code I use in my controller to create the form: $builder = $this->get(form.factory); $em = $this->get('doctrine.entity_manager'); $form = $builder->createBuilder(new ClientUserType($em), new ClientUser())->getForm(); Below is my ClientUserType class with a constructor that I pass the entity manager on: <?php namespace Application\Form\Type; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Bridge\Doctrine\Form

Guzzle and HTTPS

…衆ロ難τιáo~ 提交于 2019-11-30 21:25:36
I want to use Guzzle and Silex to send request to https pages. With http url I have a response : app->get('/',function() use ($app, $client){ $response = $client->get("http://www.google.fr"); var_dump($response); }); My response: object(GuzzleHttp\Message\Response)[102] private 'reasonPhrase' => string 'OK' (length=2) private 'statusCode' => int 200 private 'effectiveUrl' => string 'http://www.google.fr' (length=20) private 'headers' (GuzzleHttp\Message\AbstractMessage) => array (size=13) 'date' => array (size=1) 0 => string 'Wed, 18 Feb 2015 10:57:37 GMT' (length=29) 'expires' => But with

理解 Composer 的稳定性(Stability)标识

浪子不回头ぞ 提交于 2019-11-30 18:03:37
目前 composer 支持包中最常见的问题就是,对如何确定包的稳定性感到比较困惑。 这个困惑的通常表现如下例: 当引入了 包 A:dev-master ,但是它依赖于 包 B:dev-master , composer 会给出 包 B 未能找到 的提示。 根扩展包 根扩展包是主要的 composer.json 档。他位于你运行 composer install 的资料夹。很多 composer.json 里的栏位是 root-only ,表示他们只会在作为根扩展包时才会有影响。 根扩展包是一个上下文。我们说你依赖于一个扩展包 A 。在你的扩展包的目录下,你的扩展包就是根扩展包。如果你 cd 进入资料夹 A ,那 A 就是根扩展包。 Stability 是根据根扩展包决定的,也只有根扩展包能这么做。让他沉浸片刻,但永远不要忘记他。 Composer 将你的依赖包要多稳定的决定权交给使用者。作为一个使用者,你可以决定你想使用开发版、测试版,或稳定发行版。 minimum-stability 这种决策是基于根扩展包中的 minimum-stability 字段。它是一个 唯根 字段。它给稳定性标识定义了一个默认值,并作为下限。 这是一个可重定义的规则。默认只展示 "stable",但是你可以改写这个规则以展示更低层的稳定性标识。 minimum-stability

Silex + Doctrine2 ORM + Dropdown (EntityType)

浪尽此生 提交于 2019-11-30 17:52:59
问题 I have a controller that renders a form that is suppose to have a dropdown with titles mapped against a client_user entity. Below is code I use in my controller to create the form: $builder = $this->get(form.factory); $em = $this->get('doctrine.entity_manager'); $form = $builder->createBuilder(new ClientUserType($em), new ClientUser())->getForm(); Below is my ClientUserType class with a constructor that I pass the entity manager on: <?php namespace Application\Form\Type; use Symfony\Component

Unexpected character in input: '\' (ASCII=92) state=1 in a Silex Application

非 Y 不嫁゛ 提交于 2019-11-30 16:42:59
问题 I moved my website from local to a hosting, and something happened to me. I include this config file into my index.php (it's the first thing I do): <?php require_once __DIR__.'/../../vendor/autoload.php'; // some other stuff $app = new Silex\Application(); $app['debug'] = true; $defaultLocale = 'en'; $app->register(new Silex\Provider\TwigServiceProvider(), array( 'twig.path' => array( __DIR__.'/../views', __DIR__.'/../views/backend', __DIR__.'/../views/layouts', __DIR__.'/../views/components'

Guzzle and HTTPS

扶醉桌前 提交于 2019-11-30 05:30:00
问题 I want to use Guzzle and Silex to send request to https pages. With http url I have a response : app->get('/',function() use ($app, $client){ $response = $client->get("http://www.google.fr"); var_dump($response); }); My response: object(GuzzleHttp\Message\Response)[102] private 'reasonPhrase' => string 'OK' (length=2) private 'statusCode' => int 200 private 'effectiveUrl' => string 'http://www.google.fr' (length=20) private 'headers' (GuzzleHttp\Message\AbstractMessage) => array (size=13)