Ubuntu + Netbeans - Zend framework fatal error due to Include path - php

I'm experiencing a problem with my 'include' path on my fresh install of Zend framework. i'm running Ubuntu and using Netbeans. I installed Zend via the terminal and I have copied the appropriate files to my new project.
I am currently getting this while attempting to access localhost/demoZend/public
Warning: require_once(Zend/Application.php): failed to open stream: No such file or directory in /home/mastered/public_html/demoZend/public/index.php on line 18
Fatal error: require_once(): Failed opening required 'Zend/Application.php' (include_path='/home/mastered/public_html/demoZend/library:.:/opt/lampp/lib/php') in /home/mastered/public_html/demoZend/public/index.php on line 18
I have copied the 'Zend' folder with the framework into my project/library folder so the folder structure is /demoZend/library/Zend/
I have also changed the 'include' path in my php.ini from the advice of a tutorial. however this is where I have things confused.
The path reads:
include_path = ".:/usr/share/php:/usr/share/php/libzend-framework-php/"
in my apache2/php.ini aswell as my /etc/php5/cli/php.ini file.
My index.php file in my project reads as thus:
<?php
// Define path to application directory
defined('APPLICATION_PATH')
|| define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../application'));
// Define application environment
defined('APPLICATION_ENV')
|| define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production'));
// Ensure library/ is on include_path
set_include_path(implode(PATH_SEPARATOR, array(
realpath(APPLICATION_PATH . '/../library'),
get_include_path(),
)));
/** Zend_Application */
require_once 'Zend/Application.php';
// Create application, bootstrap, and run
$application = new Zend_Application(
APPLICATION_ENV,
APPLICATION_PATH . '/configs/application.ini'
);
$application->bootstrap()
->run();
I haven't changed that as the file paths seem ok.
I should also point out I have my web documents stored in my '~/public_html' directory, I have checked the permissions on my 'demoZend/library' folder and they have all restrictions off.

It sounds like you're following a tutorial for Zend Framework 1, but you've downloaded Zend Framework 2. There is no Zend/Application.php in ZF2, so that's why PHP isn't finding the file.
You can either head back to the ZF downloads page and grab the latest release of ZF1 (currently 1.12.3), or find a ZF2 tutorial and learn ZF2 instead. If you're just getting started with ZF, I'd go with the latter option.

Related

Netbeans: How to configure a remote server's PHPUnit path?

I use the latest version of Netbeans on Windows, and connect to a remote Ubuntu Apache server to a Zend Framework project. I installed on that server PHPUnit, but I didn't know what is the absolute path to the phpunit.bat (I need th absolute path in NetBeans Option->Php->Unit Testing). I installed XAMPP on my computer and tried to use PHPUnit within XAMPP and the project from the remote server, but I have problems with the include paths, for example I get this error:
'Warning: include_once(PHP\Invoker.php): failed to open stream: No
such file or directory in Y:\mos\public_html\library\Zend\Loader.php
on line 146'.
Here is my bootstrap.php file:
<?php
error_reporting( E_ALL | E_STRICT );
ini_set('display_startup_errors', 1);
ini_set('display_errors', 1);
define('APPLICATION_PATH', realpath('Y:/mos/public_html' . '/application'));
define('APPLICATION_ENV', 'development');
define('LIBRARY_PATH', realpath('Y:/mos/public_html' . '/library'));
define('TESTS_PATH', realpath(dirname(__FILE__)));
$_SERVER['SERVER_NAME'] = 'http://mos.loc';
$includePaths = array(LIBRARY_PATH, get_include_path());
set_include_path(implode(PATH_SEPARATOR, $includePaths));
require_once "Zend/Loader/Autoloader.php";
$loader = Zend_Loader_Autoloader::getInstance();
$loader->setFallbackAutoloader(true);
$loader->suppressNotFoundWarnings(false);
Zend_Session::$_unitTestEnabled = true;
Zend_Session::start();
?>
Can I set somehow the absolute path to the PHPUnit on the remote server from Netbeans, or can I make it work using the project from the remote server, and PHPUnit from my XAMPP?
Perhaps your mapped network drive isn't mapped under whatever account is running the web server.
Under your own account, check what the mapping is for your Y drive:
C:\>net use
The output should be something like this:
New connections will not be remembered.
Status Local Remote Network
-------------------------------------------------------------------------------
OK Y: \\server\share Microsoft Windows Network
Then modify your PHP script to attempt to map the drive for your scripting purposes:
<?php system("net use Y: \\server\share password /user:username /persistent:no >nul 2>&1"); ?>

problems after hosting a zend framwork project

