-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG]: v4 Regression - localhost/project/ - trouble with Application->handle #14559
Comments
@jenovateurs You're on Phalcon 4.0.0-RC.3? |
@ruudboon Yes, I'm on Phalcon 4.0.0-rc.3. |
@jenovateurs could you try to pass in $_GET["_url"]. That was the default in 3.4
|
@ruudboon When I tried with $_GET["_url"], I got this error :
|
@jenovateurs And you are using the same Apache or Nginx config as your 3.4 environment? I did some comparison between 4 and 3.4 on this point I don't see any changes that could cause this behaviour. Also on my test machine I was able to run directory based on the $_GET["_url"] (using nginx). |
@ruudboon Yes, I used the same Apache configuration. I just changed the Phalcon extension. I took a project created with v3 and I have no problem. But when I put the parameter When I took a v4 project, I had the same error : When I called this URL: With Nginx, do you have the same value ? |
@jenovateurs Nginx will strip out the dir. Config looks something like this. $1 will only hold the part after the '/'. I will have a look at this with apache.
|
@ruudboon
And if I understand well, if |
Good catch. I think we need to allow null on the handle. Let me double check and patch that. |
Resolved in #14576 |
@ruudboon I'm sorry but I didn't understand the fix code. The parameter uri is still required in the handle function. Then, when I used $_SERVER["REQUEST_URI"], I got the same error. And $_GET['_url'] isn't defined when you call this url : http://127.0.0.1/test/ (Root project) |
@jenovateurs It was already optional. But we didn't fall back '/'. That's what is changed now. So we now handle it in the same way 3.4 does. |
@ruudboon When I used the function handle like that : About |
@ruudboon Is it normal that the issue is still closed ? Thanks ;-) |
I will discuss this with the team to decide if we need to allow null as well. |
Moving this to 4.1. Need to think this through more. |
@niden No problem, I understand. |
Hi, everyone. I was having this same issue when creating a project in a subfolder. I saw some good solutions, but I tried to solve it with an improvement: use the base directory to determine the full subfolder path and use it as a "pseudo-root" folder for the project. All I did was to replace (in public/index.php) this line: echo $application->handle($_SERVER['REQUEST_URI'])->getContent(); with these lines: $path = str_replace($_SERVER["DOCUMENT_ROOT"], '', str_replace("\", "/", BASE_PATH)); I tested it with up to 2 levels of subfolders, but I think it can work with more levels. It also works with the project in the root directory of the web server. If this solution is useful to you, please, let me know. |
I have been looking into this issue as well, this weekend. My conclusion is that you can not put your project in a subdirectory without adjusting the For example, a project called 'store' in a userdir, and another in a subdirectory under
("Expected" means: expected by the router) The Phalcon router tries to match them against the default routes, which never match a uri with a tilde (~) in it, so any url under a userdir results in the default index page. The second example, with the subdirectory under A simple solution is to use In echo $application->handle($_SERVER['REQUEST_URI'])->getContent(); with these lines: $baseUri = str_replace('/public/index.php', '', $_SERVER['PHP_SELF']);
$uri = str_replace($baseUri, '', $_SERVER['REQUEST_URI']);
echo $application->handle($uri)->getContent(); Pros:
Cons:
Disclaimer: only tested with cphalcon 4.1.2 and 5.0.0alpha3, devtools 4.1.1, with Apache, on CentOS 8. |
Hi, I've done the modification above but no luck. Getting indexController handler class cannot be loaded error. Same code is working another server with same config. I couldn't get it...
|
Config
Windows 10 - Wamp - PHP 7.2.18
Description
With Phalcon V3, I can have multiple project at the root of the server like :
http://localhost/project/
http://localhost/project2/
...
With Phalcon V4, I get this error:
Little hack
To solve temporary this issue, I updated the file public/index.php:
echo $application->handle($_SERVER['REQUEST_URI'])->getContent();
to
echo $application->handle(str_replace('hello_world2/','',$_SERVER['REQUEST_URI']))->getContent();
But, It's not very great.
The text was updated successfully, but these errors were encountered: