Fatal error: Class not found in Zend Framework 2 when deployed in server but not locally
Fatal error: Class not found in Zend Framework 2 when deployed in server but not locally
当我从本地主机使用我的应用程序时,它工作正常,但是当我在服务器中部署应用程序时,出现下一个错误:
致命错误:Class 'PFC\Model\GestoresPFC' 未在第 59 行 /var/www/html/pfpdi/module/PFC/Module.php 中找到
我正在使用具有下一个树结构的模块
- 全氟化碳/
- 配置/
- 源/
- 控制器/
- 表格/
- 型号/
- gestoresPFC.php
- gestoresPFCTable.php
- PFC.php
- PFCTable.php
- 查看/
- autoload_classmap.php
- Module.php
其中 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;
}
}
而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
应该是 GestoresPFC.php
。文件名需要与 class 名称匹配。我猜您是在不区分大小写的文件系统(例如 Windows)上开发此站点的,而这无关紧要。
当我从本地主机使用我的应用程序时,它工作正常,但是当我在服务器中部署应用程序时,出现下一个错误:
致命错误:Class 'PFC\Model\GestoresPFC' 未在第 59 行 /var/www/html/pfpdi/module/PFC/Module.php 中找到
我正在使用具有下一个树结构的模块
- 全氟化碳/
- 配置/
- 源/
- 控制器/
- 表格/
- 型号/
- gestoresPFC.php
- gestoresPFCTable.php
- PFC.php
- PFCTable.php
- 查看/
- autoload_classmap.php
- Module.php
其中 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;
}
}
而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
应该是 GestoresPFC.php
。文件名需要与 class 名称匹配。我猜您是在不区分大小写的文件系统(例如 Windows)上开发此站点的,而这无关紧要。