Symfony access assets folder - symfony

I have some folders in www/web/ which is the root.
It's the following folder: assets/exports/
And it contains a file export.xsl
When I do in javascript:
window.open('/assets/exports/export.xsl');
I'm going to the following link:
http://mywebsite/assets/exports/export.xsl
But I get a: 404 not found
Is symfony somehow protecting this link?
So, my question is, how can I access this file, so it starts downloading for the visitor?

From Symfony Documentation:
Keep in mind that web/ is a public directory and that anything stored here will be publicly accessible, including all the original asset files (e.g. Sass, LESS and CoffeeScript files).
Make sure you put the files in a proper directory: <symfony_root_dir>/web. See below.
Then accessing the http://mywebsite/assets/exports/export.xsl returns the file's content.
Check also your server configuration, virtual host config and read web server configuration guide from Symfony to see if you configured it properly.

Related

Symfony 4 deploy on IIS in a nested directory

I want to deploy a new Symfony 4 project (the symfony-demo) from local to a IIS web server. The project should stay in its own sub directory. The IIS webroot is two levels higher. When I go to public/index.php of my project (which is releative to the webroot in /sf/symfony-demo/), the templates are not shown correctly, since the server does not find the correct JavaScript directory in build/js/...), see screenshot
I call http://192.168.1.203/sf/symfony-demo/public/index.php, but fails to load from http://192.168.1.203/build/manifest.js.
On the server, I can not set the webroot or create virtual directores. Also, I have no command line. I need to do it via configuration in symfony or a correct write/rewrite rule in web.config file.
How can I set the sf- project root directory relative to the IIS webroot, in my case to /sf/symfony-demo/public ?
Can somebody provide a rewrite rule in web.config in /sf/symfony-demo/ or in /sf/symfony-demo/public? Or do I need to set the directory somewhere (prefix? asset?) in my project configuration files (e.g. \sf\symfony-demo\config\packages\framework.yml)?
Edit
I got it working somehow, there is a similar discussion and a solution for a symfony 2 project:
Symfony 2 project in nested directory
by adding in symfony-demo\config\packages\framework.yaml a line at assets :
base_urls:
- 'http://192.168.1.203/sf/symfony-demo/public/'
But somehow this looks strange for me to set the path this way. Setting here
base_path: '/sf/symfony-demo/public/'
does not work. I would expect to set the (relative) path explicitly somewhere, not a url. But where?
Also, setting extra.symfony-public-dir in composer.json like in
http://symfony.com/doc/current/configuration/override_dir_structure.html
does not work.
Regarding the rewrite rules:
Yes I read the doc, but I found nothing for web.config on iis for symfony on
https://symfony.com/doc/current/setup/web_server_configuration.html.
But I found a iis web.config for silex
[https://silex.symfony.com/doc/2.0/web_servers.html .
It looks like the web.config is not the real problem here.
Thank you for taking the time to read this. d.

Get Static referenced files with http request in meteor

This can be a silly question but I have had some issues with it. I am trying to implement jwplayer with meteor. Jwplayer will try to get a file based off the url you suggest. So I tried to place a file in localhost:3000/test.mp3. When I tried to hit that url I get just the default site. This would work if I used tomcat. Is there something I can do to get the files relative to meteor directory?
Thanks for your help.
In the /public directory, per the docs:
Lastly, the Meteor server will serve any files under the public directory, just like in a Rails or Django project. This is the place for images, favicon.ico, robots.txt, and anything else.
Meteor hasn't yet implemented server side routing and all directories are ultimately flattened. So for the time being, you can access your file at http://localhost:3000/test.mp3, but that may change in the future.

symfony routing.yml config for site folders

I have symfony web files in web root folder where the project is running. I have site files such as index.html, aboutus.html and contactus.html files. I have put these files into public_html/site/ How to access these files by default using routing.yml? also project should run in index.php
Hm...If you want to add to your project some static pages, I would recommend you this method.I think this is the right way. For index.php ,well read this
Why don't you make a new module for static pages and move the html content into it?
You have to understand that routing system in symfony is used for connect requested urls to controllers. So you can't use it to provide generating urls for static pages outside of your symfony application. That files are just like files of foreign site.
So you can just use link_to('about us', $this->getRequest()->getHost().'/about_us.html');

Only Serve Static Files From a Specific Directory via Code

I am looking for a code based solution to only serving static files from a specified directory using ASP.NET routing rather than specify a HttpHandler in the Web.config.
For example:
I have the following partial directory layout
/
/public
/public/hello.txt
/public/css
/public/css/base.css
/readme.txt
If any files are requested from the /public directory they should be served as-is. If any other static files are requested for example /readme.txt it should be served as a 404. The directory which allows static files to be served from should be easily specified as a string (var publicDir = "public";).
I am looking to do this with little to no configuration required in the Web.config file, and most of it configured in code.
I don't think it would be possible to achieve a solution using a class library. In IIS 6 environment files with .TXT or .JPG extension are served without going through .NET Framework. The only way is changing IIS configuration.
In IIS 7 things are handled differently but I have no idea if it is possible to find a solution that works in all environments or not.
I'll be pleased to hear what others say about this and correct me if i'm worng.

ASP.NET: external custom config file in a virtual directory - how to?

I know that there at least two approaches to leverage the web.config file:
using the configSource attribute which was introduced in .NET 2.0 - here is a good blog entry about it.
The file attribute of the appSettings tag which lets you point to an external file with a relative path. Described in the MSDN documentation on the appSettings element.
Now, my problem is that both approaches work well only for physical paths. But I need to address a config file which is in a virtual directory.
Which other method could I use to put my config resources in a virtual directory?
Note: I want to do it this way, because I have multiple instances of my web application on the same server (and that on many servers). To keep deployment easy and clean, I want to keep one directory for all the files (aspx, ascx, images, css, js etc.) and point the web apps in IIS for different customers (=domains, https etc.) to this single directory. In every IIS web I would have a virtual directory called "custom" which points to a different folder for each web.
Update: I'd like to point out that this virtual directory "custom" is not suited to contain an inherited web.config - that web.config would be valid only for the custom folder which doesn't contain aspx/ascx files.
I have the same scenario and after reading you post I realised that asp.net won't let you do this for various security reasons.
Therefore I turned to the OS to find an equivalent to the Linux soft link function which in turn led me to the Junction utility from sysinternals. This can create a directory that is actually any other directory on that volume and asp.net can't tell the difference and so happy loads the config sections that are not actually in a subdirectory of you website. Works for me :)
Virtual Directories can be set as applications, and you can just place another web.config there.
It will inherit any changes from the parent config, and you can add custom settings in it.
I was looking to do the same thing but it did not work, so I decided to do the opposite, as you know the web.config can be inherited, so I pointed IIS to a folder containing the client config (connection string, file path etc) files and the website files i put them on a virtual directory with the rest of the webconfig (where it load dll and other application files needed)
So basically i can use the website files to multple clients and the clients with their own Database connection string and other specific client settings.

Resources