I'm trying to include ZendFramework on a web site with no luck. Lately I gave a try at modifying the .htaccess file like this:
php_value include_path ":/home/u230474/Zend"
I also tried
php_value include_path ".:/home/u230474/Zend"
But on each case what happened was that I no longer could view any of the pages in the web site.
I did these modifications since I'm trying to make the system understand the following code:
<?php
$libreria='/Zend/ZendFramework/library';
set_include_path(get_include_path().PATH_SEPARATOR.$libreria);
require_once('Zend/Loader/Autoloader.php');
Zend_Loader_Autoloader::getInstance();
I've been trying things many days long now, and although I've talked to my provided we seem to have problems understanding the requirements.
I did a test to check the installation of ZendFramework with a script called InstallationChecker.php which is supposed to indicate the success in installing Zend Framework, and actually the script throws an error like this:
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: .:/usr/lib/php:/usr/local/lib/php
Which is why I tried modifying .htaccess
Does anyone know if I'm doing things wrong (obviously yes)? What is the right way to modify the htaccess file so that `/usr/lib/php and /usr/local/lib/php are included as well?
Also I've read that when you include a htaccess you must include also a .htaccess file to every subdirectory that makes an include. Most of my php scripts are directly in the public folder, but still I have many of them on subdirectories as well. How am I supposed to proceed?
I made some changes following Mike's advise and included the whole custom path like this:
$libreria='Zend/ZendFramework/library/Zend/Loader';
then I looked at php.info and it still doesn't show any changes to include_path. Additionally, I noticed that the error in the test I'm running to check if ZendFramework is installed is telling me there's a class Loader.php in the Zend folder, which is actually there, but still nothing gets loaded.
Ok so I did a couple of test to see what's going wrong, since the Zend Framework seems to load ok. First I added this code to the file 'libreria.php' which sets the include path (apparently alright, since the library is loaded). I did this:
$libreria='/home/u230474/public_classes/Zend/ZendFramework/library';
set_include_path(get_include_path().PATH_SEPARATOR.$libreria);
require_once('Zend/Loader/Autoloader.php');
$libload = Zend_Loader_Autoloader::getInstance();
if(!$libload) echo "Librería Zend Framework cargada"; else echo "Error al cargar la librería";
And as a result, it outputs: "Error al cargar la librería".
I also set up a tiny test to see if there's something wrong with the case sensitivity. On some of the pages that are having trouble, I put this code inmediately after including the header and the library:
//codigo para probar equidad de nombre de archivo---------->
$filename = basename($_SERVER['SCRIPT_FILENAME']);
$request = basename($_SERVER['SCRIPT_NAME']);
if($filename != $request)
die('Case of filename and request do not match!');
And it does not die, so it's ok. (If I get it right the result would be different if there was a slight difference in my file names, as are seen on the browser address, and as are seen by the server, but maybe I'm wrong).
Then, there's something going on with the way I call the Autoloader.php class, but I don't see a different way of calling it than the static method on Zend's introduction to Autoloader documentation, where it says 'Autoloader, basic usage'
.htaccess is probably not the place to make this change, as it will be more difficult to append the new path you want to include to the existing. What you did was overwrite all the include paths with just the one you specified in .htaccess. This blowd things up.
If you look at the 2nd line of the PHP code you included, it shows you how to append to the include path (by getting the current path and appending a new path to it.) Just do similar for the path you want to include.
Related
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)
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.
I'm running out of ideas here. Physically, my Zend install (XAMPP on Windows) is located at D:\xampp\htdocs\newsite\zend\library.
So far, I've managed to fail with all of the following include paths, as reported in zend.php (located at D:\xampp\htdocs\newsite and accessed from 127.0.0.1/newsite/zend.php.
.;D:\xampp\php\PEAR
.;D:\xampp\php\PEAR;/zend/library
.;D:\xampp\php\PEAR;D:\xampp\htdocs\newsite\zend\library
.;D:\xampp\php\PEAR;D:/xampp/htdocs/newsite/zend/library
.;D:/xampp/htdocs/newsite/zend/library
.;D:\xampp\htdocs\newsite\zend\library
D:\xampp\htdocs\newsite\zend\library
.;./zend/library;D:\xampp\php\PEAR;D:\xampp\htdocs\newsite\zend\library
.;./zend/library;D:\xampp\php\PEAR;D:\xampp\htdocs\newsite\zend\library;/zend/library
.;./zend/library;D:\xampp\php\PEAR;D:\xampp\htdocs\newsite\zend\library;D:/xampp/htdocs/newsite/zend/library
EDIT: Yes, I got all of the above through get_include_path(). I'm on PHP 5.3.8.
Assuming you are not trying to use auto loading, which would be a good idea to rule out problems with auto loaders.
Since the include_path returns ".;D:\xampp\php\PEAR;D:\xampp\htdocs\newsite\zend\library" I would expect a simple include to work.
Assuming you are using ZF2, this test should not error, if the above include path is being returned:
<?php
include ('Zend\Version\Version.php');
If that does error, try it with a full path to verify if it's the include path or something else that is causing the file not to be included.
<?php
include ('D:\xampp\htdocs\newsite\zend\library\Zend\Version\Version.php');
If your test is more complicated that the above, maybe it's something other than the include path going wrong. Can you post the code that is failing?
Also, you might consider installing the ZF2 Skeleton App, which shows current best practices for setting up autoloading, namespaces, etc.
https://github.com/zendframework/ZendSkeletonApplication
While using Zend Library, make sure
1) You have parent dir of Zend folder in include paths
D:\xampp\htdocs\newsite\zend\library has to be in include paths, not D:\xampp\htdocs\newsite\zend\library\Zend
2) PHP not running in safe mode, also PHP is updated to 5.2+ or 5.3+ and if apc is turned on, it must have apc.include_once_override off.
If still not working, inspect by printing get_include_path() or phpinfo();
That should be it.
I'm trying to get started with unit testing and PHPUnit. I see code here that indicates the way to get started is to include 'PHPUnit/Framework.php' and then create a test case that extends PHPUnit_Framework_TestCase
It looks like that's no longer the way to include PHPUnit but the new docs don't explain what files needed to be included to make PHPUnit work.
What am I missing? When I include 'Framework.php' an error is triggered that tells me no to include that file any longer. 'Autoloader.php' does not work either. When I include files such as 'TestSuiteLoader.php' and others I'll inevitably run into an error that tells me another needed file is missing. I doubt I'm supposed to manually include dozens of files but the docs aren't clear on what I should include yet.
You should include the phpunit library in your php.ini's include_path rather including them manually.
My include path is include_path = ".;C:\wamp\library\phpunit";
I have installed zend framework on my local machine. I have configured a vhost in httpd.conf and have added a line in my hosts file (127.0.0.1 mysite). I am running windows 7. Everything works perfect. The problem is when i upload on a hosting server the paths get mixed up.
I am uploading on a remote dir called zf-framework. To access the index page i need to type this url: http://mysite/zf-framework/public. It displays the index page but when i press any links on the page they get mixed up and end up being something like http://mysite/controller/action when in fact it should be http://mysite/zf-framework/public/controller/action. I have found a work-around for this situation...to use echo $this->baseUrl(link) for any links i have in the layout.phtml. The problem is more serious when it comes to submitting forms. I can't use baseUrl there....or i don't know how to use it. Is there a way to write some general config stuff so that this could be automatically resolved by the framework. Let's say to write something in index.php or bootstrap.php that will fix the paths automatically?
If you're using Zend_Application, then add the following to your configs/application.ini file.
resources.frontController.baseUrl = "/your-path-here"
If you're not using Zend_Application, then do this in your bootstrap, or index.php file.
$front = Zend_Controller_Front::getInstance();
$front->setBaseUrl('/your-path-here');
You won't have to use $this->baseUrl() when submitting a form to the same action and controller (just leave out the action attribute in the form tag), or when using the Redirector action helper. However, links in your view scripts will require you to $this->baseUrl('/url-without-base'), which doesn't seem too bad to me.
I am not 100% on this, but if you specify the route in your routes.ini as zf-framework/public/Controller/Action etc this should fix your issue.
I would see this as a bandaid, but I am not 100% sure on how to properly fix your issue other then you modifying the vhosts file on the remote server to set a document root to the public folder. If that is not an option, well the above should work, but know that all of your files are potentially accessible from everyone (at least your folder structure). I am not sure what harm this can do (if any) other then if your database schema is in the /data directory.
It is better to try and get the public set as the web root, if possible.