Zend Framework 1.11.2 cache_dir not writable - php

I have inherited an application written with Zend Framework 1.11.2. It has been ported to a server managed by my company, but some of the functionality of the site seem broken on the new server, due to a little fine tuning of the environment.
Specifically, one of the cron jobs on the system is throwing an exception related to the cache directory not being writable.
I am not sure where the cache directory is to make it writable. I have done a little reading and it seems to suggest there is a tmp directory. Can anyone point me in the right direction to either the directory, or how to find out where it is, if it is application specific?
Any help appreciated.

The code for which determines the cache_dir to use when one is not specified is in Zend_Cache_Backend::getTmpDir(). The results are OS-specific and even environment-specific.
This little snippet:
require_once 'Zend/Cache/Backend.php';
$cache = new Zend_Cache_Backend();
echo $cache->getTmpDir() . PHP_EOL;
produced /tmp on my Ubuntu. YMMV.

The cache directory is specified in application.ini:
resources.cachemanager.database.backend.options.cache_dir
resources.cachemanager.locale.backend.options.cache_dir
resources.cachemanager.translations.backend.options.cache_dir

There is a feature request for this (ZF-12214). You can use the included patch to monkey-patch your ZF for debugging.

Related

Convert Web Application (ZF2) to PHAR

I know how to convert php file into phar file.
$phar = new PHAR('app.phar');
$phar->addFile('file1.php');
$phar->addFile('file2.php');
I thought it can be useful only for converting POPO to PHAR.
My question
Is it possible to convert entire Zend framework 2 web application to PHAR file? if yes, then How?
(or)
How to package Zend framework2 web application into a package? (except .zpk(zend studio package file) file format)
Updated: creating Phar from entire application
create-phar.php
$basePath = /path/to/;
$path = /path/to/application;
$phar = new Phar ('project.phar');
$phar->buildFromIterator(new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path)), $basePath);
$phar->setStub("<?php
Phar::webPhar('project', 'public/index.php');
include 'phar://project/public/index.php';
__HALT_COMPILER();
?>");
index.php
<?php
include 'project.phar';
?>
Question:
When i run index.php it do not redirect to actual public/index.php file instead it shows blank page on the browser. How can I resolve this problem?
Thanks in advance
I deploy phorkie as a .phar file.
There are some things to consider:
Pack up all files in the .phar - php and static asset files (js, css, png, jpg), too. I use phing to do that. Do not forget the dependencies.
You need a stub file that runs Phar::webPhar() which takes care of sending out HTTP headers
Write your own .htaccess rewrite rule interpreter, because Phar::webPhar() does not do nice-path resolving on its own. I did that already.
Manually take care of sending out caching headers for static files
Hope that you (or your users) don't run into one of the Phar::webPhar bugs:
Symlinked files
No HEAD, PUT or DELETE support
Redirection loop with FPM (already fixed in git)
Hope that your user's web server handles .phar files (it will not; neither Debian nor Fedora ship that configuration)
Hope that the user's web server is correctly configured to handle .phar files with PATH_INFO appended (/path/to/file.phar/foo/bar.png), like in http://p.cweiske.de/122
Getting phorkie running from the .phar took me the evenings of two weeks. Now that it basically works it still is not a drop-phar-and-play solution, because the default configuration of web servers just doesn't play nice with .phar.

Restler 3.0 RC5 HtmlFormat uses mkdir

first thanks for your brilliant work on Restler, I am using it for some labs at the University and so far it works like a charm, really simple and elegant framework!
I've been using Restler 3.0 RC4 successfully until I updated to RC5 today. Now I'm having problems with the HtmlFormat. Whenever I try to access any of my web services that return HtmlFormat or try to enter the API Explorer, I'm getting a HTTP 500, "Unable to create cache directory /home/xxxxxxx/public_html/concrete/api/cache/php" . Also, I see a "Warning: mkdir() [function.mkdir]: No such file or directory in /home/xxxxxxx/public_html/concrete/Restler/vendor/Luracast/Restler/Format/HtmlFormat.php on line 367" .
Do you have any idea of what could be happening? In the upgrade, I just replaced my Restler framework folder with the RC5 one, without any changes in my API itself.
I would appreciate any help. Thank you!
Most of the template formats need a cache folder to keep their compiled files so that they run efficiently
Since RC5 we create a subfolder for the template type used. Even though php templates does not need compilation Restler attempts creating php folder under the default cache location, which is cache folder located in the same folder as the index.php
In your case it is
/home/xxxxxxx/public_html/concrete/api/cache
You should update the cache folder to keep it outside the web root by adding
Defaults::$cacheDirectory = '/home/xxxxxxx/cache';
And then make sure the cache folder is writable
Then HtmlFormat will create the php/twig/blade folder depending on your template preference and add the compiled files inside

Installing Zend Gdata Client library

Hi this is my first post on here. I am trying to install the Gdata Zend Client library without much success.
I have used these resources + scoured Stack Overflow.
https://developers.google.com/gdata/articles/php_client_lib
http://jeromejaglale.com/doc/php/google_calendar_api
I want to be able to add,edit etc events on google calendar via PHP. My problem/question is i really dont understand what the include_path settings are all about and how to set them in order to make the class work. Of course i checked php manual regarding this but still draw a blank.
I have downloaded the relevant class and uploaded it to my web root. In the past i would just include a class by using php include at the top of the page and this would suffice.
I am of the understanding that i need to change the php.ini file to show php where my class is. Does this mean that i have to put my class somewhere else other than the web root.
I am terribly confused about this step and i know that if i can get it installed, actually using the class should be relatively easy.
Thanks for any help.
Welcome! Your Q is about include files rather than ZF elements.
Understanding where the include setting can be made (and subsequently overridden) is an absolute key bit of information.
You need to find out where it is on the server you are working on.
echo ini_get('include_path');
Then dash off and really, really read the corresponding manual page.
Try out including a very simple file with an echo statement, and you will regain your sanity and confidence.
http://www.php.net/manual/en/function.include.php
Get that working then have a play with this:
http://www.php.net/manual/en/function.ini-set.php
The experience how you can include a file from the same directory (not generally a good idea if that is a public webpage - inside your webroot)
Then if you want to really chase this thing down, look at where you can set this in Apache and per-directory in .htaccess files.
Finally, you can just include a file by telling include/require the exact path from the top of the tree;
include /var/www/includes/libraries/and/so/on.php;
There are SO many places you can set and override this that you are really best off finding out where the server thinks the include directory is and putting your compoenents in there:
Now, when that comes to ZF stuff, I (on Deb and Ubuntu anyhow) put the contents of
Zend Framworks version XYZ ZendFramework/lib/Zend <-that folder into:
/usr/share/php/Zend <-into this place
Then setup your autoloader and Robert is your mothers brother...
Zend/Gdata.php line 124 is like this:
public static function import($uri, $client = null,$className=’Zend_Gdata_Feed’)
Change that to this:
public static function import($uri, $client = null,$className=’Zend_Gdata_Feed’, $useObjectMapping = true)

Zend framework in Xampp

I recently downloaded the full package version(recommended) of ZendFramework(2.0.5).And tried and failed to install in xampp(version 1.7.4) also my php version is 5.3.5 .
I have done almost everything that is said to do like-
1.find php.ini and add path
include_path = ".;C:\xampp\php\Zend\library\zend\;C:\xampp\php\PEAR;"
2.Extract the downloaded Zend Framework folder and copy to your PHP include path.
I have also checked the folder(xampp,php,Zend) permissions too.I have checked and rechecked my tries multiple times but that error is not solved.
Exception thrown trying to access Zend/Loader.php using 'use_include_path' = true. Make sure you include Zend Framework in your include_path which currently contains: .;C:\xampp\php\Zend\library\zend\;C:\xampp\php\PEAR;
It has already taken mine whole day to check other forums,get ideas but none of then works.Please help .Thanks
Your path should probably be C:\xampp\zend\library\Zend.
You shoulnd't take the framework to the global include path but have it as a dependency in your project, soon you'll have two projects with two different versions of ZF and then the global option creates troubles
Hi there finally after doing every possible tries,my error was gone.
I don't know other cases but in my case i have done a series of mistake.So as i corrected them the error was gone.Here is what i did
1.In ZendFramework-2.0.5 the loader.php was missing.So following error occured
Exception thrown trying to access Zend/Loader.php using 'use_include_path' = true. Make sure you include Zend Framework in your include_path which currently contains: .;C:\xampp\php\Zend\library\zend\;C:\xampp\php\PEAR;
For this i downloaded the ZendFramework-1.12.0(only in my case).And Loader.php was there
2.No two mistake of mine was i fractured the path from half.
i.e.If my folder structure was like
ZendFramework-1.12.0/library/Zend/..I add the half path to php.ini file
include_path = ".;C:\xampp\php\PEAR\;C:\xampp\php\Zend;"
which was a mistake so i, gave the path before the library folder
include_path = ".;C:\xampp\php\PEAR\;C:\xampp\php\Zend\library;"
and placed the folders according to path.
3.And what about environmental variables i read about?
They are not neccessary while installing the ZendFramework for the first time.After it i am not in that condn to say whether it should be added or not environmantal variables
C:\xampp\php
So,after doing above mentioned corrections and checking through the installation checker the error was gone.
And remember to restart(start and stop) the apache server after a tiny change in php.ini file.
thanks to markus-tharkun and Seth Battin a lot.You saved me.

Help me correct my php include path on windows 7, i've hit a block

i've been suggested to use the ZFDotrine from a post here but right now it turns out to be kind of headache where i don't know why zf can't see the zfdoctrine provider.
I have a kind of shady environment on my windows 7.i have xampp 1.7.3 and zend server5.0.2 on my machine each with a different version of zf.so i downloaded zf 1.10.8 under drive c (C:\ZendFramework) and referenced its bin in the environment variable path, and its library in php.ini. i've removed c:/xampp/php/PEAR/zend folder and c:/xampp/php/zf.bar | zf.php. i also have netbeans 6.9 created the zf.ini for me.After some issue with NetBeansCommandsProvider i got everything working fine, from command line tool project create to tool from netbeans.
xamp/php.ini
include_path = ".;C:\xampp\php\PEAR;C:\ZendFramework\library;"
zendserver/php.ini
include_path=".;C:\ZendFramework\library"
in zf.ini i have change php.includepath to php.include_path
php.include_path = "C:\ZendFramework\library;.;C:\Users\sensei\ .netbeans\6.9\zend;C:\ZFDoctrine;"
basicloader.classes.0 = "NetBeansCommandsProvider"
So with ZFDoctrine physically under C and referenced in zf.ini i thougth everything would work out but i'm having errors
Failed opening 'ZFDoctrine\Tool\DoctrineProvider.php' for inclusion (include_path='.;C:\xampp\php\PEAR;C:\ZendFramework\library;C:\ZFDoctrine;') in C:\ZendFramework\library\Zend\Loader.php on line 147
for the command zf enable config.provider ZFDoctrine_Tool_DoctrineProvider
Apparently when i copy ZFDoctrine folder to C:\ZendFramework\library\zend\ it works.that makes me realize there is something wrong with the include_path.
i'm thinking also about copying it to the PEAR folder but that too, i don't know if that's the best way to go.I just don't understand why it can't find the ZFDoctrine folder.
I'm kinda stuck.Please has anyone successfully using this to share his experience with me?Can you point out what i'm not doing right? thanks for reading this.this is a kind of blocker to me
Zend_Tool uses the include path in zf.ini, so it's this one you need to double check:
php.include_path = "C:\ZendFramework\library;.;C:\Users\sensei\ .netbeans\6.9\zend;C:\ZFDoctrine;"
What is the correct full path to DoctrineProvider.php? At the moment it's looking for:
C:\ZFDoctrine\ZFDoctrine\Tool\DoctrineProvider.php
which doesn't look right. Assuming you've extracted the full ZFDoctrine to C:\ZFDoctrine, then should it be:
php.include_path = "C:\ZendFramework\library;.;C:\Users\sensei\ .netbeans\6.9\zend;C:\ZFDoctrine\library;"

Categories