Skip to content

[WebServerBundle] Error when using custom router path/file #23206

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
acrobat opened this issue Jun 16, 2017 · 1 comment
Closed

[WebServerBundle] Error when using custom router path/file #23206

acrobat opened this issue Jun 16, 2017 · 1 comment

Comments

@acrobat
Copy link
Contributor

acrobat commented Jun 16, 2017

Q A
Bug report? yes
Feature request? no
BC Break report? no
RFC? no
Symfony version 3.3.2

We are using the server:run command in our travis-ci test suite to run behat tests. We specify a custom router file for the behat tests environment.

In symfony 3.2.x it worked fine:

→ app/console server:run 127.0.0.1:8080 --env=test_travis --router=app/config/router_test_travis.php 

                                                                                                                        
 [OK] Server running on http://127.0.0.1:8080                                                                           
                                                                                                                        

 // Quit the server with CONTROL-C.                                                                                     

PHP 7.1.6-1~ubuntu16.04.1+deb.sury.org+1 Development Server started at Fri Jun 16 09:28:54 2017
Listening on http://127.0.0.1:8080
Document root is /path/to/web
Press Ctrl-C to quit.
[Fri Jun 16 09:28:58 2017] 127.0.0.1:36272 [200]: /
[Fri Jun 16 09:28:58 2017] 127.0.0.1:36274 [404]: /css/345a2cf.css
[Fri Jun 16 09:28:58 2017] 127.0.0.1:36276 [404]: /js/f0fb6d7.js
[Fri Jun 16 09:28:58 2017] 127.0.0.1:36310 [404]: /js/66e68a2.js
[Fri Jun 16 09:28:58 2017] 127.0.0.1:36312 [200]: /bundles/xxxxx/img/logo.png
[Fri Jun 16 09:28:58 2017] 127.0.0.1:36314 [200]: /bundles/xxxxx/img/chimney.png
[Fri Jun 16 09:28:58 2017] 127.0.0.1:36328 [404]: /js/f0fb6d7.js
[Fri Jun 16 09:28:58 2017] 127.0.0.1:36352 [404]: /js/66e68a2.js
[Fri Jun 16 09:28:58 2017] 127.0.0.1:36364 [200]: /bundles/xxxxx/img/ico/favicon.ico
Symfony packages
symfony/assetic-bundle                 v2.8.1  Integrates Assetic into Symfony2
symfony/monolog-bundle                 v2.12.1 Symfony MonologBundle
symfony/polyfill-intl-icu              v1.3.0  Symfony polyfill for intl's ICU-related data and classes
symfony/polyfill-mbstring              v1.3.0  Symfony polyfill for the Mbstring extension
symfony/polyfill-php54                 v1.3.0  Symfony polyfill backporting some PHP 5.4+ features to lower PHP versions
symfony/polyfill-php55                 v1.3.0  Symfony polyfill backporting some PHP 5.5+ features to lower PHP versions
symfony/polyfill-php56                 v1.3.0  Symfony polyfill backporting some PHP 5.6+ features to lower PHP versions
symfony/polyfill-php70                 v1.3.0  Symfony polyfill backporting some PHP 7.0+ features to lower PHP versions
symfony/polyfill-util                  v1.3.0  Symfony utilities for portability of PHP codes
symfony/polyfill-xml                   v1.3.0  Symfony polyfill for xml's utf8_encode and utf8_decode functions
symfony/swiftmailer-bundle             v3.0.1  Symfony SwiftmailerBundle
symfony/symfony                        v3.2.9  The Symfony PHP framework

But when we try to upgrade to symfony 3.3 and use the new symfony/webserver-bundle the custom router option does not work anymore:

 app/console server:run 127.0.0.1:8080 --env=test_travis --router=app/config/router_test_travis.php

                                                                                                                        
 [OK] Server listening on http://127.0.0.1:8080                                                                         
                                                                                                                        

 // Quit the server with CONTROL-C.                                                                                     

PHP 7.1.6-1~ubuntu16.04.1+deb.sury.org+1 Development Server started at Fri Jun 16 09:30:21 2017
Listening on http://127.0.0.1:8080
Document root is /path/to/web
Press Ctrl-C to quit.
[Fri Jun 16 09:30:28 2017] PHP Warning:  Unknown: failed to open stream: No such file or directory in Unknown on line 0
[Fri Jun 16 09:30:28 2017] PHP Fatal error:  Unknown: Failed opening required 'app/config/router_test_travis.php' (include_path='.:/usr/share/php') in Unknown on line 0
Symfony packages
symfony/assetic-bundle                 v2.8.1  Integrates Assetic into Symfony2
symfony/monolog-bundle                 v3.1.0  Symfony MonologBundle
symfony/polyfill-intl-icu              v1.4.0  Symfony polyfill for intl's ICU-related data and classes
symfony/polyfill-mbstring              v1.4.0  Symfony polyfill for the Mbstring extension
symfony/polyfill-php56                 v1.4.0  Symfony polyfill backporting some PHP 5.6+ features to lower PHP versions
symfony/polyfill-php70                 v1.4.0  Symfony polyfill backporting some PHP 7.0+ features to lower PHP versions
symfony/polyfill-php72                 v1.4.0  Symfony polyfill backporting some PHP 7.2+ features to lower PHP versions
symfony/polyfill-util                  v1.4.0  Symfony utilities for portability of PHP codes
symfony/polyfill-xml                   v1.4.0  Symfony polyfill for xml's utf8_encode and utf8_decode functions
symfony/swiftmailer-bundle             v3.0.3  Symfony SwiftmailerBundle
symfony/symfony                        v3.3.2  The Symfony PHP framework
@stof
Copy link
Member

stof commented Jun 16, 2017

#23173 is fixing this. There is a regression in 3.3. The workaround until the fix is merged and released is to pass an absolute path for your router script instead of a relative one.

fabpot added a commit that referenced this issue Jun 16, 2017
This PR was merged into the 3.3 branch.

Discussion
----------

[WebServerBundle] Fix router script option BC

| Q             | A
| ------------- | ---
| Branch?       | 3.3
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #23206
| License       | MIT
| Doc PR        | -

Server commands does not work with router script given by a relative path eg.:
```
bin/console server:run -r router.php
```
but, this was working before and was removed (by accident I guess) in https://github.com/symfony/symfony/pull/21039/files#diff-b915f83f99a4166eb34eab581a92501bL187

Commits
-------

aeab2fe [WebServerBundle] Fix router script path and check existence
@fabpot fabpot closed this as completed Jun 16, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants