psliwa / PdfBundle

This bundle integrates Symfony2 with PHPPdf library.
http://ohey.pl
MIT License
120 stars 45 forks source link

Unable to run clear:cache in development mode #38

Open d3vpunk opened 11 years ago

d3vpunk commented 11 years ago

It's not possible to clear the cache of my symfony2 application. The PdfBundle internally uses some zf_cache with www-data rights (the user linux uses when you run your application in the browser. In the console, you run the app/console with another user who is not able to delete the folder:

So it's not possible to delete the cache folder:

[UnexpectedValueException] FilesystemIterator::__construct(/app/cache/dev_old/zfcache-fa): failed to open dir: Permission denied

psliwa commented 11 years ago

This is not PdfBundle issue but general symfony2 problem. Symfony2 cache is precreated by user who called app/console script but application runs on www-data account, so when some cache is creating while application runtime, permission denied error occurs.

There are some solutions: http://symfony.com/doc/current/book/installation.html#configuration-and-setup

I use umask function in first line of console script and app*.php files and it works ok.

d3vpunk commented 11 years ago

Thanks for the fast reaction and this great bundle!

I know this solution but i think this not an elegant one. I read the your documentation and i'm apparently able to define cache options: https://github.com/psliwa/PdfBundle#configuration

I tried to define some zend cache related cache options but it didn't work for me: http://framework.zend.com/manual/1.12/en/zend.cache.backends.html

Isn't it possible to define some symfony2 friendly caching options as an intiial configuration of the bundle?

truckee commented 10 years ago

In a shared host prod environment umask() (as suggested above) does not prevent an error on cache:clear similar to that of playr1983g.

psliwa commented 10 years ago

Probably you set this mask after cache was created. Umask doesn't work if cache is already created. You should clear cache one time manually (via delete cache/prod directory) and next time cache:clear should work ok.

truckee commented 10 years ago

Piotr,

Thanks for your reply.  Such does not appear to be the case.  I removed the app/cache/prod directory, ran clear cache for prod environment command as user then created a pdf in prod environment.  The zfcache* directories return owned by www-data with no group or world rights.

Now trying (without much success) to create a controller to clear cache for prod environment.

George

UPDATE: Now that I have a controller that can deal with the prod cache I no longer worry about www-data owned directories.

I very much appreciate your work here. I apologize for not being able to contribute - my work is as a volunteer for a non-profit.


From: Piotr Śliwa notifications@github.com To: psliwa/PdfBundle PdfBundle@noreply.github.com Cc: truckee truckeetrout@yahoo.com Sent: Monday, November 11, 2013 7:15 AM Subject: Re: [PdfBundle] Unable to run clear:cache in development mode (#38)

Probably you set this mask after cache was created. Umask doesn't work if cache is already created. You should clear cache one time manually (via delete cache/prod directory) and next time cache:clear should work ok. — Reply to this email directly or view it on GitHub.

ricohumme commented 9 years ago

Hi,

Problem hasn't been resolved yet, unfortunately. Still having issues with this. I keep changing the access rights to the cache folder due to the zf-cache dirs. Is there going to be a solution for this in the near future?

Best regards, Rico

bartlomiej84 commented 6 years ago

Hi to the best pdf library.

In my case setting right permissions for zfcache library helped:

ps_pdf:
    ...
    cache:
        type: ~
        options:
            filePermission: 0660
            dirPermission: 0770
    ...

Using symfony 3.4, Best regards, Bart