Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [ZendFramework] nie poznaje funkcji getRouter(), Fatal error: Call to undefined method Zend_Application::getRouter() in
agnieszkagdansk
post
Post #1





Grupa: Zarejestrowani
Postów: 32
Pomógł: 0
Dołączył: 22.05.2009

Ostrzeżenie: (0%)
-----


Pokazuje mi taki komunikat
Cytat
Fatal error: Call to undefined method Zend_Application::getRouter() in C:\Program Files\WebServ\httpd\cms\index.php on line 53


  1. <?php
  2.  
  3.  
  4.  
  5. // Define path to application directory
  6. defined('APPLICATION_PATH')
  7.    || define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/application'));
  8.  
  9. // Define application environment
  10. defined('APPLICATION_ENV')
  11.    || define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production'));
  12.  
  13. // Ensure library/ is on include_path
  14. set_include_path(implode(PATH_SEPARATOR, array(
  15.    realpath(APPLICATION_PATH . '/../library'),
  16.    realpath(APPLICATION_PATH . '/../application/admin/models'),
  17. )));
  18.  
  19. /** Zend_Application */
  20. require 'Zend/Application.php';
  21. require "Zend/Loader.php";
  22.  
  23. Zend_Loader::loadClass('Zend_Controller_Front');
  24. Zend_Loader::loadClass('Zend_Config_Ini');
  25. Zend_Loader::loadClass('Zend_Registry');
  26. Zend_Loader::loadClass('Zend_Controller_Router_Route');
  27. //Zend_Loader::loadClass('Zend_Db');
  28. //Zend_Loader::loadClass('Zend_Db_Table');
  29.  
  30.  
  31. // Create application, bootstrap, and run
  32. $application = new Zend_Application(
  33.    APPLICATION_ENV,
  34.    APPLICATION_PATH . '/configs/application.ini'
  35. );
  36.  
  37.  
  38. $config = new Zend_Config_Ini('./application/configs/config.ini', 'general');
  39. //$registry = Zend_Registry::getInstance();
  40. //$registry->set(’config’, $config);
  41.  
  42. // setup database
  43. $db = Zend_Db::factory($config->db);
  44. Zend_Db_Table::setDefaultAdapter($db);
  45.  
  46. $route = new Zend_Controller_Router_Route('parametr1/:var1/parametr2/:var2/',   array('module' => 'default', 'controller' => 'index', 'action' => 'index'));
  47. $application->getRouter()->addRoute('default', $route);
  48. $application->bootstrap()->run();
  49. ?>



Co jest nie tak ?
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 3)
michaJlS
post
Post #2





Grupa: Zarejestrowani
Postów: 83
Pomógł: 9
Dołączył: 21.05.2004
Skąd: Glogau/Breslau

Ostrzeżenie: (0%)
-----


no tak jak tam jest napisane (IMG:http://forum.php.pl/style_emoticons/default/winksmiley.jpg) Zend_Application nie ma takiej metody, jak getRouter() -> http://framework.zend.com/apidoc/core/Zend...pplication.html
Go to the top of the page
+Quote Post
agnieszkagdansk
post
Post #3





Grupa: Zarejestrowani
Postów: 32
Pomógł: 0
Dołączył: 22.05.2009

Ostrzeżenie: (0%)
-----


ok powinno być
  1. <?php
  2. $route           = new Zend_Controller_Router_Route('parametr1/:var1/parametr2/:var2/',   array('module' => 'default', 'controller' => 'index', 'action' => 'index'));
  3. $frontController = Zend_Controller_Front::getInstance();
  4. $frontController->getRouter()->addRoute('default', $route);
  5. ?>


ale teraz powstały dwa dodatkowe problemy

Router działa mi także dla modułu Admin to znaczy jak wpisze
localhost/admin to i tak pokazuje mi to co jest na localhost

na dodatek funkcja

  1. <?php
  2. $this->_request->getParam('nazwa_parametru');
  3. ?>

przestała mi zwracać wartosc parametru

Ten post edytował agnieszkagdansk 29.07.2009, 14:01:19
Go to the top of the page
+Quote Post
Master Pain
post
Post #4





Grupa: Zarejestrowani
Postów: 71
Pomógł: 1
Dołączył: 5.04.2007
Skąd: Jarocin

Ostrzeżenie: (0%)
-----


Napisz może przykład: podaję adres strona.pl/admin -> chcę wywołać controller: 'nazwa_controllera' i akcję 'nazwa_akcji', czy jakoś podobnie.
Bo na razie masz ustawione w routerze, że ma użyć controller IndexController i akcję IndexAction - router działa poprawnie.
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 23.08.2025 - 08:53