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

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!! :)

Related

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.

Permission denied with wkhtmltopdf

I have installed Wkhtmltopdf and I have this error when I execute him "/var/chroot/wkhtmltox-jessie-amd64: Permission denied". I search in Google but I have not found how to do ... repertory have this permission "drwxr-xr-x root root" and i execute him in web-server (apache) and Symfony.
Error :
The exit status code '126' says something went wrong:
stderr: "sh: 1: /var/chroot/wkhtmltox-jessie-amd64: Permission denied
"
stdout: ""
Can you help me ?
I encountered the same problem on the server; it was weird that the local version was happily doing its job.
After changing the generated file's destination folder permissions without any luck, I realised that the problem whas caused by the binary path in config.yml. I changed it from:
/opt/wkhtmltox/bin/wkhtmltopdf.exe
to:
/opt/wkhtmltox/bin/wkhtmltopdf
Now all it's ok.
PS: if you don't keep wkhtmltopdf in the vendor's file (my case), create a knp_snappy config in config_prod.yml; the paths are different from local to prod version.
Here is the official documenation of KnpLabs Bundle for more info.
Good luck ! (in case you needed any 'after 1 year and 11 months' answear)
Install library Wkhtmltopdf on custom folder in the user directory for linux or mac save this route and set in your config
This solution working in production server
This error is because var and opt folder you can't write any content if not root user
if you use net core or .net, use:
sudo chmod 777 -R <Directorio que contiene el wkhtmltopdf>
the error is caused because the program does not have writing permissions

Symfony production environment throws 500 error: Doctrine\ORM\ORMException 'Unknown Entity namespace alias 'DSBlogBundle'

I'm learning Symfony2, really cool stuff. But I do run into some trouble when I want to try and visit the production environment. I have followed the Symblog Tutorial that is located here: http://tutorial.symblog.co.uk/
I have cleared the cache and I visit http://symfony.dev/ I have running locally. The page remains totally blank and this error is in the log:
Fatal error: Uncaught exception 'Doctrine\ORM\ORMException' with message 'Unknown Entity namespace alias 'DSBlogBundle'.'
in /Applications/MAMP/htdocs/symfony/vendor/doctrine/orm/lib/Doctrine/ORM/ORMException.php:236
Stack trace:
#0 /Applications/MAMP/htdocs/symfony/vendor/doctrine/orm/lib/Doctrine/ORM/Configuration.php(194): Doctrine\ORM\ORMException::unknownEntityNamespace('DSBlogBundle')
#1 /Applications/MAMP/htdocs/symfony/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php(554): Doctrine\ORM\Configuration->getEntityNamespace('DSBlogBundle')
#2 /Applications/MAMP/htdocs/symfony/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/AbstractClassMetadataFactory.php(194): Doctrine\ORM\Mapping\ClassMetadataFactory->getFqcnFromAlias('DSBlogBundle', 'Blog')
#3 /Applications/MAMP/htdocs/symfony/vendor/doctrine/orm/lib/Doctrine/ORM/EntityManager.php(295): Doctrine\Common\Persistence\Mapping\AbstractClassMetadataFactory->getMetadataFor('DSBlogBundle:Bl...')
#4 /Applications/MAMP/htdocs/symfony/vendor in /Applications/MAMP/htdocs/symfony/vendor/doctrine/orm/lib/Doctrine/ORM/ORMException.php on line 236
What I don't get is that the 'Unknown Entity namespace alias 'DSBlogBundle' is perfectly "known" in the development environment. Does anyone know what I am missing? Any help is much appreciated! Thank you!
Couple possibilities I can think of:
1) If your code functions properly in the development environment, then it could be a cache problem and/or a permissions problem. Make sure your files are readable by the user/process associated with your web server and make sure the prod cache directory is writable by that user so it can generate the necessary files. What I generally do is run the clear cache console command AS that user to avoid unexpected cache problems, like this (on linux):
sudo -u www-user php app/console cache:clear --env=prod
If you're developing on linux, you must be logged in as either root or another user with administrator privileges to run a command as a user other than yourself.
2) You may have configurations defined in the dev environment that don't exist in the prod environment. Double check the files in your app/config folder. My first guess would have been that the DSBlogBundle wasn't correctly defined in app/AppKernel.php but I believe that's environment independent so it couldn't work in dev but not prod.

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