[英]Fatal error: Class not found in Zend Framework 2 when deployed in server but not locally
When I use my application from localhost it works fine, but when I deploy the application in the server I get the next error: 当我从本地主机使用应用程序时,它可以正常工作,但是当我在服务器中部署应用程序时,出现下一个错误:
Fatal error: Class 'PFC\\Model\\GestoresPFC' not found in /var/www/html/pfpdi/module/PFC/Module.php on line 59 致命错误:在第59行的/var/www/html/pfpdi/module/PFC/Module.php中找不到类'PFC \\ Model \\ GestoresPFC'
I'm using a module with the next tree structure 我正在使用具有下一个树结构的模块
Where gestoresPFC.php is like: gestoresPFC.php类似于:
<?php
namespace PFC\Model;
use Zend\InputFilter\InputFilter;
use Zend\InputFilter\InputFilterAwareInterface;
use Zend\InputFilter\InputFilterInterface;
class GestoresPFC implements InputFilterAwareInterface
{
public $gestor_id;
public $plan_id;
protected $inputFilter; // <-- Add this variable
public function exchangeArray($data)
{
$this->gestor_id = (isset($data['gestor_id'])) ? $data['gestor_id'] : null;
$this->plan_id = (isset($data['plan_id'])) ? $data['plan_id'] : null;
}
public function getArrayCopy()
{
return get_object_vars($this);
}
// Add content to these methods:
public function setInputFilter(InputFilterInterface $inputFilter)
{
throw new \Exception("Not used");
}
public function getInputFilter()
{
if (!$this->inputFilter) {
$inputFilter = new InputFilter();
$inputFilter->add(array(
'name' => 'gestor_id',
'required' => true,
'filters' => array(
array('name' => 'StripTags'),
array('name' => 'StringTrim'),
),
'validators' => array(
array(
'name' => 'StringLength',
'options' => array(
'encoding' => 'UTF-8',
'min' => 1,
'max' => 100,
),
),
),
));
$inputFilter->add(array(
'name' => 'plan_id',
'required' => true,
'filters' => array(
array('name' => 'StripTags'),
array('name' => 'StringTrim'),
),
'validators' => array(
array(
'name' => 'StringLength',
'options' => array(
'encoding' => 'UTF-8',
'min' => 1,
'max' => 11,
),
),
),
));
$this->inputFilter = $inputFilter;
}
return $this->inputFilter;
}
}
And Module.php is like: 而Module.php就像:
<?php
namespace PFC;
use PFC\Model\PFC;
use PFC\Model\PFCTable;
use PFC\Model\GestoresPFC;
use PFC\Model\GestoresPFCTable;
use Zend\Db\ResultSet\ResultSet;
use Zend\Db\TableGateway\TableGateway;
use Zend\ModuleManager\Feature\AutoloaderProviderInterface;
use Zend\ModuleManager\Feature\ConfigProviderInterface;
class Module implements AutoloaderProviderInterface, ConfigProviderInterface
{
public function getAutoloaderConfig()
{
return array(
'Zend\Loader\ClassMapAutoloader' => array(
__DIR__ . '/autoload_classmap.php',
),
'Zend\Loader\StandardAutoloader' => array(
'namespaces' => array(
__NAMESPACE__ => __DIR__ . '/src/' . __NAMESPACE__,
),
),
);
}
public function getConfig()
{
return include __DIR__ . '/config/module.config.php';
}
public function getServiceConfig()
{
return array(
'factories' => array(
'PFC\Model\PFCTable' => function($sm) {
$tableGateway = $sm->get('PFCTableGateway');
$table = new PFCTable($tableGateway);
return $table;
},
'PFCTableGateway' => function ($sm) {
$dbAdapter = $sm->get('Zend\Db\Adapter\Adapter');
$resultSetPrototype = new ResultSet();
$resultSetPrototype->setArrayObjectPrototype(new PFC());
return new TableGateway('plan_formacion', $dbAdapter, null, $resultSetPrototype);
},
'PFC\Model\GestoresPFCTable' => function($sm) {
$tableGateway = $sm->get('GestoresPFCTableGateway');
$table = new GestoresPFCTable($tableGateway);
return $table;
},
'GestoresPFCTableGateway' => function ($sm) {
$dbAdapter = $sm->get('Zend\Db\Adapter\Adapter');
$resultSetPrototype = new ResultSet();
$resultSetPrototype->setArrayObjectPrototype(new GestoresPFC());
return new TableGateway('gestores', $dbAdapter, null, $resultSetPrototype);
},
),
);
}
}
gestoresPFC.php
should be GestoresPFC.php
. gestoresPFC.php
应该是GestoresPFC.php
。 The filename needs to match the class name. 文件名需要与类名匹配。 I'm guessing you developed this site on a case-insensitive file system (eg Windows) where this wouldn't matter.
我猜您是在不区分大小写的文件系统(例如Windows)上开发此站点的,这无关紧要。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.