php-router icon indicating copy to clipboard operation
php-router copied to clipboard

Looks like page not found or something went wrong. Please try again.

Open sajjadef98 opened this issue 3 years ago • 13 comments

hi i use php-router in my framework "flare-framework" but after use composer update and update your packeage my framework don't work .If you can take a look at it, I really don't know where the problem is

sajjadef98 avatar Jun 23 '22 07:06 sajjadef98

Could you have the steps to install package in the Flare framework?

And it can let others try to reproduce this issue.

peter279k avatar Jun 23 '22 07:06 peter279k

you can see Router and config in dir Flare/app and index.php and htaccess in public dir you can install that composer create-project flare-framework/flare mysite and test its working but after use composer update its show "Looks like page not found or something went wrong. Please try again." ? I really don't know where the problem is 😟☹

sajjadef98 avatar Jun 23 '22 12:06 sajjadef98

Which version of the Router do you use? And what's the previous version?

izniburak avatar Jun 23 '22 14:06 izniburak

2.3 is working good but i want use 2.5 you can install and test that

sajjadef98 avatar Jun 23 '22 20:06 sajjadef98

Did you check changelogs?

izniburak avatar Jun 24 '22 06:06 izniburak

yes , and use

 $router->notFound(function(Request $request, Response $response) {
   dump($request,$response) ;
});

output ----------------------

