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

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.

Related

$env must not be accessed before initialization

I upgrade my project from SF 5.4 to SF 6 with php 8.1.2.
With my dev env I have no errors!
When I use the prod env when I cache clear I have the error:
In Route.php line 196:
Typed property Symfony\Component\Routing\Annotation\Route::$env must not be accessed before initialization
I try to remove the var/cache folder.
Do you have any ideas how to fix that one?
I found the same error in stack and I replace the handler_id with null value.
The error come from the SF router vendor. Route.php is not my own code.
I have had the same issue so I cleared cache typing this command symfony console cache:clear to make all work again.
You can also refer to this link if the need arises:
$env not initialized

LAMP Error on AWS: Error writing server configuration file ".htaccess"

I'm setting up a silverstripe(4) project using LAMP with AWS and I am new to the programming world.
I'm having trouble with after entering the php dev/build.
This error comes up:
error-log.ERROR: Uncaught Exception Exception: "Error writing server configuration file ".htaccess"" at /var/www/alsoherdaughter/vendor/silverstripe/assets/src/Flysystem/AssetAdapter.php line 157 {"exception":"[object] (Exception(code: 0): Error writing server configuration file \".htaccess\" at /var/www/alsoherdaughter/vendor/silverstripe/assets/src/Flysystem/AssetAdapter.php:157)"}
Not sure what I have done wrong. I have looked about for information/resolutions but not having much luck.
You should be able to (temporarily at least) solve any permission issue with:
chmod 777 /var/www/alsoherdaughter/ -R
(in a Linux terminal)
I mentioned temporarily. If you don't have ownership to the items at hand, it's possible the above chmod will be overwritten again by some other process operating by someone else.
You might be able to permanently solve it with:
chown /var/www/alsoherdaughter/ YOUR_USERNAME_HERE

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

EPERM: operation not permitted, unlink C:\Users

I am using Meteor 1.4.3.2 on a windows7 dev environment.
A Meteor application I have developed has been great for 6+ months but I have caused a problem by removing modules and apparently something I should not have.
Something outside the application folders (sym-link pointing into \AppData\Local.meteor.. somewhere) is missing/wrong, I think.
All other projects are fine, except this one.
All of my backup copies for this project are failing now too, including fresh clone from repo.
No 'meteor' commands will in this project, or it's backup copies, so 'meteor reset' is not an option.
The error is:
C:\Users\muser\iNotice>meteor
C:\Users\muser\AppData\Local\.meteor\packages\meteor-tool\1.4.3_2\mt-os.windows.
x86_32\dev_bundle\lib\node_modules\meteor-promise\promise_server.js:190
throw error;
^
Error: EPERM: operation not permitted, unlink 'C:\Users\muser\iNotice\.meteor\lo
cal\dev_bundle'
at Error (native)
at Object.fs.unlinkSync (fs.js:932:18)
at exports.makeLink (C:\tools\cli\dev-bundle-links.js:20:8)
at [object Object]._.extend.ensureDevBundleLink (C:\tools\project-context.js
:1476:7)
at [object Object]._.extend._readFile (C:\tools\project-context.js:1410:10)
at new exports.ReleaseFile (C:\tools\project-context.js:1360:8)
at C:\tools\cli\main.js:898:22
Any suggestions on best approach to fix the application?
Thanks very much for your time and expertise.
Pick one of the following:
You can delete the content of your .meteor/local folder (repopulated next time you run > meteor)
Or call meteor as an admin
Or remove the read-only access on the dev_bundle folder (but Windows sets it back to read-only from time to time)
Thanks #n3squik!
Here are the actions I took which fixed my problem.
Remove folders:
C:\Users\muser\testApp\.meteor\local\dev_bundle*\*
C:\Users\muser\AppData\Local\.meteor\packages\meteor-tool\1.4.0-1\*
Ran:
C:\Users\muser\testApp> meteor run
The application started up and all seems good.
Thanks again Stack.

How to use VersionPress to clone across servers?

I would like to clone a WordPress site that is already in VersionPress to a new server.
The instructions are generally only listed for cloning on the current server. I have one server dedicated to Dev and another for Production
I tried the following command line:
wp vp clone
--name=sitename
--ssh=username#site.school.edu
--path=/var/www/html/folder
--url=https://site.school.edu/destination
--dbname=mydb
--dbuser=myuser
--dbpass=mypass
--dbhost=xxx.xxx.xxx.xxx
--dbprefix=wp-
--force
However after I login to the remote ssh server, I get this error:
Fatal error: Call to undefined function apply_filters() in /var/www/html/atwiki/wp-includes/load.php on line 317
Error: Cannot connect over SSH using provided configuration.
Any ideas?
Here's a blog post on how to achieve that today. We will have a more polished way in the future.

Resources