Symfony 3.2 PHP Error not displayed - symfony

I have an almost fresh install of Symfony 3.2 and it appears not to be capturing and displaying PHP errors.
To test, I have omitted the final semicolon from a line in a working controller. When I try to access the route a blank screen is displayed (the app returns nothing). This is in the dev environment. The error is logged by Symfony, but it is not handled and displayed by the debug component. This is my first version 3 project - I have previously worked in version 2 where the nicely formatted error would be returned for such an error.
Any ideas how to fix this?
I am on PHP version 5.5.9.
The relevant lines in the Symfony log are:
php.CRITICAL: Fatal Parse Error: syntax error, unexpected 'return' (T_RETURN) {"exception":"[object] (Symfony\Component\Debug\Exception\FatalErrorException(code: 0): Parse Error: syntax error, unexpected 'return' (T_RETURN) at /var/www/html/tcfdev/src/AppBundle/Controller/HomeController.php:17)"} []
and
request.CRITICAL: Uncaught PHP Exception Symfony\Component\Debug\Exception\FatalErrorException: "Parse Error: syntax error, unexpected 'return' (T_RETURN)" at /var/www/html/tcfdev/src/AppBundle/Controller/HomeController.php line 17 {"exception":"[object] (Symfony\Component\Debug\Exception\FatalErrorException(code: 0): Parse Error: syntax error, unexpected 'return' (T_RETURN) at /var/www/html/tcfdev/src/AppBundle/Controller/HomeController.php:17)"} []
The apache2 log contains the following:
PHP Parse error: syntax error, unexpected 'return' (T_RETURN) in /var/www/html/tcfdev/src/AppBundle/Controller/HomeController.php on line 17
So it appears that debug is picking it up but failing to display it.

An almost fresh install? Did you get this from another project? Does your routing_dev.yml have the profiler and errors setup?
It should look something like this:
_wdt:
resource: "#WebProfilerBundle/Resources/config/routing/wdt.xml"
prefix: /_wdt
_profiler:
resource: "#WebProfilerBundle/Resources/config/routing/profiler.xml"
prefix: /_profiler
_errors:
resource: "#TwigBundle/Resources/config/routing/errors.xml"
prefix: /_error
_main:
resource: routing.yml

Related

Issue with cache Symfony2

I have a problem when I make a change in symfony2 and when I refresh the page, the cache does not get regenerated. The log tells me the following:
AH01071: Got error 'PHP message: PHP Fatal error: Uncaught Error: Class 'Symfony\\Component\\HttpKernel\\Config\\FileLocator' not found in /var/www/vhosts/coosur.com/httpdocs/releases/840/app/bootstrap.php.cache:2812\nStack trace:\n#0 /var/www/vhosts/coosur.com/httpdocs/releases/840/app/bootstrap.php.cache(2769): Symfony\\Component\\HttpKernel\\Kernel->getContainerLoader(Object(Symfony\\Component\\DependencyInjection\\ContainerBuilder))\n#1 /var/www/vhosts/coosur.com/httpdocs/releases/840/app/bootstrap.php.cache(2721): Symfony\\Component\\HttpKernel\\Kernel->buildContainer()\n#2 /var/www/vhosts/coosur.com/httpdocs/releases/840/app/bootstrap.php.cache(2493): Symfony\\Component\\HttpKernel\\Kernel->initializeContainer()\n#3 /var/www/vhosts/coosur.com/httpdocs/releases/840/app/bootstrap.php.cache(2531): Symfony\\Component\\HttpKernel\\Kernel->boot()\n#4 /var/www/vhosts/coosur.com/httpdocs/releases/840/web/app.php(18): Symfony\\Component\\HttpKernel\\Kernel->handle(Object(Symfony\\Component\\HttpFoundation\\Request))\n#5 {main}\n thrown in /var/www/vhosts/coo...', referer: https://www.XXXX.com/
AH01071: Got error 'PHP message: PHP Fatal error: Uncaught Error: Class 'Symfony\\Component\\HttpKernel\\Config\\FileLocator' not found in /var/www/vhosts/coosur.com/httpdocs/releases/840/app/bootstrap.php.cache:2812\nStack trace:\n#0 /var/www/vhosts/coosur.com/httpdocs/releases/840/app/bootstrap.php.cache(2769): Symfony\\Component\\HttpKernel\\Kernel->getContainerLoader(Object(Symfony\\Component\\DependencyInjection\\ContainerBuilder))\n#1 /var/www/vhosts/coosur.com/httpdocs/releases/840/app/bootstrap.php.cache(2721): Symfony\\Component\\HttpKernel\\Kernel->buildContainer()\n#2 /var/www/vhosts/coosur.com/httpdocs/releases/840/app/bootstrap.php.cache(2493): Symfony\\Component\\HttpKernel\\Kernel->initializeContainer()\n#3 /var/www/vhosts/coosur.com/httpdocs/releases/840/app/bootstrap.php.cache(2531): Symfony\\Component\\HttpKernel\\Kernel->boot()\n#4 /var/www/vhosts/coosur.com/httpdocs/releases/840/web/app.php(18): Symfony\\Component\\HttpKernel\\Kernel->handle(Object(Symfony\\Component\\HttpFoundation\\Request))\n#5 {main}\n thrown in /var/www/vhosts/XXX...'
Besides, if I make a change and reload the page, the result is the next:
�Tf8utf8_general_ciPRIselect,insert,update,referencesNEVERvarchar(17),8�defpsalocalesactiveNOenumutf8utf8_general_ciselect,insert,update,referencesNEVERtrueenum('false','true')
Any idea?

Akeneo - Cannot access specific parts of the backend (http 500)

