Giter Site home page Giter Site logo

Blank page about symfony2-ep2 HOT 9 OPEN

knpuniversity avatar knpuniversity commented on July 26, 2024
Blank page

from symfony2-ep2.

Comments (9)

weaverryan avatar weaverryan commented on July 26, 2024

Hey Mathias!

Ok, so we basically just need to figure out why we're getting the blank page - that should never happen :). I need you to check a few things for me:

  1. Make sure you're accessing app_dev.php still - e.g. http://events.local/app_dev.php.

  2. Double-check that the php.ini setting for display_errors is set to true. The best way to figure this out for sure is to create a simple PHP file that has <?php phpinfo(); ?> and execute it. On that page, you'll see the display_errors value. We need to make sure that's set to true.

When you get a white screen, it's typically not because there's an exception in Symfony, but that there's a deeper, more fatal error (it could be within our Symfony code, of course, but probably isn't an exception). Because of this, Symfony's logs are probably not going to help us - we need to look at Apache's error log to see what the actual error is. If display_errors is true, then we should see this error. But even if we don't, we should be able to find it in Apache's error log.

Let me know what you find out :).

from symfony2-ep2.

roukmoute avatar roukmoute commented on July 26, 2024

Here's a quick video that should hopefully answer all your questions
http://youtu.be/HX8zAb-Wh_A

from symfony2-ep2.

weaverryan avatar weaverryan commented on July 26, 2024

Yes, the video was very helpful, but there's still nothing that's obvious.

Typically, the white screen means you (a) have a PHP fatal error that's not showing (and your errors appear that they should be showing up), (b) you have a die statement in your code or (c) you're actually returning and empty page in your controller (this seems unlikely, since the events page was working).

What's interesting with the logs that you posted earlier, is that you can see the correct route being matched, the controller being executed, a query being made, and the request finishing. It all looks perfect. Open up your web/app_dev.php file, go to the bottom, and print out some content. Does this show up? I want to know if the execution has failed before the bottom of this file, or if it hasn't. If your content prints out, then it really seems like we're in a situation similar to (c) where our page almost seems to be acting as if nothing is being returned. What is the status code on the page? Is there any hidden HTML content?

Thanks!

from symfony2-ep2.

roukmoute avatar roukmoute commented on July 26, 2024

Hi !
Sorry for my delay

www.youtube.com/watch?v=ll1ezomRuKg

from symfony2-ep2.

weaverryan avatar weaverryan commented on July 26, 2024

Hi Mathias!

Yes, so it looks like there is never an error at all. Can you go into your controller (EventBundle:Event:index) and try adding a die statement there? Can you also try just returning a simple value from your controller? Right now, it literally seems as if you controller is just returning no content. So try this:

public function indexAction()
{
    return new Symfony\Component\HttpFoundation\Response('Hello world!');
}

And also verify that the template you're rendering has content in it. That may sound basic, but it really does look like your application is working just fine :).

Cheers!

from symfony2-ep2.

roukmoute avatar roukmoute commented on July 26, 2024

Everything all right apparently !
www.youtube.com/watch?v=PVrwqTD8hjw

from symfony2-ep2.

weaverryan avatar weaverryan commented on July 26, 2024

Yes, I agree!

Does your template have content in it? If so, try removing all of the content and replacing it with a simple "Hello world". Also, make sure there is content in your base layout (base.html.twig). Finally, if none of this shows anything, try using the render function instead of the @Template shortcut:

return $this->render('EventBundle:Event:index.html.twig', array('entities' => $entities));

Cheers!

from symfony2-ep2.

roukmoute avatar roukmoute commented on July 26, 2024

And voilà !
This is, of course, my fault !
I've completely forgotten to delete this lines in EventBundle:Event:index.html.twig :
{{ app.session.get('some_session_key') }}
{{ app.request.host }}
I don't know why, but this lines causes a bug.
Now everything all right :)

Thank you very much for your help and for your time!

from symfony2-ep2.

weaverryan avatar weaverryan commented on July 26, 2024

Hey @mathias-strasser!

I'm so glad you figured it out! Yes, the code in question was just "play" code from the last episode, but we never say explicitly to remove it (other people have left it there too). What's interesting is that it shouldn't have broken your code - both of those statements should have printed something, but not broken anything. So, I'll leave this issue open so that we can investigate :).

Cheers!

from symfony2-ep2.

Related Issues (9)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.