This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
Go to file
Fabien Potencier e7077605bb feature #18869 [Routing] Throw exception when PHP start tag is missing (WouterJ)
This PR was merged into the 3.2-dev branch.

Discussion
----------

[Routing] Throw exception when PHP start tag is missing

| Q             | A
| ------------- | ---
| Branch?       | master (?)
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | yes
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | https://github.com/symfony/symfony-docs/issues/6116 (and many more)
| License       | MIT
| Doc PR        | -

The Problem
---

In the documentation, we never use the PHP start tag. However, in the first tutorials, people simply copy/past the code examples, save the file and expect things to work. They seem to often forget to add the PHP start tag.

Without start tag, the annotation file loader simply skips the file without providing any reason why. As a big framework is quite overwhelming, simple things like this are completely forgotten.

The Fix
---

If a `*.php` file only consists of `T_INLINE_HTML`, it means there is no `<?php` start tag. In this case, instead of skipping the file, an exception is throwed with a possible fix.

BC Break?
---

As the file loader is only executed for `*.php` files, I think the BC break is minimal, but it is possible that people have applications with `*.php` files *without* a start tag. If this file lives in a routing loaded directory (e.g. when doing `@AppBundle/Controller`), it would now result in an exception.

I think this BC break is minimal and can be ignored. If you don't agree, we can add a little str match to check if `class ... {` exists. If that's the case, I think it's safe to say that it was meant to be a PHP file.

Bug or Feature?
---

I don't know if this is considered a bug or a feature, so I submitted it as a feature.

Commits
-------

1e765c8 Throw exception when PHP start tag is missing
2016-06-12 09:33:47 +02:00
.composer Drop hirak/prestissimo 2016-05-12 07:44:15 -05:00
.github Add 3.1 to PR template branch row, remove 2.3 2016-06-01 21:19:49 +02:00
src/Symfony feature #18869 [Routing] Throw exception when PHP start tag is missing (WouterJ) 2016-06-12 09:33:47 +02:00
.editorconfig Add EditorConfig File 2012-06-16 14:08:15 +02:00
.gitignore Add appveyor.yml for C.I. on Windows 2015-08-25 23:41:37 +02:00
.php_cs use nowdoc instead of heredoc 2015-12-21 17:05:00 +01:00
.travis.php Merge branch '3.0' 2016-05-13 13:06:41 -05:00
.travis.yml feature #18894 [Cache] Added PhpFilesAdapter (trakos, nicolas-grekas) 2016-06-06 10:10:42 +02:00
appveyor.yml [Cache] Optimize & wire PhpFilesAdapter 2016-05-31 18:28:43 +02:00
CHANGELOG-3.0.md Merge branch '3.0' 2016-05-12 10:59:27 -05:00
CHANGELOG-3.1.md updated CHANGELOG for 3.1.0 2016-05-30 09:24:18 +02:00
composer.json updated version to 3.2 2016-05-13 13:13:23 -05:00
CONTRIBUTING.md Update contributing docs 2016-02-24 15:36:06 +01:00
CONTRIBUTORS.md update CONTRIBUTORS for 2.3.42 2016-05-30 10:40:59 +02:00
LICENSE Update copyright year 2016-01-01 23:53:47 -03:00
phpunit [appveyor] Ignore STATUS_HEAP_CORRUPTION errors on Windows 2016-06-03 09:48:37 +02:00
phpunit.xml.dist use the clock mock for progress indicator tests 2016-03-17 10:19:04 +01:00
README.md Merge branch '2.8' 2015-06-04 22:30:47 +02:00
UPGRADE-3.0.md Merge branch '3.0' into 3.1 2016-06-03 13:12:53 +02:00
UPGRADE-3.1.md [YAML] fixed "dump" signature in upgrade file 2016-05-18 11:23:21 +02:00
UPGRADE-3.2.md deprecate get() for uncompiled container builders 2016-06-08 13:34:16 +02:00
UPGRADE-4.0.md feature #18728 deprecate get() for uncompiled container builders (xabbuh) 2016-06-08 13:34:19 +02:00

README

What is Symfony?

Symfony is a PHP full-stack web framework. It is written with speed and flexibility in mind. It allows developers to build better and easy to maintain websites with PHP.

Symfony can be used to develop all kind of websites, from your personal blog to high traffic ones like Dailymotion or Yahoo! Answers.

Installation

The best way to install Symfony is to use the official Symfony Installer. It allows you to start a new project based on the version you want.

Documentation

The "Quick Tour" tutorial gives you a first feeling of the framework. If, like us, you think that Symfony can help speed up your development and take the quality of your work to the next level, read the official Symfony documentation.

Contributing

Symfony is an open source, community-driven project. If you'd like to contribute, please read the Contributing Code part of the documentation. If you're submitting a pull request, please follow the guidelines in the Submitting a Patch section and use Pull Request Template.

Running Symfony Tests

Information on how to run the Symfony test suite can be found in the Running Symfony Tests section.