silex

Is it possible to use EventSubscribers with Silex?

狂风中的少年 提交于 2019-12-06 09:39:12
Whilst looking around at using AuthenticationHandlers I saw that Symfony supports EventSubscribers which can be more flexible when authenticating with multiple methods. I have been using this as an example: https://knpuniversity.com/screencast/guard/success-handling So I have got my subscriber class all setup, but what I do not know how to do is register is as an event in Silex. I am pretty sure that I need to use the $app['dispatcher'] but what I do not know is what event to listen on. Using the example from the page, in a Symfony configuration, the servics is tagged with kernel.event

Silex security provider

杀马特。学长 韩版系。学妹 提交于 2019-12-06 09:38:17
问题 I have a class UserMapper <?php namespace Models; use Symfony\Component\Security\Core\User\UserProviderInterface; use Symfony\Component\Security\Core\User\UserInterface; use Symfony\Component\Security\Core\Exception\UnsupportedUserException; use Symfony\Component\Security\Core\Exception\UsernameNotFoundException; use \PDO; class UserMapper implements UserProviderInterface { /** * Database connection. */ var $db = NULL; /** * Constructor function. Loads model from database if the id is known.

Symfony2 Form Collection allow_add and allow_delete null error (Silex)

…衆ロ難τιáo~ 提交于 2019-12-06 06:23:33
I've run into a problem when following the Symfony cookbook for form collections with add/remove. See: http://symfony.com/doc/current/cookbook/form/form_collections.html Now, for some reason, if I dynamically add a form row but don't fill in any of its fields , I get the following error: ContextErrorException: Catchable Fatal Error: Argument 1 passed to Project::addTask() must be an instance of Task, null given in D:\web_workspace\wedding\src\testapp.php line 82 I would like people to be able to have blank rows in the form which will just get ignored. For example, if you click "Add Task" a few

Doctrine ORM Fail (ClassMetadataFactory.php)

帅比萌擦擦* 提交于 2019-12-06 04:12:33
recently I made an update of my project with silex 2.0 and mark me the following error mapping Parse error: syntax error, unexpected '[', expecting ')' in/var/www/vhosts/server.com.mx/cmanager.server.com.mx/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php on line 80. This makes certain tables not all inclusive had to change database administrator and works perfect. Have a comment or suggestion. Thank You I'm guessing you accidentally upgraded doctrine when upgrading to silex 2.0. If you simply ran composer update instead of composer update silex/silex , you will update all

Route.php can't find controller class I created

那年仲夏 提交于 2019-12-05 19:45:35
I'm trying to build a silex application. My file structure is: ROOT/ /App/ /Controller/{IndexController.php} /Config/{dev.php,prod.php,route.php} /vendor /web/{index.php, index_dev.php} When I'm trying to see http://localhost/web/ I get error: PHP Fatal error: Class 'App\Controller\IndexController' not found in ../App/config/route.php on line 2 Here are the relevant files: index_dev.php <?php require_once __DIR__.'/../vendor/autoload.php'; require __DIR__.'/../App/config/dev.php'; $app = require __DIR__.'/../App/app.php'; $app->run(); ?> app.php <?php use Silex\Application; use Silex\Provider

PHP Silex routing localization

℡╲_俬逩灬. 提交于 2019-12-05 17:55:22
starting with Silex. Say I want a localised site where all routes have to start with /{_locale} and don't fancy repeating myself as : $app->match('/{_locale}/foo', function() use ($app) { return $app['twig']->render('foo.twig'); }) ->assert('_locale', implode('|', $app['languages.available'])) ->value('_locale', $app['locale.default']) ->bind('foo'); $app->match('/{_locale}/bar', function() use ($app) { return $app['twig']->render('bar.twig'); }) ->assert('_locale', implode('|', $app['languages.available'])) ->value('_locale', $app['locale.default']) ->bind('bar'); Ideally, I'd like to create

Silex set cookie

守給你的承諾、 提交于 2019-12-05 17:31:27
I'm using Silex Framework, and I'm desperately trying to set a cookie. There's no information to be found in the docs, and I have tried almost anything! Does someone possible have experience with this, and can provide a small example? Thanks Here's an excerpt from one of my sites that sets a cookie then serves a pdf: $dt = new \DateTime(); $dt->modify("+1 year"); $c = new Cookie("juniorkupon_letoltve", "1", $dt); $r = new Response(file_get_contents(ROOT . "/data/kupon.pdf"), 200, array("Content-Type" => "application/pdf")); $r->headers->setCookie($c); return $r; The trick is you need to create

How to attach a password encoder to a User Interface in Silex?

最后都变了- 提交于 2019-12-05 08:37:34
So I am trying to create a new Silex application and use the Security bundle included. For simplicities sake I was going to go with the basic password encoding. Per the Silex documentation http://silex.sensiolabs.org/doc/providers/security.html I have created a custom User Provider. However this user interface does not seem to use the default password encoding. I can successfully get a password out of $password = $app['security.encoder.digest']->encodePassword('foo'); However when I use the example // find the encoder for a UserInterface instance $encoder = $app['security.encoder_factory']-

How to automatically login a new user after registration with a custom user provider in Silex?

∥☆過路亽.° 提交于 2019-12-05 02:07:58
问题 Context : I created a custom user provider for my Silex Application and I can now register and log my own user perfectly. However, I need now to automatically log in my user after registration and this doesn't work. Here is my security section : 'secured' => array( 'pattern' => '^/', 'anonymous' => false, 'form' => array('login_path' => '/login', 'check_path' => '/login_check'), 'logout' => array('logout_path' => '/logout', 'invalidate_session' => true), 'users' => $app->share(function () use

Silex - Twig_Error_Syntax: The function “path” does not exist

独自空忆成欢 提交于 2019-12-05 01:26:44
According to the Silex documentation : Symfony provides a Twig bridge that provides additional integration between some Symfony2 components and Twig. Add it as a dependency to your composer.json file. I include the following in my composer.json file: { "require": { "silex/silex": "1.*", "twig/twig": ">=1.8,<2.0-dev", "symfony/twig-bridge": "2.3.*" } } I register the TwigServiceProvider() like so: $app->register(new Silex\Provider\TwigServiceProvider(), array( 'twig.path' => __DIR__ . '/views' )); I'm attempting to use the twig path() method like so: <a href="{{ path('logout') }}">Log out</a>