I would like to include static content in a Symfony2 project. I have auto-generated some documentation HTML files that I would like to render. They are complete HTML files, with links between them.
Thus, I would have something like:
mysite.com: Routing managed by Symfony2, using its MVC engine.mysite.com/docs/,mysite.com/docs/.../.../, etc : Just return the content of those HTML static files.
I guess I would need to create a bundle that deals with these static files, stored in its Resources/public, but I don’t know what is the best way to achieve this. Also, the routing should be able to recognize every route under mysite.com/docs/.
You can create the directory
docsin thewebdirectory.If you look at the rewrite rule in the
.htaccesslocated in thewebdirectory you will see :It means “if the file doesn’t exists, use the app.php (therefore Symfony2) file with the rewrite rule”.
Thus, if you create the file (e.g
docs/test.html) in the web directory, you will be able to access it directlyfrom mysite.com/docs/test.htmlEdit :
Think about the
cssandjsfiles for examples. When you include them, they are not handle by the router