问题描述
我按照以下和我时遇到的问题。我访问的网址为本地主机/ EPOS 的和索引页工作正常。但是,如果我做的本地主机/ EPOS / pgeline2d 的我得到错误
时发生错误
找不到网页
异常信息:消息:指定无效的控制器(EPOS)
堆栈跟踪:#0 /opt/eposdatatransfer/library/Zend/Controller/Front.php(954):Zend_Controller_Dispatcher_Standard->讯(对象(的Zend_Controller_Request_Http),对象(Zend_Controller_Response_Http))
#1 /opt/eposdatatransfer/library/Zend/Application/Bootstrap/Bootstrap.php(97):Zend_Controller_Front->调度()
#2 /opt/eposdatatransfer/library/Zend/Application.php(366):Zend_Application_Bootstrap_Bootstrap->运行()
#3 /opt/eposdatatransfer/public/index.php(26):Zend_Application->运行()
#4 {}主力请求参数:阵列(
控制器=> 史诗,
'行动'=> 留言本,
'模块'=> '默认',
)
在我的SQLLite数据库表名叫做PGE_Line2D。下面是我的文件:
的httpd.conf
别名/ EPOS的/ opt / eposdatatransfer /公<目录的/ opt / eposdatatransfer /公众>
选择多视图索引了FollowSymLinks
所有的AllowOverride
为了允许,拒绝
所有允许
< /目录>
应用程序/ CONFIGS /的application.ini
[制作]
phpSettings.display_startup_errors = 0
phpSettings.display_errors = 0
includePaths.library = APPLICATION_PATH/../library
bootstrap.path = APPLICATION_PATH/Bootstrap.php
bootstrap.class =引导
appnamespace =应用程序
resources.frontController.controllerDirectory = APPLICATION_PATH/控制器
resources.frontController.params.displayExceptions = 0
phpSettings.date.timezone =欧洲/伦敦
resources.db.adapter =PDO_SQLITE
resources.db.params.dbname = APPLICATION_PATH/../data/db/h3111142.db[分期:生产][测试:制作]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1[开发:生产]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1
resources.frontController.params.displayExceptions = 1
应用程序/ bootstrap.php中
类扩展自举Zend_Application_Bootstrap_Bootstrap {}
应用程序/视图/脚本/指数/ index.phtml
你好
应用程序/视图/脚本/ PGE线-2D / index.phtml
< BR />< BR />
< DIV ID =查看内容>
< P>作为控制器和LT查看脚本; B> PgeLine2D< / B>和脚本/动作名称< B>指数< / B>< / P>
?< PHP的foreach($这个 - >条目$项):>
< DT>< PHP的echo $这个 - >逃生($入门> pga_id)GT;< / DT>
<?PHP endforeach>
< / DIV>
应用程序/模型/ PGLine2D.php
类Application_Model_PgeLine2D
{
保护$ _PGA_Id;
保护$ _PGA_Name; 公共职能__construct(数组$选项= NULL)
{
如果(is_array($选项)){
$这个 - > setOptions($选项);
}
} 公共职能__set($名称,$值){
$方法='设置'。 $名称;
如果(('映射'== $名)||!method_exists($此,$法)){
抛出新的异常(无效套PgeLine2D财产);
}
$这个 - > $法($值);
} 公共职能__get($名){
$方法='得到'。 $名称;
如果(('映射'== $名)||!method_exists($此,$法)){
抛出新的异常(无效获得PgeLine2D财产);
}
返回$这个 - > $()的方法;
} 公共职能setOptions(数组$选项)
{
$方法= get_class_method(0函数$本);
的foreach($选项,$关键=> $值){
$方法='设置'。 ucfirst($键);
如果(in_array($方法,$方法)){
$这个 - > $法($值);
}
}
返回$这一点;
} 公共职能setPGA_Id($ ID){
$这个 - > PGA_Id = $ ID;
返回$这一点;
} 公共职能getPGA_Id(){
返回$这个 - > PGA_Id;
} 公共职能setPGA_Name($名){
$这个 - > PGA_Name = $名称;
返回$这一点;
} 公共职能getPGA_Name(){
返回$这个 - > PGA_Name;
}
}
应用程序/模型/ PGLine2DMapper.php
类Application_Model_PgeLine2DMapper
{
保护$ _dbTable; 公共职能setDbTable($ DBTABLE)
{
如果(IS_STRING($ DBTABLE)){
$ DBTABLE =新的$ DBTABLE();
}
如果(!$ DBTABLE的instanceof Zend_Db_Table_Abstract){
扔(无效的表数据网关提供')新的异常;
}
$这个 - > _dbTable = $ DBTABLE;
返回$这一点;
} 公共职能getDbTable()
{
如果(空=== $这个 - > _dbTable){
$这个 - > setDbTable('Application_Model_DbTable_PgeLine2D');
}
返回$这个 - > _dbTable;
} 公共职能保存(Application_Model_PgeLine2D $ pgeLine2D)
{
$数据=阵列(
PGA_Name'=> $ pgeLine2D-> getPGA_Name()
); 如果(NULL ===($ n = $ pgeLine2D-> getPGA_Id())){
未设置($数据['身份证']);
$这个 - > getDbTable() - GT;插入($的数据);
}其他{
$这个 - > getDbTable() - GT;更新($的数据,阵列('?PGA_Id ='= GT;的$ id));
}
} 公共职能的发现($ ID,Application_Model_PgeLine2D $ pgeLine2D)
{
$结果= $这个 - > getDbTable() - GT;找到($ ID);
如果(0 ==计数($结果)){
返回;
}
$行= $ result->电流();
$ pgeLine2D-> setPGA_Id($行向> PGA_Id)
- > setPGA_Name($行向> PGA_Name);
} 公共功能使用fetchall()
{
$的resultSet = $这个 - > getDbTable() - GT;使用fetchall();
$项=阵列();
的foreach($ ResultSet作为$行){
$进入=新Application_Model_PgeLine2D();
$入门级GT&; setPGA_Id($行向> PGA_Id)
- > setPGA_Name($行向> PGA_Name);
$项[] = $进入;
}
返回$条目;
}}
应用程序/模型/ DBTABLE / PGLine2D.php
类Application_Model_DbTable_PgeLine2D扩展Zend_Db_Table_Abstract
{ 保护$ _name ='PGE_Line2D';
}
应用程序/控制器/ PgeLine2DController.php
类PgeLine2DController扩展化Zend_Controller_Action
{ 公共职能的init()
{
/ *在这里初始化动作控制器* /
} 公共职能的indexAction()
{
//动作体
$ pgeLine2D =新Application_Model_PgeLine2DMapper();
$这个 - >取景>项= $ pgeLine2D->使用fetchall();
}
}
当您使用别名,而不是新的领域,你必须添加
resources.frontController.baseUrl =/ EPOS
要你的config.ini文件。
I have followed the following documentation and I am having problems. I access the url as localhost/epos and the index page works fine. but if i do localhost/epos/pgeline2d i get error
An error occurred
Page not found
Exception information:
Message: Invalid controller specified (epos)
Stack trace:
#0 /opt/eposdatatransfer/library/Zend/Controller/Front.php(954): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http))
#1 /opt/eposdatatransfer/library/Zend/Application/Bootstrap/Bootstrap.php(97): Zend_Controller_Front->dispatch()
#2 /opt/eposdatatransfer/library/Zend/Application.php(366): Zend_Application_Bootstrap_Bootstrap->run()
#3 /opt/eposdatatransfer/public/index.php(26): Zend_Application->run()
#4 {main}
Request Parameters:
array (
'controller' => 'epos',
'action' => 'guestbook',
'module' => 'default',
)
The table name in my SQLLite db is called "PGE_Line2D". Below are my files:
httpd.conf
Alias /epos "/opt/eposdatatransfer/public"
<Directory "/opt/eposdatatransfer/public">
Options Indexes MultiViews FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
application/configs/application.ini
[production]
phpSettings.display_startup_errors = 0
phpSettings.display_errors = 0
includePaths.library = APPLICATION_PATH "/../library"
bootstrap.path = APPLICATION_PATH "/Bootstrap.php"
bootstrap.class = "Bootstrap"
appnamespace = "Application"
resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers"
resources.frontController.params.displayExceptions = 0
phpSettings.date.timezone = "Europe/London"
resources.db.adapter = "PDO_SQLITE"
resources.db.params.dbname = APPLICATION_PATH "/../data/db/h3111142.db"
[staging : production]
[testing : production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1
[development : production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1
resources.frontController.params.displayExceptions = 1
application/bootstrap.php
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap {}
application/views/scripts/index/index.phtml
hello
application/views/scripts/pge-line-2d/index.phtml
<br /><br />
<div id="view-content">
<p>View script for controller <b>PgeLine2D</b> and script/action name <b>index</b></p>
<?php foreach ($this->entries as $entry): ?>
<dt><?php echo $this->escape($entry->pga_id) ?></dt>
<?php endforeach ?>
</div>
application/models/PGLine2D.php
class Application_Model_PgeLine2D
{
protected $_PGA_Id ;
protected $_PGA_Name ;
public function __construct(array $options = null)
{
if (is_array($options)) {
$this->setOptions($options);
}
}
public function __set($name, $value){
$method = 'set' . $name;
if (('mapper' == $name) || !method_exists($this, $method)) {
throw new Exception('Invalid set PgeLine2D property');
}
$this->$method($value);
}
public function __get($name){
$method = 'get' . $name;
if (('mapper' == $name) || !method_exists($this, $method)) {
throw new Exception('Invalid get PgeLine2D property');
}
return $this->$method();
}
public function setOptions(array $options)
{
$methods = get_class_methods($this);
foreach ($options as $key => $value) {
$method = 'set' . ucfirst($key);
if (in_array($method, $methods)) {
$this->$method($value);
}
}
return $this;
}
public function setPGA_Id($id){
$this->PGA_Id = $id;
return $this;
}
public function getPGA_Id(){
return $this->PGA_Id;
}
public function setPGA_Name($name){
$this->PGA_Name = $name;
return $this;
}
public function getPGA_Name(){
return $this->PGA_Name;
}
}
application/models/PGLine2DMapper.php
class Application_Model_PgeLine2DMapper
{
protected $_dbTable;
public function setDbTable($dbTable)
{
if (is_string($dbTable)) {
$dbTable = new $dbTable();
}
if (!$dbTable instanceof Zend_Db_Table_Abstract) {
throw new Exception('Invalid table data gateway provided');
}
$this->_dbTable = $dbTable;
return $this;
}
public function getDbTable()
{
if (null === $this->_dbTable) {
$this->setDbTable('Application_Model_DbTable_PgeLine2D');
}
return $this->_dbTable;
}
public function save(Application_Model_PgeLine2D $pgeLine2D)
{
$data = array(
'PGA_Name' => $pgeLine2D->getPGA_Name()
);
if( null === ($id = $pgeLine2D->getPGA_Id()) ) {
unset($data['id']);
$this->getDbTable()->insert($data);
} else {
$this->getDbTable()->update($data, array('PGA_Id = ?' => $id));
}
}
public function find($id, Application_Model_PgeLine2D $pgeLine2D)
{
$result = $this->getDbTable()->find($id);
if (0 == count($result)) {
return;
}
$row = $result->current();
$pgeLine2D->setPGA_Id($row->PGA_Id)
->setPGA_Name($row->PGA_Name);
}
public function fetchAll()
{
$resultSet = $this->getDbTable()->fetchAll();
$entries = array();
foreach ($resultSet as $row) {
$entry = new Application_Model_PgeLine2D();
$entry->setPGA_Id($row->PGA_Id)
->setPGA_Name($row->PGA_Name);
$entries[] = $entry;
}
return $entries;
}
}
application/models/DbTable/PGLine2D.php
class Application_Model_DbTable_PgeLine2D extends Zend_Db_Table_Abstract
{
protected $_name = 'PGE_Line2D';
}
application/controllers/PgeLine2DController.php
class PgeLine2DController extends Zend_Controller_Action
{
public function init()
{
/* Initialize action controller here */
}
public function indexAction()
{
// action body
$pgeLine2D = new Application_Model_PgeLine2DMapper();
$this->view->entries = $pgeLine2D->fetchAll();
}
}
When you use aliases instead of new domain you must add
resources.frontController.baseUrl = "/epos"
To yours config.ini file.
这篇关于无效的控制器指定() - Zend框架的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!