After hosting my website, I had some configuration issues.
Warning: require_once (Zend/application.php) [function.require-once]: failed to open stream: No such file or directory in //www/***.com/public/index.php on line 22
I placed the Zend Framewotk library in www/library
www/application/
www/library/ <--- Zend Framework
www/public/
but after the addition of library another problem occurs:
HTTP Error 500 (Internal Server Error): An unexpected condition has occurred while the server was attempting to fulfill the request.
Script of public/index.php
<?php
// Define path to application directory
defined('APPLICATION_PATH')
|| define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../application'));
// Define application environment
defined('APPLICATION_ENV')
|| define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production'));
defined('TMP_PATH')
|| define('TMP_PATH', realpath(APPLICATION_PATH . '/../tmp/'));
// Ensure library/ is on include_path
set_include_path(implode(PATH_SEPARATOR, array(
realpath(APPLICATION_PATH . '/../library'),
APPLICATION_PATH . '/models',
APPLICATION_PATH . '/models/generated',
get_include_path(),
)));
/** Zend_Application */
require_once 'Zend/Application.php';
// Create application, bootstrap, and run
$application = new Zend_Application(
APPLICATION_ENV,
APPLICATION_PATH . '/configs/application.ini'
);
$application->bootstrap()
->run();
$application->bootstrap()->run(); does nothing Comeback
Do you have a .htaccess configured corretly for that new hosting?
Error 500 is normally a server error, try to take a look in the
.htaccess.
Cheers,
Hugo
Warning: require_once (Zend/application.php) [function.require-once]: failed to open stream: No such file or directory in //www/*.com/public/index.php on line 22
At first glance, it seems like a case-sensitivity issue: note the lowercase a in Zend/application.php.
However, your public/index.php seems to contain the correct:
require_once 'Zend/Application.php'
and the correct instantiation
$application = new Zend_Application(
APPLICATION_ENV,
APPLICATION_PATH . '/configs/application.ini'
);
so there would be no need for the autoloader to try and load a class with the lower-case a.
Have you faithfully copied/pasted all the errors and code? Or might there be a transcription error in there somewhere?

Zend Framework Error: Failed opening required 'Zend/Application.php'

