silex

Creating new service providers in Silex

删除回忆录丶 提交于 2019-12-07 18:58:10
问题 I've been using Silex for a while now without any issues. I've been able to add new services, create basic sites, etc. Unfortunately I'm stuck now on creating a new service from scratch... I'm not too sure what I'm doing wrong and I figured a nudge in the right direction would be useful right about now. I have a basic structure like this: cache resources src -app.php -autoload.php -config.php -controllers.php -etc vendor -assetic -Company -src -Postback.php <-- The classes I need to load

Silex - app->json() returning integer data as strings

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-07 17:58:50
问题 I just started working with Silex to help me build a restful api that returns data from my MySQL database. Previously when working with php and mysql I noticed that MySQL would return integers as strings inside my json_encode() function. It would put quotes around all my integer values. The only way I was able to fix this was to pass JSON_NUMERIC_CHECK into the json_encode function: return json_encode($array, JSON_NUMERIC_CHECK); Worked lovely for what I needed. Now that I'm using silex I've

How to implement a custom authentication success handler with Silex framework?

妖精的绣舞 提交于 2019-12-07 17:10:55
问题 I'd like to track some data when users are logging in (success and failure) but I don't really know how to do it. The firewall looks like this : $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' => $app->share(function () use ($app) { return $app["dao.identifiant"]; }), ), ), )); I

Symfony LDAP auth bind with username and password

浪子不回头ぞ 提交于 2019-12-07 15:05:24
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\Component\Ldap\Ldap::create('ext_ldap', [ 'connection_string' => 'ldap://MY_LDAP_DOMAIN', ]), 'dc=MY

Silex set cookie

断了今生、忘了曾经 提交于 2019-12-07 09:33:35
问题 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 回答1: 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(

Configure .htaccess to work on a PHP Framework (Silex)

别等时光非礼了梦想. 提交于 2019-12-07 08:05:58
问题 I have a working path on my Apache2 localhost (linux): http://localhost/lab/silex/web/index.php/hello/name I want to become: http://localhost/lab/silex/hello/name Now I have Rewrite mode enabled and tested. I have placed my .htaccess file in my silex/web folder: <IfModule mod_rewrite.c> Options -MultiViews RewriteEngine On RewriteBase /web/ RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^ index.php [L] </IfModule> I still cannot see the clean url working.

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

岁酱吖の 提交于 2019-12-07 05:59:24
问题 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

How can I make the entity field type available in silex?

…衆ロ難τιáo~ 提交于 2019-12-07 04:15:27
问题 I have been using Silex for my latest project and I was trying to follow along with the "How to Dynamically Modify Forms Using Form Events" in the Symfony cookbook. I got to the part that uses the entity field type and realized it is not available in Silex. It looks like the symfony/doctrine-bridge can be added to my composer.json which contains the "EntityType". Has anyone successfully got entity type to work in Silex or run into this issue and found a workaround? I was thinking something

Redirect to login page when session expires + silex

江枫思渺然 提交于 2019-12-06 13:53:23
问题 I want to redirect to my login page when my session is expired. What happens now: When you are for example logged in and at the dashboard, you will see you're username in the right top corner. But when you don't do anything for 2 hours or so and then refresh you get an error that it's impossible to access an attribute 'username' of NULL. This comes because you're logged out... But how can I redirect to the login page when my session expires? I know how I can increase the expire time but I don

Creating new service providers in Silex

时光怂恿深爱的人放手 提交于 2019-12-06 12:58:58
I've been using Silex for a while now without any issues. I've been able to add new services, create basic sites, etc. Unfortunately I'm stuck now on creating a new service from scratch... I'm not too sure what I'm doing wrong and I figured a nudge in the right direction would be useful right about now. I have a basic structure like this: cache resources src -app.php -autoload.php -config.php -controllers.php -etc vendor -assetic -Company -src -Postback.php <-- The classes I need to load -silex -etc views web So, in app.php : use SilexExtension\CompanyPostbackServiceProvider; $app->register