silex

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

北城以北 提交于 2019-12-10 01:12:12
问题 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'

Proper way to configure Silex Firewall to use api keys

谁说我不能喝 提交于 2019-12-09 22:25:35
问题 I've been working on making an api that accepts api keys and followed the instructions on http://symfony.com/doc/current/cookbook/security/api_key_authentication.html using a database table to hold the api keys. Is there a better way to handle this strictly using silex's firewall settings? 回答1: Symfony does not come with an API key authenticator out of the box, but you can create one (not easily, especially for beginers) following the cookbook entry you've posted. So the short answer to your

Custom authentication provider in silex application

懵懂的女人 提交于 2019-12-09 16:46:24
问题 I try to write custom authentication provider for LDAP-authentication using silex documentation - Defining a custom Authentication Provider. But if I look into $app['security.authentication_providers'] there are two providers. One that I defined App\LdapAuthenticationProvider and one Symfony\Component\Security\Core\Authentication\Provider\DaoAuthenticationProvider And when I try to authorize user I get error because there is call of a App\LdapUserProvider::loadUserByUsername() from class

Difference between Include, Extends, Use, Macro, Embed in Twig

China☆狼群 提交于 2019-12-08 22:46:22
问题 What is the difference between use and include in Twig? Documentation: include The include statement includes a template and returns the rendered content of that template into the current one: {% include 'header.html' %} Body here... {% include 'footer.html' %} use The use statement tells Twig to import the blocks defined in blocks.html into the current template (it's like macros, but for blocks): blocks.html {% block sidebar %}{% endblock %} main.html {% extends "base.html" %} {% use

Accessing app.user in unsecured area, silex

人走茶凉 提交于 2019-12-08 06:58:33
问题 I have this configuration for firewall : $app->register(new Silex\Provider\SecurityServiceProvider(), array( 'admin' => array( 'pattern' => '^/admin', 'form' => array( 'login_path' => '/#login', 'check_path' => '/admin/login_check', ), 'logout' => array( 'logout_path' => '/admin/logout', ) ), 'unsecured' => array( 'anonymous' => true, 'pattern' => '^.*$', ), )); and also this for security.rules : $app['security.access_rules'] = array( array('^/admin', 'ROLE_ADMIN'), array('.*', 'IS

Silex PHPUnit Functional tests

情到浓时终转凉″ 提交于 2019-12-08 06:40:22
问题 I have a question concerning the functional test in Silex/PHPUnit. require_once '/var/www/silex/vendor/autoload.php'; class MyTest extends Silex\WebTestCase{ protected $app; public function createApplication() { $this->app = require 'app.php'; return $this->app; } public function testInitialPage(){ $client = $this->createClient(); $crawler = $client->request('GET', '/login'); $this->assertTrue($client->getResponse()->isOk()); $this->assertCount(1, $crawler->filter('html:contains("Login")'));

Symfony LDAP auth bind with username and password

我的梦境 提交于 2019-12-08 04:07:20
问题 I am trying to get LDAP authentication working for Symfony firewall but am having trouble. The main issue seems to stem from the Symfony LdapUserProvider - it does not take the user supplied username and password when trying ldap_bind() . So, I have this as my firewall config: $app->register(new SilexProvider\SecurityServiceProvider(), [ 'security.firewalls' => [ 'secured' => [ 'pattern' => '^.*$', 'http' => true, 'users' => new \Symfony\Component\Security\Core\User\LdapUserProvider( \Symfony

Automatic login after registration in Silex

南楼画角 提交于 2019-12-08 03:30:18
问题 I want to automatically login user after registering. First I tried this way https://gist.github.com/simonjodet/3927516. Bu tit did not work. I found out someone else had the same problem and found a workaround in this question, but it does not work for me. This is my code, the login process works correctly. But not login automatically when registering. My security configuration: $app['security.firewalls'] = array( 'main' => array( 'pattern' => '^(/user|/logout|/login_check)', 'form' => array

Silex: redirect admin to admin-home path after login

放肆的年华 提交于 2019-12-08 03:17:19
问题 How in Silex redirect admin (ROLE_ADMIN) to /admin page after successful login and user (ROLE_USER) to / page after successful login? My config so far: $app['security.firewalls'] = array( 'login' => array( 'pattern' => '^/login$', ), 'secured' => array( 'pattern' => '^.*$', 'form' => array('login_path' => '/login', 'check_path' => '/login_check'), 'logout' => array('logout_path' => '/logout'), 'users' => $app->share(function() use ($app) { return new App\User\UserProvider($app['db']); }), ),

Doctrine ORM Fail (ClassMetadataFactory.php)

柔情痞子 提交于 2019-12-07 22:46:53
问题 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 回答1: I'm guessing you accidentally upgraded doctrine when upgrading