Zend Failed opening required 'Zend/Loader.php' on Plesk Server - php

I am getting the following warning and error on a plesk server where I am trying to get the Zend framework working:
PHP Warning: require_once(Zend/Loader.php) [function.require-once]: failed to open stream: No such file or directory in /var/www/vhosts/mydomain.com/httpdocs/test.php on line 5
PHP Fatal error: require_once() [function.require-once]: Failed opening required 'Zend/Loader.php' (include_path='.:/usr/share/pear:/local/PEAR/:/usr/share/zend') in /var/www/vhosts/mydomain.com/httpdocs/test.php on line 5
I have set the include_path in the php.ini file (/etc/php.ini) to use the directory where I have added the Zend files (/usr/share/zend). This directory then has the framework in a sub-dir called Zend.
I have tried adding a slash to the end of the include_path (/usr/share/zend/).
The path is present when I use get_include_path()
I have tried using set_include_path.
The /usr/share/zend directory has 775 permissions (also tried with 777) and the user and group are both set to root.
I would like to have the framework available to all sites on the server.
I have copied in the Gdata files too and the Zend/Loader.php is there.
Versions:
Framework: 2.0.4
Gdata: 1.12.0
This is the PHP:
require_once("Zend/Loader.php");
I have also tried using:
require_once("/usr/share/zend/Zend/Loader.php");
I am novice plesk/unix user

The things to check for are:
The file exists where PHP is looking for it.
The file is readable by the web server/php_fpm process.
safe_mode is off!
(Putting the information here - so that the question can be marked as answered!)

Zend/Loader.php is for ZF1 and that file don't exists with ZF2 (2.0.4)
Also you need to download the updated version of GData compatible with ZF2
https://github.com/zendframework/ZendGData
If you'll use Composer to setup your dependencies then you should use require_once __DIR__ . '/path/to/vendor/autoload.php

Related

`require` is not working in php

This is the error which i am fetching right now.
PHP Fatal error: require(): Failed opening required '/base/data/home/apps/s~civic-planet-191520/20180221t115719.407805658953142647/web-service/web/../vendor/autoload.php' (include_path='.;/base/data/home/apps/s~civic-planet-191520/20180221t115719.407805658953142647/;/base/php_experiment_runtime/sdk')
My autoload.php file is placed in vendor directory , and i am loading autoload.php file from web/index.php file . Web and vendor directory both are at same lavel. Check below screenshot.
I am using this php code for load autoload.php file.
require __DIR__."/../vendor/autoload.php";
I have also try:
require(__DIR__. '/../vendor/autoload.php');
My project is load on google app engine.
Install the Composer executable globally for the dependency management
the same as it is done in this Google PHP quickstart.

Running Fuel Php in Azure

I am trying to move a website from an apache2 site to an Azure hosted site.
I configure Azure as a PHPWebsite. I copied the contents of my site into the Azure site.
I installed Pear PHP Not sure why but I was advised to do it.
I then ran
php composer.phar self-update
and
php composer.phar update
and installed FuelPHP.
Now I am getting this error
Warning: require(\classes\autoloader.php): failed to open stream: No such file or directory in D:\home\site\wwwroot\app\bootstrap.php on line 4 Fatal error: require(): Failed opening required '\classes\autoloader.php' (include_path='.;C:\php\pear') in D:\home\site\wwwroot\app\bootstrap.php on line 4
Any idea how to fix this?
Thanks.
The path \classes\... will find to the absolute path \classes\autoloader.php in the file system in the windows OS, which is not the actual file path.
We need to relative path classes\autoloader.php or absolute full path __DIR__."\classes\autoloader.php" if the file path "classes\autoloader.php" is in the same directory with the bootstrap.php.
Additionally, we can have a simple test on Azure Web Apps to verify the issue:
if you have a classes folder with autoloader.php file and the folder is in the same directory with the test script,
echo realpath('\classes\autoloader.php'); will return empty
echo realpath('classes\autoloader.php'); will return the right full path

Zend - error in index.php - not opening Zend/Application.php

I have a project written in PHP, in zend framework. But when i go on page: localhost/Project/public, i get an error:
Warning: require_once(Zend/Application.php): failed to open stream: No such file or directory in /var/www/Project/public/index.php on line 18 Fatal error: require_once(): Failed opening required 'Zend/Application.php' (include_path='/var/www/Project/library:.:/usr/share/php:/usr/share/pear') in /var/www/Project/public/index.php on line 18
The line 18 in file index.php is following:
require_once 'Zend/Application.php';
I have set include_path in php.ini:
include_path = ".:/usr/share/php:/usr/local/ZendFramework/library"
Zf project is successfully creating by commands from console, so i think that Zend is well configured (anyway in php.ini).
Help me! What I'm doing wrong?
You can see the include path it's using in the error, and it doesn't include /usr/local/ZendFramework/library. Typically index.php overrides the include path to point it at the project's library folder. So either you want a copy of ZF in the library folder, or if you prefer to keep ZF in /usr/local/ you want to edit this include path to point at /usr/local/ZendFramework/library as well.

Zend Framework include path error in ubuntu

I have developed a Zend Framework application, which works well on xammp and windows. Now I want to transfer this application to a new ubuntu web server. However I get the following warning:
Warning: include_once(Zend/Navigation/Page/MVC.php): failed to open stream: No such file or directory in /var/www/library/Zend/Loader.php on line 146 Warning: include_once(): Failed opening 'Zend/Navigation/Page/MVC.php' for inclusion (include_path='/var/www/application/../library/:/var/www/library:.:/usr/share/php:/usr/share/pear') in /var/www/library/Zend/Loader.php on line 146 Fatal error: Class 'Zend_Navigation_Page_MVC' not found in /var/www/application/ext/views/NavigationCreator.php on line 34
So the Autoloader seems not to find the Zend library classes. My library is really at /var/www/library, my application at /var/www/application. I did sudo chmod -R 777 /var/www to rule out any permission issues.
I know that there are several related posts at SO, but non has helped me so far. Do you have any suggestions how to fix my problem?
Class name should be Zend_Navigation_Page_Mvc not Zend_Navigation_Page_MVC (note the difference in capitalization).
Whenever you move a project from windows system to a linux based one, these are common errors you might get. Because file names are case sensitives in linux. So, always check if the file exists and with the correct case.

How to include the PEAR php packages on a MAC when changed include path in .htaccess

I'm trying to use the Text_Password class of PEAR but am not sure how to include it.
I have installed PEAR. And I'm guessing it has put the classes somewhere in the PHP directory. I have this in my .htaccess file
php_value include_path .:/Library/WebServer/Documents/phpweb20/include
Which is why I'm guessing it isn't picking them up. Does anyone know how i can include the PEAR classes?
Here is the error messageI get:
Warning: include_once(Text/Password.php) [function.include-once]: failed to open stream: No such file or directory in /Library/WebServer/Documents/phpweb20/include/Zend/Loader.php on line 146
Warning: include_once() [function.include]: Failed opening 'Text/Password.php' for inclusion (include_path='.:/Library/WebServer/Documents/phpweb20/include') in /Library/WebServer/Documents/phpweb20/include/Zend/Loader.php on line 146
Fatal error: Class 'Text_Password' not found in /Library/WebServer/Documents/phpweb20/include/DatabaseObject/User.php on line 25
The reason I have changed my .htaccess file is because I am using the Zend framework. I put the Zend classes in the include folder. Can I do something similar for PEAR?
Thanks a lot!
Jonesy
You can set multiple folders, see: http://php.net/manual/en/function.set-include-path.php
Example 2 will probably best suit your needs. You can also do that in your php ini file.

Categories