Symfony2 Overiding Exception - symfony

Recently, I've put the error.html.twig, error404.html.twig, exception.html.twig templates to the app/Resources/TwigBundle/views/Exception project directory to override Symfony2 error pages. In the prod environment it's working fine; in the dev environment also its overriding the default exception template, so it is very hard for debugging.
How can I get the default template working in the dev environment.

Overriding exception.html.twig is a mistake as it is only available in DEV environment, and you don't want a custom exception template.
Extract from official doc:
The debug-friendly exception pages shown to the developer can even be customized in the same way by creating templates such as exception.html.twig for the standard HTML exception page or exception.json.twig for the JSON exception page.

Related

Symfony 4.1 Custom twig error template

I'm trying to override twig html error templates as per the symfony documentation
So I tried to override the views like for other third party bundles by creating the following files in 'templates/bundles/TwigBundle/Exception' :
error.html.twig
error404.html.twig
However the default html twig error templates show up when I trigger a 404 error in production mode.
Testing with the /_error/{statusCode} route in dev mode displays my custom templates correctly.
EDIT: I found out that it was an issue with FriendsOfSymfony/FOSRestBundle. Using composer require friendsofsymfony/rest-bundle dev-master solved the issue

FOSUserBundle not overriding twig template in specific cases

I am using FOSUserBundle in some Symfony2 Projects.
To override the login page, I normally create a Twig file like this: /app/Resources/FOSUserBundle/views/security/login.html.twig.
In the past projects I created, this worked normally and did override the login page.
Recently, I have been working on a new Symfony project with a teammate. Overriding the login page worked in my environment but NOT in his environment. We tried uploading the project to a test server where it also didn't override the login page (It used to override it for other projects we tested).
We are using Symfony 2.7 with Linux Distros for all the environments. In my case, I use Ubuntu Server. My teammate runs Ubuntu Mate and the test server runs Ubuntu.
We checked folder permissions and ownerships and everything is ok.
Everything in the project works except this little twig override for the FOSUserBundle login page.
We already tried php clear:cache and manually deleting the cache folder.
We also tried this solution: What is the issue with not overriding templates in symfony2.6 and FOSUserBundle 1.3, where the answer suggests that the problem is the way PHP caches the file stats. This also didnt' work.
Any suggestions or maybe some PHP configs that we could try?
Thanks in advance,
It may be a problem with a case sensitivity.
Change it to /app/Resources/FOSUserBundle/views/Security/login.html.twig (lower case s -> upper case S). And then check by ls -l (also check your version control if relevant).

Custom Error Page in Shiny

When visiting a page pointing to shiny app, such as myshinyapp.com/NoSuchPage.html, shiny will return "Not Found" information page. I suppose it is error 404 page.
How can I replace this "Not Found" page with my own page?
Thanks.
From section 2.10 of the manual:
Shiny Server can utilize custom templates when generating static pages such as directory indexes and error pages. This feature is controlled using the template_dir directive and can be applied globally, or to a particular server or location.
To utilize this feature, you'll need a directory in which you'll store your templates. In this example, we'll assume you're using /etc/shiny-server/templates/. Inside this directory, you'll place the handlebars-enabled HTML templates for your pages.
Shiny Server will attempt to find a specific page to accommodate the current need -- for instance, if it encountered a 404 error, it will first look to see if you provided a specific template for handling 404 errors in the specified directory (error-404.html). If it doesn't find this file, it will go one step backwards to see if you provide a generic error template (error.html). If it can't find a suitable template in your template directory, it will fall back to use the provided templates that come with Shiny Server (and are stored in /opt/shiny-server/templates).
As you may have noticed already, Shiny Server uses a hyphen-delimited hierarchy which progresses from broadest to narrowest. So all error pages start with error. But the file name for a 404 error page would add an additional element (404) following a hyphen: error-404. All files are expected to use the .html extension.

Symfony cannot find template on prod server

Should be simple enough. Everything works in my local environment, but not on my prod server (neither prod nor dev environment). I get an error that the FOS template cannot be found:
Unable to find template "FOSUserBundle::layout.html.twig".
My code is simple:
{% extends "FOSUserBundle::layout.html.twig" %}
I'm going from my local Windows machine to a Linux box. I've read case sensitivity might be the culprit, but it doesn't seem like it.
The FOS bundle is in the normal place: vendor/friendsofsymfony/user-bundle/FOS/UserBundle.
I'm having trouble diagnosing - any ideas? Did things get screwed up when I FTPd? Permissions issues? What are the common gotchas? I'm desparate!
Update: A clue. I ran assetic:dump and got
[RuntimeException]
".../app/Resources/FOSUserBundle/views/layout.html.twig" resource is hidden by a
resource from the "*******Bundle" derived bundle. Create a
".../app/Resources/*******Bundle/views/layout.html.twig" file to override the bundle
resource.
This question seems relevant.
Another update: I was using getParent() in my own bundle to override the templates. I switched to the first method in the docs but now the templates in app/resources simply aren't having an effect. It's going straight to the default form template with a white background.
Any ideas?
It was a upper/lower case/namespacing thing. I thought my local files were in sync with remotes but they were not.
Just check your whole directory & all namespaces in the FOS bundle!
I also encountered the problem and "solved" it by renaming my layout.html.twig inside my bundle's Resources/views folder to bundle-layout.html.twig and adapting my templates accordingly.
I resolved the resource is hidden by a resource error by moving the template in the good bundle extension.
Specifically from app/Resources/FOSUSerBundle/views/ChangePassword
to src/Application/Sonata/UserBundle/Resources/views/ChangePassword
I confounded FOSUser & SonataUser.

Display Error in Oracle Apex Application

I have exported my oracle apex application and install on another computer. I used css file written by me on my application and also i have change some settings in Theme that i have used for my application. I have exported and installed that css file and theme also. but when i run my application, it is not display correctly. it display only Texts and Images that i have used in application. Theme is missing. but my Login page is display correctly. because it is not using my Template. Login page using Login Template in oracle apex. after logged, when i browse other pages in my application, they are not displaying correctly. Theme is missing on those pages.
The issue is with my Template. but i have imported it in to apex application.
How could i solve this ?
UPDATED
When i open the Developer Tools in my browser(chrome), in Matched CSS Rules section in Elements Tab, display only user agent stylesheet. there is no my stylesheet.
Check your theme templates you changed and see if they are really correct and contain the reference to your custom stylesheet(s)
Check the output of a page you know should have the stylesheet reference
Where do you store the stylesheet? Workspace files, Application files, or simply in the "/i/" (#IMAGE_PREFIX#) folder?
if the latter: did you copy over your stylesheet and is it in the correct location? You say you imported the application to another computer, so you might have simply forgotten to copy over those files.
What is your Apex version ?
How do you load your CSS files ? They are stored on the server (accessible using the image prefix #IMAGE_PREFIX#), loaded into the database (accessible using #WORKSPACE_IMAGES#) or stored on an external server (accessible using the full URL) ?
When you say "install on another computer", you mean load your application into another apex installation right ? Then are you sure the server is configured as the other one (especially image prefix) ?
Have you checked that templates are the same in the two applications ?
Use the console in Chrome or Firefox to check if there are any errors on your page, such as CSS files that can't be loaded.

Resources