Symfony 3.3 built-in server error
Asked Answered
H

5

5

I'm developping an app under windows 10 + wamp + php 7 + Symfony 3.3

I'm trying to use the built-in server :

php bin/console server:run
[OK] Server listening on http://127.0.0.1:8000
// Quit the server with CONTROL-C.

And when I go to http://localhost:8000/app_dev.php/ or http://127.0.0.1:8000/app_dev.php

I get this error :

Warning: Unknown: failed to open stream: No such file or directory in Unknown on line 0 
Fatal error: Unknown: Failed opening required 'C:\wamp\www\myproject\vendor\symfony\symfony\src\Symfony\Bundle\WebServerBundle/Resources/router.php' (include_path='.;C:\php\pear') in Unknown on line 0

Same error under every routes. My routes are correct and works fine outside of the built-in server...

Can you help me with this issue please ?

Handmaid answered 9/8, 2017 at 16:39 Comment(10)
Did you try to close your wamp server and retry ?Neolith
... yes. And my computer. Even my appartement. going to try with the entire buildingHandmaid
Hahaha good plan. You have a space in your path \myproject \vendor, try to remove it. Check your php path. Your error is very strangeNeolith
no more space... It was a typo editing link on SO sorry. "my-project" is not the real name of my project.Handmaid
maybe a way... github.com/symfony/symfony/issues/23206 but it looks like it's fix 'till junHandmaid
Which version of symfony do you use ? You should try to reproduce the bug with the symfony demo project. If the evil bug is still here, try to submit an issue with the modified demo :/Neolith
Can you check the file var/logs/dev.log to see if it shows further information as to which file line 0 is referring to?Blintze
Why are you trying to use the PHP builtin server when you have WAMPServer runningDragline
Because i'm develping a REST API.Handmaid
Please update your question with your exact PHP version. PHP 7.0, 7.1 or 7.2?Swound
B
10

I had same problem,

Solved by :

  • Delete symfony folder in vendor

  • composer update

  • If you have antivirus (like Avast) disable it before launching web server

  • php bin/console server:run

Blockbuster answered 20/12, 2017 at 14:4 Comment(3)
Worked for me on Win10 - 64bit, PHP 7.2. ThanksPompano
This worked for me: rm -rf vendor; composer update -vvv --profile --prefer-distPrevision
I also get this error when I did not notice that the server was started on port 8001 and was pointing my browser on localhost:8000.Separator
X
0

I got the same error, even when installing via composer.

It turns out that for whatever reason when composer downloaded the project, the required file listed in the error you get (vendor\symfony\symfony\src\Symfony\Bundle\WebServerBundle/Resources/router.php) was not included...

To fix this, I manually added it from https://github.com/symfony/web-server-bundle/blob/master/Resources/router.php and then my symfony app worked as expected.

I had to restart my computer in order to actually add the file because somehow I was locked out of adding it even as admin in Windows after launching the php server.

UPDATE:

Even better than manually adding the file, I just deleted the symfony folder from the vendor folder in the project and reran composer update. the router.php file is indeed downloaded. Sometimes when running bin/console server:run it gets deleted. Not sure why.

Xiaoximena answered 12/11, 2017 at 11:52 Comment(0)
S
0

It happened to me when upgrading from Symfony 3.1 to Symfony 3.4.

The reason was that I had left the development server running when I executed the command:

composer update

The solution:

  • Delete the contents of vendor folder
  • Execute composer update
  • Install the new Symfony development server bundle (follow the instructions)
  • Execute the server for development in a new port

    php bin/console server:start localhost:3421

Stoller answered 31/1, 2019 at 12:1 Comment(0)
A
0

I had this problem too : it was AVAST that blocked the "router.php" file.

I went into avast -> protection -> quarantine, and put an exception of the router.php file

And then everything worked again

Amplify answered 10/3, 2020 at 16:36 Comment(0)
S
-2

I get the same error and I solve this issue by installing the project with composer

composer create-project symfony/framework-standard-edition my_project_name

Scape answered 16/9, 2017 at 21:10 Comment(3)
This is a guess, isn't it? There isn't even a composer.json in the question.Swound
this is not a guess , I solve my issue with this solution , In the question I just described my issueScape
While your solution did work for your problem, this is not a good solution. It installs a new project, while there is a existing project. This is a 'if you got a blue screen, buy a new computer'-solution. Since there isn't even a composer.json in the question, you just don't know how the project looks like. Symfony Framework Standard Edition will install Twig, Doctrine, etc. It's not clear if OP is even using those components.Swound

© 2022 - 2024 — McMap. All rights reserved.