I get the following error when I try to run the project created by Zend Framework. Its looking for Zend/Application.php and that is available in the directory that is in my include_path. I do have read permissions on the directory.
PHP Fatal error: require_once() [function.require]:
Failed opening required 'Zend/Application.php'
(include_path='/var/www/vhosts/moderncloud.net/om/library:.:/var/www/vhosts/moderncloud.net/om
/library:') in /var/www/vhosts/moderncloud.net/om/public/index.php on
line 24
<?php
// Define path to application directory
//defined('APPLICATION_PATH')
// || define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../application'));
defined('APPLICATION_PATH')
|| define('APPLICATION_PATH', dirname(__FILE__) . '/../application');
// Define application environment
defined('APPLICATION_ENV')
|| define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production'));
// Ensure library/ is on include_path
set_include_path(implode(PATH_SEPARATOR, array(
('/var/www/vhosts/moderncloud.net/om/library'),
get_include_path(),
)));
/** Zend_Application */
require_once 'Zend/Application.php';
// Create application, bootstrap, and run
$application = new Zend_Application(
APPLICATION_ENV,
APPLICATION_PATH . '/configs/application.ini'
);
$application->bootstrap()
->run();
SOLUTION:
I found it myself today. Its a problem with the option
"php_admin_value open_basedir" in my httpd configuration. I set it to
none and it started working. Alternatively, I guess I can append the Zend library
directory to the open_basedir option in my web server configuration instead of setting it to none.
Can you try replacing:
set_include_path(implode(PATH_SEPARATOR, array(
('/var/www/vhosts/moderncloud.net/om/library'),
get_include_path(),
)));
with
$siteRootDir = dirname($_SERVER['DOCUMENT_ROOT']);
set_include_path(
$siteRootDir . '/library' . PATH_SEPARATOR
. $siteRootDir . '/application' . PATH_SEPARATOR
. get_include_path()
);
Hope it works for you
If possible, remove the existing zend framework installation and install ZF using PEAR. It will be easier to update later on:
pear channel-discover zend.googlecode.com/svn
pear install zend/zend
It will also use PEAR's include_path, so it should solve your problem.
If you can't use pear, try to use relative path with your include path:
// Ensure library/ is on include_path
set_include_path(implode(PATH_SEPARATOR, array(
realpath(APPLICATION_PATH . '/../library'),
get_include_path(),
)));
This problem generated due to :
Inside Public folder in index.php file.
or
Inside library folder :- Just check in library folder there is a folder of Zend present in library folder or not.If not present zend folder then download from zend framework and save in library folder.
=> In index.php copy the following code and replace it.
<?php
// Define path to application directory
defined('APPLICATION_PATH')
|| define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/application'));
// Define application environment
defined('APPLICATION_ENV')
|| define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production'));
// Ensure library/ is on include_path
set_include_path(implode(PATH_SEPARATOR, array(
realpath(APPLICATION_PATH . '/../library'),
get_include_path(),
)));
/** Zend_Application */
//require_once 'Zend/Application.php';
require_once 'library/Zend/Application.php';
// Create application, bootstrap, and run
$application = new Zend_Application(
APPLICATION_ENV,
APPLICATION_PATH . '/configs/application.ini'
);
$application->bootstrap()
->run();

publishing zend website issue on goDaddy.com

I'm trying to move my zend application from local to remote.After I uploaded all of my folders on my GoDaddy host this is my folders structure :
/html
/application
/configs
/controllers
/models
/views
bootstrap.php
/library
/public
/css
/images
/js
.htaccess
index.php
my index.php :
// Define path to application directory
defined('APPLICATION_PATH')
|| define('APPLICATION_PATH',realpath(dirname(__FILE__) . '/../application'));
// Define application environment
defined('APPLICATION_ENV')|| define('APPLICATION_ENV',
(getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV'): 'production'));
//add library directory to include path
set_include_path(implode(PATH_SEPARATOR, array(
dirname(dirname(__FILE__)) . '/library',dirname(dirname(__FILE__)) .
'/application/models',dirname(dirname(__FILE__)) .
'/application/forms',dirname(dirname(__FILE__)) . '/application/views/scripts',
get_include_path())));
/** Zend_Application */
require_once 'Zend/Application.php';
// Create application, bootstrap, and run
$application = new Zend_Application(
APPLICATION_ENV,
APPLICATION_PATH . '/configs/application.ini');
$application->bootstrap()->run();
Now if I try to go type this URL : "www.mysite.com/public/index/index" I receive this error :
The requested URL /public/index/index/ was not found on this server.
Additionally, a 404 Not Found error was encountered while trying
to use an ErrorDocument to handle the request.
And if I just type : "www.mysite.com/public/" I receive this warning :
Warning: require_once(/home/content/66/6902756/html/application/Bootstrap.php
[function.require-once]: failed to open stream: No such file or directory
in /home/content/66/6902756/html/library/Zend/Application.php on line 320
Fatal error: require_once() [function.require]: Failed opening
required '/home/content/66/6902756/html/application/Bootstrap.php'
(include_path='/home/content/66/6902756/html/application/../library:
/home/content/66/6902756/html/library:
/home/content/66/6902756/html/application/models:
/home/content/66/6902756/html/application/forms:
/home/content/66/6902756/html/application/views/scripts:
.:/usr/local/php5/lib/php')
in /home/content/66/6902756/html/library/Zend/Application.php on line 320
In local everything was working properly
UPDATE
In my index.php I tried :
//it output "exists"
echo file_exists( '/home/content/66/6902756/html/application/Bootstrap.php' )?'exists':'no file found';
//where '/home/content/66/6902756/html' is my absolute hosting path
thanks
I'll wager that a major part of your problem is that you're using \ in your include path. Try replacing those with the constant DIRECTORY_SEPARATOR. Personally, I would get rid of all of those dirname(dirname(__FILE__)). Instead use the built in APPLICATION_PATH:
set_include_path(implode(PATH_SEPARATOR, array(
dirname( APPLICATION_PATH ) . DIRECTORY_SEPARATOR . 'library', //note one exception
APPLICATION_PATH. DIRECTORY_SEPARATOR . 'models',
APPLICATION_PATH. DIRECTORY_SEPARATOR . 'forms',
APPLICATION_PATH. DIRECTORY_SEPARATOR . 'views'. DIRECTORY_SEPARATOR .'scripts',
get_include_path())));

ZEND Classes are not loading on Production server

I shifted the site from shared server to dedicated server but the site is not working correctly. I am getting the error as "Fatal error: Uncaught exception 'Zend_Db_Adapter_Exception' with message 'The PDO extension is required for this adapter but the extension is not loaded' in ";
Result for:
if (extension_loaded('pdo') and extension_loaded('pdo_mysql')) {
print "Success";
} else {
print "Failure";
}
is also false.
------Index File------
<?php
// Define path to application directory
defined('APPLICATION_PATH')
|| define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../application'));
// Define application environment
defined('APPLICATION_ENV')
|| define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production'));
// Ensure library/ is on include_path
set_include_path(implode(PATH_SEPARATOR, array(
realpath(APPLICATION_PATH . '/../library'),
get_include_path(),
)));
/** Zend_Application */
require_once 'Zend/Application.php';
// Create application, bootstrap, and run
$application = new Zend_Application(
APPLICATION_ENV,
APPLICATION_PATH . '/configs/application.ini'
);
$application->bootstrap()
->run();
Link of the site: http://voxsun.com
phpinfo of site: http://voxsun.com/public/info.php
Thanks,
Lalit
In the first line of your phpinfo() we can read:
'./configure' '--disable-pdo'
Well, it's self-explanatory.
If you compiled PHP yourself, I really advise you to use your package manager to do so (aptitude, yum, etc.), it'll ease your system upgrade and avoid you to compile it hand each time you need to update PHP.
Do it only if you've very good reasons.
From the you're info.php ... Configure Command './configure' '--disable-pdo' so put it simple, php wasn't compiled with pdo in mind .
One option would be to try and load the extensions manualy in public/index.php at the start of you're script ( i don't expect it to work but it's worth giving it a try ) :
dl('pdo.so');
dl('pdo_mysql.so');
PHP: dl - Loads a PHP extension at runtime

Categories