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

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.

Related

How to fix 'Uncaught PHP Exception Twig_Error_Loader: Unable to find template' on Symfony 3.4?

I deployed a symfony 3.4 project from my local machine (Windows 10) to a cloud server (Digital Ocean) based on Ubuntu.
I spent 2 days trying to resolve this (i think) routing problem:
"request.CRITICAL: Uncaught PHP Exception Twig_Error_Loader..."
Locally, on localhost with XAMPP, it works perfect.
The project runs ok on the login (is like a backend user app), with the register ok But when it tries to pass the login, it needs to load the initial dashboard with some includes (like nav_side.html.twig) and the server response is error 500.
How can i fix it?
Thanks a lot for your response...i'm a little bit desperate. :)
I made composer update, i deleted the cache folder, but the error is still there.
request.CRITICAL: Uncaught PHP Exception Twig_Error_Loader: "Unable to
find template "Backe ndBundle:includes:nav_side.html.twig"
(looked into: /var/www/onecup/app/Resources/views,
/var/www/onecup/vendor/s
ymfony/symfony/src/Symfony/Bridge/Twig/Resources/views/Form) in
"BackendBundle:Dashboard:index.html.twig" at line 7." at
/var/www/onecup/vendor/twig/twig/lib/Twig/Loader/Filesystem.php line
234 {"exception":"[object] (Twig_Err or_Loader(code: 0):
Unable to find template \"BackendBundle:includes:nav_side.html.twig\"
(looked into: /var/www/ onecup/app/Resources/views,
/var/www/onecup/vendor/symfony/symfony/src/Symfony/Bridge/Twig/Resources/views/Form)
in \"BackendBundle:Dashboard:index.html.twig\" at line 7. at
/var/www/onecup/vendor/twig/twig/lib/Twig/Loader/Fil
esystem.php:234)"} []
#Flying was right: examine your code and try to find possible case inconsistences in directory / filenames. e.g. "file" and "File". Windows filesystem is case-insensitive, but Ubuntu filesystem is case-sensitive.
So, i changed the Includes to includes and that's all.
Thanks a lot!! :)

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.

Fatal error when copying wordpress site from server to localhost

I've been trying to create a local copy of this wordpress site - click4taps.co.uk. But even though everything seems to run pretty much fine on the server, on localhost I am getting these code errors, I would have maybe expected a database error if I had forgot something in the setup. I'm not super good at php but I can't see anything that out of place in the code the error specifies.
Here is the error message I receive when trying to launch the site in localhost:
Warning: call_user_func_array() expects parameter 1 to be a valid callback, function 'woocommerce_layered_nav_init' not found or invalid function name in C:\Program Files (x86)\Ampps\www\click4taps\wp-includes\plugin.php on line 406
Fatal error: Call to undefined function is_product() in C:\Program Files (x86)\Ampps\www\click4taps\wp-content\themes\bazar\theme\plugins\woocommerce-ajax-layered-nav\init.php on line 59
Any feedback on this would be very helpful thanks
Activate your woocommerce plugin

LinkedIN - PHP Sample Code

I am trying to implement the LinkeIN API with PECL oAuth Module, I have managed to import my contacts and the scrip works well on my Development envoirnment
But on my Live Server it raises an exception when I get redirected to my website after authentication(From Linked In Website)
I have confirmed the following:
1. The TimeZone is proper and My Server DateTime is set correct.
2. The CallBack URL is proper
Exception :
Exception caught! Response: 400 1302008612531 0 Unsupported POST target {/v1/people/~:(id,first-name,last-name,headline,location,industry,distance,relation-to-viewer,current-status,current-status-timestamp,connections,summary,specialties,proposal-comments,honors,positions,educations,member-url-resources,picture-url,site-standard-profile-request,api-standard-profile-request)}
Fatal error: Uncaught exception 'OAuthException' with message 'Invalid auth/bad request (got a 400, expected HTTP/1.1 20X or a redirect)' in /var/www/html/contaxz/app/webroot/linkedIn/linkedin/Request.php:217 Stack trace: #0 /var/www/html/contaxz/app/webroot/linkedIn/linkedin/Request.php(217): OAuth->fetch('https://api.lin...') #1 /var/www/html/contaxz/app/webroot/linkedIn/example/index.php(23): LinkedIn_Request->pullConnections() #2 {main} thrown in /var/www/html/contaxz/app/webroot/linkedIn/linkedin/Request.php on line 217
Please suggest
Thanks
Ravi
I had been breaking my head with the code, server configuration, oAuth installation, php and apache version, TimeZone and what not.... but had No Luck….
Finally, I found my way and thought of posting it here as it could help someone:
Stop Apache
Hunted for the PHP OAuth Module in the PHP lib directory in my case I found this at /usr/lib/php/modules/oauth.so
Copied PHP OAuth Module from my DEV server and uploaded it on LIVE server
Restarted apache and it worked!
Thanks
Ravi

Resources