Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

Empty post on basic tutorial, phalcon v4.0.2

In phalcon basic tutorial signup form example, i can fetch data from db so "List the Registered Users" worked, but i cant save any data in non-blank register form .when i disable "notNullValidation" and fields nullable in db table, result is empty rows in database.These empty rows can be listed.

Values cant pass controller to model.It's not a custom code, generated by phalcon devtools or project folder created manually.Every time i get same error below.

E:\xampp\php\php.exe E:\xampp\htdocs\basic\public\index.php

Notice: Undefined index: REQUEST_URI in E:\xampp\htdocs\basic\app\config\router.php on line 7

Call Stack: 0.0005 401000 1. {main}() E:\xampp\htdocs\basic\public\index.php:0 0.0009 411224 2. include('E:\xampp\htdocs\basic\app\config\router.php') E:\xampp\htdocs\basic\public\index.php:26

Fatal error: Uncaught TypeError: Argument 1 passed to Phalcon\Mvc\Router::handle() must be of the type string, null given in E:\xampp\htdocs\basic\app\config\router.php on line 7

TypeError: Argument 1 passed to Phalcon\Mvc\Router::handle() must be of the type string, null given in E:\xampp\htdocs\basic\app\config\router.php on line 7

Call Stack: 0.0005 401000 1. {main}() E:\xampp\htdocs\basic\public\index.php:0 0.0009 411224 2. include('E:\xampp\htdocs\basic\app\config\router.php') E:\xampp\htdocs\basic\public\index.php:26

PHP Notice: Undefined index: REQUEST_URI in E:\xampp\htdocs\basic\app\config\router.php on line 7 PHP Stack trace: PHP 1. {main}() E:\xampp\htdocs\basic\public\index.php:0 PHP 2. include() E:\xampp\htdocs\basic\public\index.php:26 PHP Fatal error: Uncaught TypeError: Argument 1 passed to Phalcon\Mvc\Router::handle() must be of the type string, null given in E:\xampp\htdocs\basic\app\config\router.php:7 Stack trace:

0 E:\xampp\htdocs\basic\app\config\router.php(7): Phalcon\Mvc\Router->handle(NULL)

1 E:\xampp\htdocs\basic\public\index.php(26): include('E:\xampp\htdocs...')

2 {main}

thrown in E:\xampp\htdocs\basic\app\config\router.php on line 7

Undefined index: REQUEST_URI implies that the $_SERVER superglobal is not filled in properly by your web-server.

Please check the docs on how to configure apache with phalcon: https://docs.phalcon.io/latest/en/webserver-setup#apache

i checked phpinfo() and phalcon apache setup docs , when i'm trying to debug with phpstorm, i can trace $_SERVER variables and values, maybe it's a cli error due no argument,Page is rendered correctly in browser but i got same error in terminal even index page. i have a virtual host directory and dns record in like "bas.ic" in my development machine, and project folder is localhost/basic..htaccess files in project folder not apache main config file. i can call bas.ic bas.ic/signup etc.
but if i try "localhost/basic" or "localhost/basic/signup" gave me below error "BasicController handler class cannot be loaded

0 [internal function]: Phalcon\Mvc\Dispatcher->throwDispatchException('BasicController...', 2)

1 [internal function]: Phalcon\Dispatcher\AbstractDispatcher->dispatch()

2 E:\xampp\htdocs\basic\public\index.php(48): Phalcon\Mvc\Application->handle('/basic/')

3 {main}"

Must we need a default controller which is same name project folder, if i use virtual host, IndexController or any working without any error. Urls in browser developer tool ok, controller and routing seems to be working but posting data not working.



269
Accepted
answer

I found the solution.Phalcon tutorial documentation a bit older.In SignupController.php i've changed somelines according to this.

$user->assign( $this->request->getPost(), null, [ "name", "email", ] );


$user->assign( $this->request->getPost( null,'name','email' )