Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Changing the name of the public folder
  • Apologies, but i'm a complete newbie to fuel PHP. Ive developed my application locally using MAMP as the environment with FuelPHP. Now other people are starting to become involved in the project so i'm trying to upload it somewhere for the rest of the team to review.

    I created the site in a subfolder of my root directory directory (htdocs) on MAMP, so the path to the public folder is currently:

    /Applications/MAMP/htdocs/mediatemple-test/public/

    I'm trying to initially get it working on our Mediatemple grid-serve, however i noticed that the root folder on Mediatemple is called "html". From reading other posts on here I understood that i should be able to just rename the "public" folder to "html", however when i do this locally i get the following error:

    Warning: require(/bootstrap.php): failed to open stream: No such file or directory in /Applications/MAMP/htdocs/mediatemple-test/public/index.php on line 44

    Fatal error: require(): Failed opening required '/bootstrap.php' (include_path='.:/Applications/MAMP/bin/php/php5.4.4/lib/php') in /Applications/MAMP/htdocs/mediatemple-test/public/index.php on line 44

    Do i need to change anything else or do i need to add a .htaccess file? If so what do I need ot put in there?

    Also does anybody have any learnings from deploying FuelPHP to Mediatemple gridserve.

  • HarroHarro
    Accepted Answer
    The FuelPHP architecture is designed so that no files are accessible from the browser, except your assets. This is where the /public folder in the distribution comes in, as you need a mount point for your webservers DocumentRoot.

    If you don't use this, but install the entire framework INSIDE the DocumentRoot, then you don't need the public folder, it serves no purpose anymore.

    You can either remove it (move the contents one folder up and modify the .htaccess accordingly), or you need to move the htaccess one directory up, and work with RewriteBase to hide the public folder, which is now inside the docroot as additional folder.

    If, in case of mediatemple, the docroot is "htdocs", and "mediatemple-test" is a folder in which you have installed the framework, you need to do both, since not only the public folder is not needed (from a functional point of view), you also introduced a folder in your docroot.

    An in all cases, you need to check the paths defined in your index.php, as they use relative paths to find stuff like the app folder and the core folders, to make sure they are still ok.

    You seem to have a different issue here. The error message suggests it wants to load the bootstrap from the root ('/bootstrap.php'), which indicates the __DIR__ constant isn't processed. This is a constant that is only available in PHP 5.3+, so check that you run that (Fuel requires PHP 5.3.3+, it will NOT work on lower versions!).
  • Hi, thanks for getting back to me so quickly.

    Just to clarify, i have been developing everything in the DocumentRoot for my local copy, but now wish to copy it to our Mediatemple Gridserve, where by only everything in the public folder is accessible at the DocumentRoot and the base/app files are in the level above (outside the DocumentRoot).

    The thing i'm struggling to get my head around is that on Mediatemple the DocumentRoot folder is called "html", so assumed i would need to change the "public" folder to the appropriate name.

    So i tried doing this on my local version and then everything just broke showing the above error :-(
    When i revert back to the folder being called "public" it all works perfectly again.

    In short i want to make the code secure when i upload it to the server, but i can't get my head around how/where i need to make changes.

    BTW, i'm definatley using PHP 5.3+ on all my servers.

    Thanks again for your help!
  • HarroHarro
    Accepted Answer
    If your local install is fully inside the document root, I assume you have deployed a custom htaccess in your document root to get rid of the /public in your URL's?

    If so, it's save to rename "public" to "html", and change your htaccess accordingly (as it would need a different rewritebase and or rewrite rules to your index.php).

    When you deploy it, it should work with the default htaccess as provided by the framework. Your custom version should be in the installation root, which is not visible by mediatemple, as that is outside their docroot.

    If you have dealt with "/public" in your code, instead of with a custom rewrite, you're doomed... ;)
  • I havent used "/public" in my code (thankfully!) :-)

    Also, I haven't created a custom htaccess file to remove the /public from the url, but i think this might be the issue i m having, hence could you point me in the direction of the code i would need to complete this.

    Thanks so much for your help!
  • HarroHarro
    Accepted Answer
    For that I need to know exactly how you installed it.

    You just installed everything inside the docroot, directly? So you need to use "/public/index.php" now? Or is everything in a folder inside the docroot (so you get "/folder/public/index.php")?
  • Its the latter..

    So the public folder resides at /mediatemple-test/public/index.php

    Thanks
  • HarroHarro
    Accepted Answer
    Ok, I have a similar setup for testing Fuel versions. I have a single docroot, and in there folders like "16master", "17develop", etc. And in those folders a complete Fuel install, so I end up with "/17develop/public/index.php".

    I have this .htaccess in the /17develop folder:

    <IfModule mod_rewrite.c>
        RewriteEngine on

        RewriteBase /17develop

        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d [OR]
        RewriteCond $1 ^$

        RewriteRule ^(.*)$ /17develop/public/index.php/$1 [L]

    </IfModule>

    The .htaccess in the public folder is completely default.

    I can request "http://fueltests.mymachine.local/17develop", which would load the welcome controller, action_index (same as "http://fueltests.mymachine.local/17develop/welcome/index").
  • HarroHarro
    Accepted Answer
    Note that this only deals with index.php though, it doesn't work with public assets.
  • Brill thanks, is there a way you can deal with public assets in here as well? Would a wildcard work?
  • HarroHarro
    Accepted Answer
    Probably, I've never dived into the rewriting.

    It's going to be a bit complicated, as you need to rewrite /mediatemple_test/assets/img/something.jpg to /mediatemple_test/public/assets/img/something.jpg, then test if that exists, and if not call index.php.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion