Poru
Poru

Reputation: 8370

Symfony2 with PHP 5.4 built-in server

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.

Upvotes: 6

Views: 7030

Answers (2)

Michał Pipa
Michał Pipa

Reputation: 562

/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.

Upvotes: 7

Saem
Saem

Reputation: 3413

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.

Upvotes: 0

Related Questions