Access files outside of public_html

0

Is it possible to consistently access files outside the public_html folder on the server to render a View?

What I need is to call js and css files and point the images that are within the View layer that is in the app. This in turn would be on the same level as public_html , not inside it. The public_html would contain only one file named index.php and .htaccess . The index.php would call the Init.php in the app root that defines the routes and passes to the Core of the application rendering the layout through the file Bootstrap.php

The MVC

app/
    Model/
    View/
        templates/
            css/
            img/
            js/
    Controller/
vendor/
    composer/
    Core/
pubic_html/
    - index.php
    
asked by anonymous 31.07.2016 / 01:24

2 answers

1

Static files must be in the public folder or "document root".

Otherwise, that is, the way you want to maintain the structure of files and directories, you would have to do a stream or a schema with proxy for the files static (css, js, images) are publicly accessible.

Usually this is unnecessary and costs a lot of processing and memory. Roughly, it does not make sense.

To resolve, everything that is public , put it in the public folder.

If you have a specific reason for the images to be outside the public folder, then the conversation is different. We would be talking about xsend_file and things like that.

As for CSS and JS, they may even go away and be compiled with some template engine scheme, even though many platforms adopt such a practice, but this is a more complex level and I believe that your system is not at that level of development because the nature of the question.

It's worth pointing out that this has nothing to do with MVC:



    
31.07.2016 / 09:58
0

Why do not you do the reverse (and more correctly)?

You can create a basic structure within your public_html. Something like this:

/public_html
    /src
    /web
    .htaccess

Within your .htacess you put to read the / web folder as if it were the root: Here you find an example

    
31.07.2016 / 21:20