Welcome Guest, Not a member yet? Register   Sign In
URI Routing
#1

Hello, yesterday I wrote in a similar topic, but it was already lost and the information on this issue went in parts. Therefore, I still decided to create a new topic and collected all the information in one place, which can help:
Quote:When I submit the form (located at site/user) by post to the site/user/add address, I get the following machine response:

404 - File Not Found
Controller or its method is not found: User::add
/app/Config/Autoload.php
PHP Code:
        $psr4 = [
            
'App'               => APPPATH,                // To ensure filters, etc still found,
            
APP_NAMESPACE       => APPPATH,                // For custom namespace
            
'Config'              => APPPATH .  'Config',
            ...
            
'Modules\User'        => ROOTPATH 'modules/User',
        ]; 
/app/Config/Routes.php
PHP Code:
$routes->setTranslateURIDashes(false);
$routes->set404Override();
$routes->setAutoRoute(true); 
Quote:Yesterday @includebeer suggested that I set the AutoRoute value to "false".
As a result, we received the following response from the machine:
Code:
Can't find a route for 'user/add'.
/modules/User/Config/Routes.php
PHP Code:
<?php
$routes
->group('user', ['namespace' => 'Modules\User\Controllers'], function($routes)
{
    $routes->get('/',       'User::index');
    $routes->post('add',    'User::createUser');
    $routes->post('load',   'User::load');
}); 
/modules/User/Controllers/User.php
PHP Code:
<?php namespace Modules\User\Controllers;
use 
Modules\User\Models\UserModel;

class 
User extends \CodeIgniter\Controller
{
    public function createUser() {
        $model = new UserModel();
        $model->createUser($data = [
            'mail'        => $this->request->getPost('mail'),
            ...
            'timezone'    => $this->request->getPost('timezone')
        ]);
        return redirect()->back();
        //return redirect()->back();
    
/modules/User/Views/Index.php
Code:
... <?= form_open(
        'user/add',
        [
            'class' => '',
            'id'    => 'form'
        ]);
?> ...
Help me figure out the question, maybe I just need to reinstall the framework ...

Thanks!
Reply




Theme © iAndrew 2016 - Forum software by © MyBB