Updates from July, 2011 Toggle Comment Threads | Keyboard Shortcuts

  • Pablo 8:02 PM on 25 July 2011 Permalink | Reply  

    Symfony2: SecurityBundle 

    Outline of how it’s involved in Symfony2:

    1. AppKernel -> handle  is called ( look app.php )
    2. FrameworkBundle :: HttpKernel’s -> handle is called
    3. Component :: HttpKernel’s handle is called. Which then calls handleRaw
    4. The HttpKernel dispatches an kernel.request event.
    5. The event is captured by a Firewall previously set as a listener by the SecurityBundle’s security.xml
    6. The onKernelRequest method of this Firewall is called.
    7. The firewall loops trough all the AuthenticationListeners which where set here ( lines 213 to 225 ) as part of the Firewall and call it’s handle method.
    8. If a security violation is detected ( the authentication listeners will throw this exceptions ), a kernel.exception is detected by an ExceptionListener previosuly set in security_listeners.xml and registered in the Firewall at the time of the Request.
    So that’s an overview of how the SecurityBundle intercepts Requests and based on the reaction of the AuthenticationListeners will do nothing or throw an exception informing about the security violation.
    Step 4 is where the magic happens, as you can see, the Request is intercepted before reaching the actual controller. As described here:
    (The numbers in the image are NOT related with the numbers in this article, they are part of the image form the Symfony book)
    • nabil 9:40 AM on 18 August 2011 Permalink | Reply

      Hi, I need to insert in my augmented reality action script in flash builder a preloader for my 3D.DAE model, can u help me?

  • Pablo 3:38 PM on 25 July 2011 Permalink | Reply  

    Symfony2: Custom Authentication Provider 

    Source: How to create a custom Authentication Provider

    Regarding Security, in Symfony you have 2 providers. One is an Authentication provider and the other is an UserProvider.

    • An authentication provider is used to extract information from a request to be used  to identify the user.
    • An user provider is used to check if the user found by the authentication provider exists on our pool of users.
    So basically, the authentication provider finds information about an user on the Request and creates a TOKEN with that information. This token contains the credentials of the users. With that token, the security bundle tries to find a user using the available user Provider and tries to see if it finds one that has/match the currently found user Token. If nothing is found, an error is thrown telling so.
    Easy to understand example ( AP = Authentication provider. UP = User Provider ):
    AP:  -Hey UP, i think i found an user on the request, take a look at this token-
    UP:  -let me see… Mmhh.. yeah, i found one, your token is valid!-
    AP: -Ok, thanks. Hey Symfony Security layer, this token is valid!-
  • Pablo 8:28 AM on 14 July 2011 Permalink | Reply  

    Symfony2 & CSS url References. 

    I was having problems when designing my website, i was linking to images and then on the development enviroment i wasn’t able to see them.

    For example, when working on localhost/website/web/app_dev.php and you have something like this:

    .someDiv {
       background: url(images/logo.png) no-repeat;

    The browser would search for localhost/website/web/app_dev.php/images/logo.png which would throw a 404.

    So after trying to find out the “correct” way of solving this, i just said: -fuck it, just do it- and i edited the file app.php in the web directory and added this at the very begining of the file (i would remove when going to production):


    include "app_dev.php";
    require_once __DIR__.'/../app/bootstrap.php.cache';
    require_once __DIR__.'/../app/AppKernel.php';
    use Symfony\Component\HttpFoundation\Request;
    $kernel = new AppKernel('prod', false);

    it get the job done and doesn’t make you lose time trying to figure out anything weird.
    If someone knows the correct way of solving this, please let me know.

    • Pawel 2:08 PM on 9 August 2011 Permalink | Reply


      You shouldn’t use relative urls in css files unless you know how they work.

      Try this instead:

      background: url(/images/logo.png) no-repeat;

      not this

      background: url(images/logo.png) no-repeat;

      • Pablo Bandin 4:53 PM on 9 August 2011 Permalink | Reply

        i know how relative paths work, the urls are relative to the CSS file. And there’s a long reason why i dont use absolute urls, but thanks for the comment 🙂

    • Anush 7:05 AM on 23 September 2011 Permalink | Reply

      I usually just update the .htaccess file (change app.php to app_dev.php). If you do this, make sure you don’t include the .htaccess file as part of your deployments (i.e you’d have separate .htaccess files per environment).

  • Pablo 10:01 PM on 12 July 2011 Permalink | Reply  

    CSS Nested Divs Debug Style 

    The following styles will make nested divs, up to 6 levels with a diferent shade of black. To easily visualize the depth. This is for testing while designing.

    div {
      border: 1px solid #000;
      margin: 2px;
      padding: 2px; }
      div > div {
        border-color: #333; }
        div > div > div {
          border-color: #666; }
          div > div > div > div {
            border-color: #999; }
            div > div > div > div > div {
              border-color: #CCC; }
              div > div > div > div > div > div {
                border-color: #e1e1e1; }
                div > div > div > div > div > div > div {
                  border-color: #eaeaea; }
Compose new post
Next post/Next comment
Previous post/Previous comment
Show/Hide comments
Go to top
Go to login
Show/Hide help
shift + esc