1

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/.

1 Answer 1

1

You can create the directory docs in the web directory.

If you look at the rewrite rule in the .htaccess located in the web directory you will see :

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)$ app.php [QSA,L]
</IfModule>

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 directly from mysite.com/docs/test.html

Edit : Think about the css and js files for examples. When you include them, they are not handle by the router

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.