I am having some trouble to test akeneo (PIM based on symfony) features, as some parts of akeneo backend return the following error:
Sorry, page was not loaded correctly
It specifically occurs if I click under enrich, or settings.
I checked under app/logs, here is what I found:
[2016-11-05 13:57:36] request.CRITICAL: Uncaught PHP Exception Twig_Error_Runtime: "An exception has been thrown during the rendering of a template ("There are no activated locales") in "/var/www/html/pim-community-standard/vendor/akeneo/pim-community-dev/src/Pim/Bundle/EnrichBundle/Resources/views/Attribute/index.html.twig" at line 68." at /var/www/html/pim-community-standard/app/cache/prod/classes.php line 5700 {"exception":"[object] (Twig_Error_Runtime(code: 0): An exception has been thrown during the rendering of a template (\"There are no activated locales\") in \"/var/www/html/pim-community-standard/vendor/akeneo/pim-community-dev/src/Pim/Bundle/EnrichBundle/Resources/views/Attribute/index.html.twig\" at line 68. at /var/www/html/pim-community-standard/app/cache/prod/classes.php:5700, LogicException(code: 0): There are no activated locales at /var/www/html/pim-community-standard/vendor/akeneo/pim-community-dev/src/Pim/Bundle/UserBundle/Context/UserContext.php:110)"} []
I searched almost everything I could find in forums, but I'm still stuck with this issue.
Another error is also logged (depending on where I click):
[2016-11-05 13:58:55] request.CRITICAL: Uncaught PHP Exception LogicException: "There are no activated locales" at /var/www/html/pim-community-standard/vendor/akeneo/pim-community-dev/src/Pim/Bundle/UserBundle/Context/UserContext.php line 110 {"exception":"[object] (LogicException(code: 0): There are no activated locales at /var/www/html/pim-community-standard/vendor/akeneo/pim-community-dev/src/Pim/Bundle/UserBundle/Context/UserContext.php:110)"} []
These are the two errors that I was able to find in logs.
I double checked the install & all requirements (ubuntu 1.14). Everything seems fine.
Would you have an idea?
Thanks in advance!
Try to go "My Account - Additional" and select 2 locales, English and Spanish for example. Then go to console and delete the folder
pim-community-standard/app/cache/
When starting again Akeneo, view all akeneo_pim logs, or make a
tail -f /logs*
in the logsfolder.

Symfony display exceptions in prod environment

In prod env when error occurured symfony displays a standard error page.
This is the standard default framework error page:
But when PDO can't connect to database symfony display this error to the client:
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: Name or service not known' in /homepages/35/d619429344/htdocs/mcg/web/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:43 Stack trace: #0 /homepages/35/d619429344/htdocs/mcg/web/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php(43): PDO->__construct('mysql:host=db63...', 'dbo632759072', 'mgm_mgm', Array) #1 ...
PDO exeptions:
I can't display this error to the client for security reason.
Any ideas on how to disable these messages and redirect to an error page like other error ?
You should have display_errors = off in your PHP.ini anyway to avoid this problem. Errors that reveal details like these come from many places, in addition to PDO.

symfony 2.8 debug fatal error double message

Environment: Symfony 2.8.1 with XAMPP Version 5.5.24 on Windows 7.
If I trigger a fatal error in a controller, anything as simple as $array = ; in production environment, I'm getting a default php error:
Parse error: syntax error, unexpected ';' in C:\xampp\htdocs\tgsupport-test\src\AppBundle\Controller\DefaultController.php on line 16
followed by symfony custom error page message. Obviously I'd want to avoid to show eorr info in production.
Moreover in prod.log I see a double critical error: under php.CRITICAL and request.CRITICAL. Is really useful to show the same error twice?
I'm using default configuration, indeed I just installed default framework without any custom setting and I triggered my error in AppBundle/DefaultController, so I was wondering if I'm missing anything.
I missed a php.ini configuration to avoid to display error messages in page.

Difference between messages : 'server returning 404' AND 'No route found for GET /routeName

windows 8. symfony 2.7 installed with default settings on d:\htdocs\sym\again\blog\
With apache, running the URL: http://localhost/sym/again/blog/web/hello , returns the following error:
Oops! An Error Occurred
The server returned a "404 Not Found".
Something is broken. Please let us know what you were doing when this error...
INFO: The above error is different from regular apache 404 'object not found' message. for http://localhost/NonExistingPage
With the built in PHP server php app/console server:run,
running the URL http://localhost:8000/NonExistingRoute returns
No route found for "GET /NonExistingRoute" 404 Not Found - NotFoundHttpException 1 linked Exception: ResourceNotFoundException »
while running the URL http://localhost:8000/hello, returns the actual page.
Question: What is the different between the errors ? My understanding:
the regular apache error is simply when a file is requested that is not found by apache
The 'Oops! An Error Occurred The server returned a "404 Not Found". Something is broken' is what is confusing me, I don't understand why/how it is different from the route not found errors.
the route not found means that it reached symfony but did not find any route matching /NonExistingRoute in the routes file.
Another Strange thing:
if routing.yml is changed to:
offtopic_books_homepage:
path: /sym/again/blog/web/hello
defaults: { _controller: OfftopicBooksBundle:Default:index }
then
http://localhost:8000/sym/again/blog/web/hello - returns the expected page. (with app/console running)
Whereas
http://localhost/sym/again/blog/web/hello - gives the following error:
Oops! An Error Occurred
The server returned a "404 Not Found".
Why ?
In this case please reset cache for prod env:
php app/console c:c -e prod
Note:
Please use dev env and app_dev.php for development, not production environment.

Resources