auraphp / Aura.Router

A web router implementation for PHP.
http://auraphp.com/packages/3.x/Router/
MIT License
494 stars 74 forks source link

Route Failure - Path Rule #166

Closed doktor1360 closed 5 years ago

doktor1360 commented 5 years ago

Opening this issue up (cross-posted here at Stackoverflow ) as requested by @harikt to continue mitigating a route problem per the subject. As requested in that post, here is some of the configuration code involved and a trace output of the specific failure.

nginx server block configuration:

server {
    listen 80;
    server_name infraweb.devserver.com;
    root /srv/www/workspace/infraweb/public;
    index index.php index.html index.htm;

    access_log  /var/log/nginx/infraweb/default.access.log main;
    error_log   /var/log/nginx/infraweb/default.error.log debug;
    rewrite_log on;

    ## -------------------------------------------------
    #   default site / ip address
    #     @ serve nginx application
    ## -------------------------------------------------
    location / {
        try_files $uri $uri/ /index.php?$is_args$args;
    }

    ## -------------------------------------------------
    #   default directory website location block
    ## -------------------------------------------------            
    location ~ [^/]\.php(/|$) {
    #location ~ \.php$ {
        try_files $uri /index.php =404;

        fastcgi_pass                        127.0.0.1:9011;
        include fastcgi_params;
        fastcgi_index index.php;
        fastcgi_split_path_info ^(.+\.php)(.*)$;
        fastcgi_param SCRIPT_FILENAME       $document_root$fastcgi_script_name;
    }                                                                                                                                                                            
}

index.php routing snippet concerning the route definitions:

$routing_map->get('application.signin.read', '/signin', [
    'params' => [
        'values' => [
            'controller' => '\Infraweb\LoginUI',
            'action' => 'read',
        ]
    ]
]);
$routing_map->post('services.authentication.login', '/services/authentication/login', [
    'params' => [
        'values' => [
            'controller' => '\Infraweb\Toolkit\Services\Authentication',
            'action' => 'login',
        ]
    ]
]);

xdebug trace output of actual failure:

Version: 2.6.0
File format: 4
TRACE START [2019-02-24 06:26:44]
6   1353    1   0.022454    2476112
6   1354    0   0.022462    2476392 Psr\Log\NullLogger->debug   1       /srv/www/workspace/infraweb/vendor/aura/router/src/Matcher.php  210 2   '{path} FAILED {ruleClass} ON {name}'   array ('path' => '/signin', 'ruleClass' => 'Aura\\Router\\Rule\\Path', 'name' => 'services.authentication.login')
7   1355    0   0.022478    2476392 Psr\Log\NullLogger->log 1       /srv/www/workspace/infraweb/vendor/psr/log/Psr/Log/AbstractLogger.php   126 3   'debug' '{path} FAILED {ruleClass} ON {name}'   array ('path' => '/signin', 'ruleClass' => 'Aura\\Router\\Rule\\Path', 'name' => 'services.authentication.login')
7   1355    1   0.022492    2476392
6   1354    1   0.022497    2476016
6   1356    0   0.022502    2476016 xdebug_stop_trace   0       /srv/www/workspace/infraweb/vendor/aura/router/src/Matcher.php  212 0
            0.022508    2476112
TRACE END   [2019-02-24 06:26:44]

I haven't to this point quite determined the exact cause in what looks like some sort of REGEX fail after looking at the Rule/Path.php file rule source. I'm betting I've got some piece of cement-headed code somewhere that's causing all the grief.

Having an extra set of eyeballs (or three) looking at this wouldn't hurt, and the real upside here is I'm learning a great deal about some of the open source routing concepts as a consequence. Ideas, problems or concerns? Any constructive criticism is greatly welcome and appreciated!

Thanx in advance...

harikt commented 5 years ago

Sorry for the confusion.

What I mean by posting full code to github is host your code at your end, so we can just run composer install and start the built in server.

Anyway we don't need to duplicate things over two places. And github issues are basically for issues within the package. I will continue replying on stackoverflow.