Visualizzazione dei risultati da 1 a 6 su 6
  1. #1
    Utente di HTML.it
    Registrato dal
    Jan 2007
    Messaggi
    561

    Azione non gestita con Zend Framework 2

    Io ho creato il seguente IndexController:

    Codice PHP:
    <?php
    namespace Users\Controller;
    use 
    Zend\Mvc\Controller\AbstractActionController;
    use 
    Zend\View\Model\ViewModel;
    class 
    IndexController extends AbstractActionController
    {
        public function 
    indexAction()
        {
            
    $view = new ViewModel();
            return 
    $view;
        }
        public function 
    registerAction()
        {
            
    $view = new ViewModel();
            
    $view->setTemplate('users/index/new-user');
            return 
    $view;
        }
        public function 
    loginAction()
        {
            
    $view = new ViewModel();
            
    $view->setTemplate('users/index/login');
            return 
    $view;
        }
    }
    ed ho creato la view index.phtml così:

    codice HTML:
    <h1>Welcome to Users Module</h1>
    <a href="/users/index/login">Login</a> | <a href="/users/index/register">New User Registration</a>
    Quando clicco su uno dei due link ottengo un Errore 404 (Oggetto non trovato).


    Io sto usando per la prima volta un framework ..........cosa potrebbe essere?
    Dovrebbe essere una questione di PATH ma non capisco dove però...ho provato anche su google ma niente

    aiutatemi perfavore .....grazie
    tulipan

  2. #2
    Utente di HTML.it
    Registrato dal
    Jan 2007
    Messaggi
    561
    Il file module.config.php è :

    Codice PHP:
    <?php
    return array(
        
    'controllers' => array(
            
    'invokables' => array(
                
    'Users\Controller\Index' =>
                
    'Users\Controller\IndexController',
            ),
        ),
        
    'router' => array(
            
    'routes' => array(
                
    'users' => array(
                    
    'type'    => 'Literal',
                    
    'options' => array(
                        
    // Change this to something specific to your module
                        
    'route'    => '/users',
                        
    'defaults' => array(
                            
    // Change this value to reflect the namespace in which
                            // the controllers for your module are found
                            
    '__NAMESPACE__' => 'Users\Controller',
                            
    'controller'    => 'Index',
                            
    'action'        => 'index',
                        ),
                    ),
                    
    'may_terminate' => true,
                    
    'child_routes' => array(
                        
    // This route is a sane default when developing a module;
                        // as you solidify the routes for your module, however,
                        // you may want to remove it and replace it with more
                        // specific routes.
                        
    'default' => array(
                            
    'type'    => 'Segment',
                            
    'options' => array(
                                
    'route'    => '/[:controller[/:action]]',
                                
    'constraints' => array(
                                    
    'controller' => '[a-zA-Z][a-zA-Z0-9_-]*',
                                    
    'action'     => '[a-zA-Z][a-zA-Z0-9_-]*',
                                ),
                                
    'defaults' => array(
                                ),
                            ),
                        ),
                    ),
                ),
            ),
        ),
        
    'view_manager' => array(
            
    'template_path_stack' => array(
                
    'users' => __DIR__ '/../view',
            ),
        ),
    );

  3. #3
    Utente di HTML.it L'avatar di boots
    Registrato dal
    Oct 2012
    Messaggi
    1,626
    Ma l'errore è di Zend o di Apache? Qual'è l'url della tua applicazione?

  4. #4
    Utente di HTML.it
    Registrato dal
    Jan 2007
    Messaggi
    561
    credo sia di Zend perchè non trova le azioni "register", "login", etc . Mi spiego meglio se da browser apro la pagina index.phtml andando nel file system è tutto ok nel senso che mi fa vedere correttamente la pagina index.phtml....poi però nella pagina index.phtml ci sono due azioni che un utente può compiere: il login e la registrazione.
    Invio anche la pagina index.phtml che forse è meglio:

    <h1>Welcome to Users Module</h1>
    <a href="/users/index/login">Login</a> | <a href="/users/index/register">New User Registration</a>

  5. #5
    Utente di HTML.it L'avatar di boots
    Registrato dal
    Oct 2012
    Messaggi
    1,626
    Non ho mai usato Zend, quindi non ti potrei aiutare.
    Da tipo di errore mi era sembrato più da Apache:
    Se per caso hai la tua applicatizione in
    http://localhost/myapp/
    ma poi metti come link
    codice:
    <a href="/users/index/login">Login</a>
    Il browser ti porta su
    http://localhost/users/index/login
    Invece di

    http://localhost/myapp/users/index/login

  6. #6
    Utente di HTML.it
    Registrato dal
    Jan 2007
    Messaggi
    561
    purtroppo nemmeno così riesce ad eseguire l'azione

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.