6

I'm trying to work with Symfony2 with the new PHP 5.4 and its built-in server. I downloaded Symfony2 and unziped it on my server and added this router.php file like mentioned here:

<?php

    if (isset($_SERVER['SCRIPT_FILENAME'])) {
        return false;
    } else {
        require 'Symfony/web/app.php';
    }

?>

The webserver itself works because if I replace router.php with something simple like phpinfo(); it outputs it correct but with the mentioned router.php script the site remains white/blank. If I open developer tools it returns 500 Server error.

I start the server like that:

/home/php54/php -S 0.0.0.0:88 router.php

On my shell I have no output of a error message.

5
  • This may not be the answer, but have you installed the vendors for Symfony? Commented Mar 2, 2012 at 18:48
  • I downloaded 2.0.11 with Vendors: symfony.com/download?v=Symfony_Standard_Vendors_2.0.11.zip Because I haven't installed Git. Commented Mar 2, 2012 at 19:00
  • Ah, that makes sense. What do you apache2 error logs say? Commented Mar 2, 2012 at 19:58
  • 1
    Um, this works without Apache (built-in PHP server) so there isn't logged someting in the error logs of Apache :) Commented Mar 2, 2012 at 21:00
  • Add error_reporting(E_ALL); to the top of router and see what you get. Probably an include file or possibly a permissions issue. Commented Mar 2, 2012 at 22:30

2 Answers 2

7

/home/php54/php -S 0.0.0.0:88 router.php

You are trying to run server on privileged port, so either change port or run this as privileged user (not recommended).

Also you have modified router script and I think you've messed up with file paths. You are not specifying docroot in your command, so your current directory is your docroot (so it should be your project's web/ directory). But then path to the front controller in router.php is wrong (Symfony/web/app.php).

You should really follow carefully instructions from my blog post. So:

  • change your current directory to your project's web/ directory,
  • download router script: wget https://raw.github.com/gist/1507820/b9583ab7f7f5e0e4e29806c38c6c361220b6468f/router.php,
  • run server: php -S 0.0.0.0:8000 router.php.

This should work.

You can also try patch from my pull request which adds simple command that just runs built-in PHP server.

Sign up to request clarification or add additional context in comments.

2 Comments

strange the router script doesnt work for me , i have to rename app_dev.php into index.php to make it work properly.
This pull request is now integrated. One can now run app/console server:run or app/console server:run 0.0.0.0:8000 and modify app_dev.php to allow other systems on your network to access it (great for testing your app on mobile devices)
0

I don't have a php 5.4 environment handy, but load app_dev.php instead of app.php, as debugging will be set to true and errors will be reported.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.