On Tue, Apr 5, 2011 at 11:22 PM, Thiago Elias <[email protected]> wrote:
> Hey guys.
>
> Where I work, we have some CakePHP Apps running on the same server.
> Sometimes I need to update an entire app, and I'm always having to put the
> update in a new folder, copy all webroot content (Images or any other files
> from my users) to the app new folder, and finally, remove the old one and
> rename the new folder..

rsync -av --exclude webroot/img ...

Better yet, put your user-generated content in a different directory
(eg. webroot/uploads) and exclude that so that you can use rsync to
push new img content that has to be updated. If the images that your
users are uploading are saved to the DB (the name, etc. I mean, not
the actual file) then save also the directory path relative to
webroot. eg:

directory => 'uploads/foo/bar'
name => 'some_pic.png'

> Due to this, I would like to know if there is any possibility to mantain the
> img folder out of the webroot folder, in another folder even out of the
> application, so I'll be able to update the app without fear.
>
> I was thinking in a structure like this:
>
> Normal Cake App
> /root
> + app
> ++ webroot
> +++ img
> +++ uploads
>
>
> What I want to do
> /root
> + app
> ++ webroot
> + app_content
> ++ img
> ++ uploads
>

It depends on if you're using .htaccess or not. If yes, then in
app/.htaccess, something like:

<IfModule mod_rewrite.c>
        RewriteEngine on
        RewriteCond %{REQUEST_URI} !\.(png|jpe?g|gif)$
        RewriteRule    ^$    webroot/    [L]
        RewriteRule    (.*) webroot/$1    [L]
</IfModule>

But having that extra app_content level will mean you'll either need
to include it in the URl or do further mangling with mod_rewrite.

If you have access to Apache's main conf then you really ought to set
AllowOverride None to disable htaccess and put the mod_rewrite stuff
in there. Normally, that would mean also setting DocumentRoot to
app/webroot. However, in your case, it would have to be app/.

> I know that this approach could be strange, but it could help in my context.
>
> ahh. last question: If this is possible, how to handle the $html->image
> helper ?! (I know that it goes directly into the /webroot/img folder, so, it
> will be interesting to change).

Have a look in cake/config/paths.php. You'd need to change IMAGES_URL.
But I'm fairly sure you should create your own paths.php in app/config
dir. I could be wrong but I think I saw something about that once.

But, really, I think it would be simplest to just come up with a
better practice for updating the site in the first place.

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
[email protected] For more options, visit this group at 
http://groups.google.com/group/cake-php

Reply via email to