[dump($request,$response) 📍](editor://open/?file=C%3A%5Claragon%5Cwww%5Ctp%5Csazman-flare%5C1.0.1%5CFlare%5Capp%5CRouter.php&line=26&search=&replace=)Symfony\Component\HttpFoundation\Request
attributes: Symfony\Component\HttpFoundation\ParameterBag
parameters: array (0)
request: Symfony\Component\HttpFoundation\InputBag
parameters: array (0)
query: Symfony\Component\HttpFoundation\InputBag
parameters: array (0)
server: Symfony\Component\HttpFoundation\ServerBag
parameters: array
'PATH' => 'C:\Program Files (x86)\VMware\VMware Workstation\bin\;C:\Program Files (x86)\Common Files\Intel\Shared Libraries\redist\intel64\compiler;C:\laragon\bi … ms\Fiddler'
'SYSTEMROOT' => 'C:/Windows'
'COMSPEC' => 'C:\Windows\system32\cmd.exe'
'PATHEXT' => '.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC;.PY;.PYW'
'WINDIR' => 'C:\Windows'
'SYSTEMDRIVE' => 'C:'
'TEMP' => 'C:/Windows/Temp'
'TMP' => 'C:/Windows/Temp'
'PHPRC' => 'C:/laragon/bin/php/php-8.1.4-nts-Win32-vs16-x64'
'PHP_FCGI_MAX_REQUESTS' => '0'
'_FCGI_SHUTDOWN_EVENT_' => '1160'
'SCRIPT_NAME' => '/tp/sazman-flare/1.0.1/public/index.php'
'REQUEST_URI' => '/tp/sazman-flare/1.0.1/public/sss'
'QUERY_STRING' => ''
'REQUEST_METHOD' => 'GET'
'SERVER_PROTOCOL' => 'HTTP/1.1'
'GATEWAY_INTERFACE' => 'CGI/1.1'
'REDIRECT_URL' => '/tp/sazman-flare/1.0.1/public/sss'
'REMOTE_PORT' => '1903'
'SCRIPT_FILENAME' => 'C:/laragon/www/tp/sazman-flare/1.0.1/public/index.php'
'SERVER_ADMIN' => '[email protected]'
'CONTEXT_DOCUMENT_ROOT' => 'C:/laragon/www'
'CONTEXT_PREFIX' => ''
'REQUEST_SCHEME' => 'http'
'DOCUMENT_ROOT' => 'C:/laragon/www'
'REMOTE_ADDR' => '::1'
'SERVER_PORT' => '80'
'SERVER_ADDR' => '::1'
'SERVER_NAME' => 'localhost'
'SERVER_SOFTWARE' => 'Apache/2.4.46 (Win64) OpenSSL/1.1.1k mod_fcgid/2.3.10-dev'
'SERVER_SIGNATURE' => ''
'SystemRoot' => 'C:\Windows'
'HTTP_COOKIE' => 'tracy-session=dfefd2a6b9'
'HTTP_ACCEPT_LANGUAGE' => 'en-US,en;q=0.9,fa;q=0.8,fa-IR;q=0.7'
'HTTP_ACCEPT_ENCODING' => 'gzip, deflate, br'
'HTTP_SEC_FETCH_DEST' => 'document'
'HTTP_SEC_FETCH_USER' => '?1'
'HTTP_SEC_FETCH_MODE' => 'navigate'
'HTTP_SEC_FETCH_SITE' => 'none'
'HTTP_ACCEPT' => 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9'
'HTTP_USER_AGENT' => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36'
'HTTP_UPGRADE_INSECURE_REQUESTS' => '1'
'HTTP_SEC_CH_UA_PLATFORM' => '"Windows"'
'HTTP_SEC_CH_UA_MOBILE' => '?0'
'HTTP_SEC_CH_UA' => '".Not/A)Brand";v="99", "Google Chrome";v="103", "Chromium";v="103"'
'HTTP_CACHE_CONTROL' => 'max-age=0'
'HTTP_CONNECTION' => 'close'
'HTTP_HOST' => 'localhost'
'REDIRECT_STATUS' => '200'
'FCGI_ROLE' => 'RESPONDER'
'PHP_SELF' => '/tp/sazman-flare/1.0.1/public/index.php'
'REQUEST_TIME_FLOAT' => 1656080589.15152
'REQUEST_TIME' => 1656080589
'Dev_set' => 'development'
'URL' => 'http://localhost/'
'DB_HOST' => 'localhost'
'DB_NAME' => 'Flare_Db'
'DB_USER' => 'root'
'DB_PASS' => ''
'DB_PREFIX' => ''
files: Symfony\Component\HttpFoundation\FileBag
parameters: array (0)
cookies: Symfony\Component\HttpFoundation\InputBag
parameters: array
'tracy-session' => 'dfefd2a6b9'
headers: Symfony\Component\HttpFoundation\HeaderBag
headers: array
'cookie' => array
0 => 'tracy-session=dfefd2a6b9'
'accept-language' => array
0 => 'en-US,en;q=0.9,fa;q=0.8,fa-IR;q=0.7'
'accept-encoding' => array
0 => 'gzip, deflate, br'
'sec-fetch-dest' => array
0 => 'document'
'sec-fetch-user' => array
0 => '?1'
'sec-fetch-mode' => array
0 => 'navigate'
'sec-fetch-site' => array
0 => 'none'
'accept' => array
0 => 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9'
'user-agent' => array
0 => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36'
'upgrade-insecure-requests' => array
0 => '1'
'sec-ch-ua-platform' => array
0 => '"Windows"'
'sec-ch-ua-mobile' => array
0 => '?0'
'sec-ch-ua' => array
0 => '".Not/A)Brand";v="99", "Google Chrome";v="103", "Chromium";v="103"'
'cache-control' => array
0 => 'max-age=0'
'connection' => array
0 => 'close'
'host' => array
0 => 'localhost'
cacheControl: array
'max-age' => '0'
content: null
languages: null
charsets: null
encodings: null
acceptableContentTypes: null
pathInfo: null
requestUri: null
baseUrl: null
basePath: null
method: 'GET'
format: null
session: null
locale: null
defaultLocale: 'en'
preferredFormat: null
isHostValid: true
isForwardedValid: true
isSafeContentPreferred: null
[dump($request,$response) 📍](editor://open/?file=C%3A%5Claragon%5Cwww%5Ctp%5Csazman-flare%5C1.0.1%5CFlare%5Capp%5CRouter.php&line=26&search=&replace=)Symfony\Component\HttpFoundation\Response
headers: Symfony\Component\HttpFoundation\ResponseHeaderBag
computedCacheControl: array
'no-cache' => true
'private' => true
cookies: array (0)
headerNames: array
'content-type' => 'content-type'
'cache-control' => 'Cache-Control'
'date' => 'Date'
headers: array
'content-type' => array
0 => 'text/html'
'cache-control' => array
0 => 'no-cache, private'
'date' => array
0 => 'Fri, 24 Jun 2022 14:23:09 GMT'
cacheControl: array (0)
content: ''
version: '1.0'
statusCode: 200
statusText: 'OK'
charset: null
[30.0 ms](http://localhost/tp/sazman-flare/1.0.1/public/sss#)
[×](http://localhost/tp/sazman-flare/1.0.1/public/sss#)

every request show this message And do not use this

$router->get('/', 'EFTEKHARI@index');
// or
$router->get('/sss', function() {
    return 'Hello World.';
});

I can't find the problem

sajjadef98 avatar Jun 24 '22 14:06 sajjadef98

Did you set router configs? For ex: base folder?

izniburak avatar Jun 25 '22 00:06 izniburak

Consider the above messages. You find that this problem is done only with the composer update command. So everything is set and it has no problem in version 2.3, but it doesn't work with the update at all. Router, index.php ,htaccess , Tell me exactly how I can solve the problem ?

sajjadef98 avatar Jun 25 '22 17:06 sajjadef98

I'll clone your project and try to run it. I need to debug it. I'll inform you about that.

izniburak avatar Jun 28 '22 06:06 izniburak

@izniburak any update? I have same error. Is it about php 8? I try this and it's also not working

omerfdmrl avatar Jul 16 '22 08:07 omerfdmrl

Hi, @sajjadef98 and @omerfdmrl ; I've tried the project and it worked on PHP 8.1.2 (my local env) The PHP Router version is v2.5.3

Please check Changelogs again and update your code if there is any breaking changes for you.

izniburak avatar Jul 16 '22 10:07 izniburak

I check that , but not find my problem in my framework its work good in 2.3 but after update its not work?!🤷‍♂️

sajjadef98 avatar Aug 02 '22 15:08 sajjadef98

This problem is usually caused by not being able to find the Controller class. its worked this way

my files structure

  • src
    • Controllers
      • UserControllers
  • routes
    • api.php

my api.php

` use Buki\Router\Router;

$router = new Router([ 'paths' => [ 'controllers' => '../src/Controllers', ], 'namespaces' => [ 'controllers' => 'TestAPI\Controllers', ], ]); $router->get('/', 'UserController@test'); $router->run();

`

iamserkanyilmaz avatar Nov 17 '22 18:11 iamserkanyilmaz