Can Zend_Loader_Autoloader be called with an object-oriented syntax?

124 Views Asked by At

Is there an alternate way of calling Zend's Framework Autoloader. I have this webpage where I load the Zend_Loader_Autoloader and then call the static method ::getInstance(). After having a lot of trouble wondering why my scripts do not work, I set up a test like this:

<?php 
$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&iacute;a Zend Framework cargada"; else echo "Error al cargar la librer&iacute;a";

Which outputs "Error al cargar la librería".

I also have implemented the script installlationchecker.php to which I added the first two lines of that previous code, and, having installed Zend Framework on a sister folder to the public folder, the installation test passes.

But my question is, can I call the Autoloader like an object, say:

$libload = New Zend_Loader_Autoloader();

$libload->getInstance();

There seems to be nothing in Zend Framework's documentation about this alternate syntax.

I'm intending to do this because the library doesn't load on several scripts where I need it, and this only happens on the remote server, on my testing server it works fine. I put a test like this:

include ('header.php');
//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!');
echo ('<div class="cuerpo"><div class="mensajes">');
if(isset($_POST['autoresArt'])&&isset($_POST['tituloArt'])&&isset($_POST['correoArt'])&&isset($_POST['descArt'])) {
require_once('libreria.php');

to see if there's a capitalization problem with my scripts (which were developed on windows) and the scripts in the Linux server, however there seems to be not a problem.

By the way, the only code that is outputted before requiring or including the library is 'header.php' which is just the html document to show the output, plus some javascript to control it.

P.D. I'm sorry I've checked it out and as Matt says it is outputting that the library is set. However I've been trying to get this code to work for days and since it fails in the remote server while not on my testing server I guessed the Zend Framework library wasn't being loaded. In fact, it wasn't, it was just today that I set it up right in a sister folder to the public folder and called the test script to be sure.

However, the code I set in the script doesn't run properly, it is something like:

if(isset($_POST['nombreUs'])) {
$nombreUsuario = reemplaza_blancos($_POST['nombreUs']);
$nombreUsuario = trim($nombreUsuario);
$nombreUsuario = mysql_real_escape_string($nombreUsuario);
$validaDos = new Zend_Validate_Regex('/^([[:alpha:]]|[ÁÉÍÓÚÑñáéíóúÄËÏÖÜäëïöü])[[:alpha:]]|[ÁÉÍÓÚÑñáéíóúÄËÏÖÜäëïöü]+\s?([[:alpha:]][ÁÉÍÓÚÑñáéíóúÄËÏÖÜäëïöü])?/');
if(!$validaDos->isValid($nombreUsuario)) {
$errors ['nombre'] = "El nombre no puede contener n&uacute;meros";  
}
}

and then I check if(empty($errors)) then call and run the PHPMailer class.

It makes me mindnumb to see that this script simply does not run properly

1

There are 1 best solutions below

0
On

You cannot have

$libload = New Zend_Loader_Autoloader();

simply because the constructor is declared as protected method.

protected function __construct()

So no, you cannot.