How to customize Error Pages on prod environment without debug on Symfony 4.0 - custom-error-pages

I know there is similar question on stackoverflow but they are for previous version of symfony and I didn't find any solution to my problem.
I've just migrated from symfony 3.3 to symfony 4.0 and I can't manage to migrate customization of error pages.
I did what is explained on https://symfony.com/doc/current/controller/error_pages.html.
So I put an error.html.twig file, an error404.html.twig file and an exception.html.twig file on templates\bundles\TwigBundle\Exception repository.
In my prod environment, it's working just fine when debug is true. It uses exception.html.twig template. But when debug is false, it didn't work and the default symfony template is displayed instead of mine.
I can't find any idea why? Do you?

This is what worked for me:
1) Check ownership & permissions on your templates and template directories. From the templates directory, you could:
sudo chown -R www-data:www-data *
2) Then shut off debugging in your .env file by removing the APP_DEBUG line, or setting it to false:
APP_ENV=prod
APP_DEBUG=false
3) Finally, in the project root, clear the Symfony cache:
bin/console cache:clear

Add APP_DEBUG=0 in your .env file
Note that APP_DEBUG=false didn't work for me in Symfony 4
See : https://symfony.com/doc/current/configuration/environments.html#index-3

Related

How to deploy to Now 2 without `build` and `public`?

I've been using Now and I want to upgrade to Now 2 https://zeit.co/ but the problem is for Now 2 I need to have a build script in which I just wrote:
echo 'built'
But then it says it cannot find the "public" folder - I don't need to actually build my project so there would be no public folder.
I tried changing my build script to
cp -r . ./public
This is not working either, it says cp: cannot copy a directory, ‘.’, into itself, ‘./public’.
So is there a setting where I can get Now 2 to work just like Now?
Please take a look at Project Settings, which has just been released.

aspnetcoremoduleV2 missing from iis modules after running the runtime bundle

I dont have aspnetcoremoduleV2 in iis modules, even after installing the runtime/hosting bundle
so I cant deploy or test any core service
P.S: I used to have the moduleV2 in iis, but I accidentally deleted some files from C:/inetpub folder (not 100% sure if any files were actually deleted), but since then the module disappeared and all core apps are giving me
"aspNetCore" has a bad module "AspNetCoreModuleV2" in its module list using IIS"
in folder Systerm32/inetsrv the module is missing, when I tried to add it manually and and it in the app.hosting file the iis (sort of crashed) no app was able to run until I removed these Manuel edits
I tried to re-install iis several time/ reinstall the bundle but had to luck
following from #brandoZhang's answer & iis docs here
I have done the following and its now working
1- delete the current aspNetCoreModule (I guess this part was unnecessary)
2- install the module manually if it doesnt appear in iis modules after downloading the runtimebundle
open cmd as admin
navigate to inetSrv location "C:\Windows\System32\inetsrv"
run: appcmd.exe install module /name:AspNetCoreModule /image:%windir%\system32\inetsrv\aspnetcore.dll
ans same for aspnetcoremoduleV2, but its location is in different place
mine was in %Program Files%\IIS\Asp.Net Core Module\V2\aspnetcorev2.dll
if a duplication error appeared, delete the old one and then re install it

Vue CLI build and run index.html file without server

I'm using the latest vue-cli version 3.0.
My current issue is that whenever I run npm run build the files generated in the dist folder can't be run without a server.
I would like to be able to just open the index.html file on the browser. How do I go about doing this?
I ran into a similar issue and the following two changes helped me to make it work. Now I can just open index.html in Chrome as a file to run my SPA from file system.
In vue.config.js, I did not have a publicPath configured, which resulted in the default "/".
I had to configure it to empty string like this so that it uses relative paths:
module.exports = {
publicPath: '',
}
PS: Since Vue CLI 3.3 use publicPath instead of the now deprecated baseURL
I was using the history mode of vue-router, which does not work
on a local file system to route the paths back to index.html. So I
omitted the mode to go back to the default hash mode.
I was able to fix this issue by manually changing the url of the referenced files.
It's a bit of a pain, but this was a solution without having to mess around with the build configuration.
What you need to do:
Open index.html
Find href=/ and replace with href=
Find src=/ and replace with src=
NOTE: I was in need of this solution because I was creating a Phonegap app.
You can use the http-server module
npm install http-server -g
http-server dist/
normally the server starts at port 8080 so you can serve the build app on http://localhost:8080

Location of config files when deploying Symfony

I'm trying to deploy a Symfony 3 application on Kimsufi of OVH.
Everything works on my local machine, but when I deploy I get the error (debug mode is on) :
The file "/home/remiblaiyb/app/app/config/routing.yml" does not exist.
Symfony seems to search on app/app for config, I have no idea why.
Do you have any suggestion? Thank you very much.
EDIT: I finally found the answer. It's due to the new way of getting the project directory in Symfony: Symfony looks after the composer.json file, which I didn't upload in prod!
So do not forget to include your composer.json into your project.
Thanks!

How to install play! framework modules?

I'm trying to install this pagination module for my Play! application, but can't get it to work. I've extracted the zip file inside /play/modules/paginate-head/ and I an example here on SO, to change my dependencies.yml file into:
# Application dependencies
require:
- play
- pagination -> paginate-head
repositories:
- My modules:
type: local
artifact: ${application.path}/../[module]
contains:
- paginate-head
But I still don't think the module is being loaded. I'm assuming it's documentation should appear on http://localhost:9000/#documentation/home or are there other ways to see if a module was loaded? It's not telling me anything in the console neither.
Any ideas how to get this installed?
You don't need to extract a zip file, just running the command
play install paginate-head
should work fine. But unzipping will also work. You also don't need that "repositories" section in your dependencies.yml file. Play! knows where to find modules.
The real issue is that your require should look like this:
require:
- play
- play -> paginate head
Notice play to the left of the '->' which signifies that it's a module. Also no dash between 'paginate' and 'head'. That's because 'paginate' is the module name and 'head' is the version and these should be separated by a space.
Also, for modules that are hosted in the main Play! modules repo, you don't even have to install them. You can just add the require above and start Play! and it will install it automatically. Though it will install under the applications modules directory, not the play modules directory.
Hope that helps!