Author Topic: Unknown controller method 'index.php'  (Read 8454 times)

sabuwona

  • Newbie
  • *
  • Posts: 16
    • View Profile
Unknown controller method 'index.php'
« on: August 27, 2012, 06:43:58 am »
Quote
added "/htdocs/" to webroot tree description
I'm working on a single homed multi MVC application, to simplify my models.
The basic structure is using the web-root for authentication and authorisation purposes, the (custom) session handler will be living in the myfiles directory.
each different "application" has it own 1st level directory under the webroot.
Code: [Select]
webroot /htdocs/         index.php           auth
app_1    /htdocs/1/      index.php           functionality x
app_2    /htdocs/2/      index.php           functionality y
etc

This is the error message I'm getting when accessing the default tinyMVC test page, which works at level 0.

Code: [Select]
Error: 0
Message: Unknown controller method 'index.php'
File: <private_path>\tinymvc\myfiles\plugins\tinymvc_controller.php
Line: 58
Trace:
#0 <private_path>\tinymvc\myfiles\TinyMVC.php(120): TinyMVC_Controller->__call('index.php', Array)
#1 <private_path>\tinymvc\myfiles\TinyMVC.php(120): Default_Controller->index.php()
#2 <private_path>\htdocs\m\index.php(41): tmvc->main()
#3 {main}
I can't pin down the reason of this misbehavior yet, could anybody give me directions in backtracing this issue?
I can confirm it is using the correct custom config_application.php, the paths must be correct.


I've got a neat patch for the TinyMVC_ExceptionHandler Class on line 81:
Code: [Select]
<b>Trace:</b> <br />
<?=str_replace("\n", "<br />\n", $e->getTraceAsString())?><br />
« Last Edit: August 27, 2012, 07:13:42 am by sabuwona »

mohrt

  • Administrator
  • Sr. Member
  • *****
  • Posts: 275
    • View Profile
Re: Unknown controller method 'index.php'
« Reply #1 on: August 27, 2012, 08:08:30 am »
What is the URL you are using to the page? You need this:

http://www.domain.com/index.php/[controller]/[action]

Or with apache rewrites on:

http://www.domain.com/[controller]/[action]


It appears that TinyMVC is getting:

http://www.domain.com/[controller]/index.php


sabuwona

  • Newbie
  • *
  • Posts: 16
    • View Profile
Re: Unknown controller method 'index.php'
« Reply #2 on: August 27, 2012, 08:21:22 am »
Thanks for your swift reply.

The base of my application runs perfect on:

http://www.domain.com/index.php/[controller]/[action]

For my application(s) I will be needing:

http://www.domain.com/[application]/index.php/[controller]/[action]

My (dev) system is running IIS 7.5 with PHP 5.4.6.

mohrt

  • Administrator
  • Sr. Member
  • *****
  • Posts: 275
    • View Profile
Re: Unknown controller method 'index.php'
« Reply #3 on: August 27, 2012, 08:30:11 am »
ok it may be an issue with $_SERVER['PATH_INFO'] and how IIS interprets it. Are you using 1.2.2?

sabuwona

  • Newbie
  • *
  • Posts: 16
    • View Profile
Re: Unknown controller method 'index.php'
« Reply #4 on: August 27, 2012, 08:38:13 am »
Yes, I'm using 1.2.2

I'm not using any rewrite rules at this stage as IIS does not supply this feature by default.

mohrt

  • Administrator
  • Sr. Member
  • *****
  • Posts: 275
    • View Profile
Re: Unknown controller method 'index.php'
« Reply #5 on: August 27, 2012, 08:41:48 am »
it is not a rewrite rule, it is:

http://www.domain.com/index.php/FOO/BAR

Your server needs to supply /FOO/BAR in a $_SERVER variable (everything past index.php)

Most use PATH_INFO, What does your server have?

sabuwona

  • Newbie
  • *
  • Posts: 16
    • View Profile
Re: Unknown controller method 'index.php'
« Reply #6 on: August 27, 2012, 08:57:23 am »
I might have spotted the snake biting my toes:
I think I need to shift segments one position to the right...
Code: [Select]
TinyMVC.php line 162-170
  /**
   * setup url segments array
   *
   * @access public
   */   
  public function setupSegments()
  {
    $this->url_segments = !empty($this->path_info) ? array_filter(explode('/',$this->path_info)) : null;
  }

mohrt

  • Administrator
  • Sr. Member
  • *****
  • Posts: 275
    • View Profile
Re: Unknown controller method 'index.php'
« Reply #7 on: August 27, 2012, 08:59:22 am »
tinymvc does this to set the path_info:

/* set path_info */
   
Code: [Select]
$this->path_info = !empty($_SERVER['PATH_INFO']) ? $_SERVER['PATH_INFO'] :
    (!empty($_SERVER['ORIG_PATH_INFO']) ? $_SERVER['ORIG_PATH_INFO'] : '');

Is that working on your server? you need to check the values of $_SERVER['PATH_INFO'] and $_SERVER['ORIG_PATH_INFO']

sabuwona

  • Newbie
  • *
  • Posts: 16
    • View Profile
Re: Unknown controller method 'index.php'
« Reply #8 on: August 27, 2012, 09:11:16 am »
For my application(s) I will be needing:

http://www.domain.com/[application]/index.php/[controller]/[action]

did I mention the application is living in a sub directory under the webroot with the contents of the tinyMVC htdocs directory to host the application?

sabuwona

  • Newbie
  • *
  • Posts: 16
    • View Profile
Re: Unknown controller method 'index.php'
« Reply #9 on: August 27, 2012, 09:24:44 am »
/* set path_info */
Is that working on your server? you need to check the values of $_SERVER['PATH_INFO'] and $_SERVER['ORIG_PATH_INFO']
$_SERVER['PATH_INFO']  is giving me the following information:
The first three requests work fine, it is the last request which ruins my day...  ;)

[edit]It is actually ORIG_PATH_INFO instead of PATH_INFO[/edit]
« Last Edit: August 27, 2012, 09:47:27 am by sabuwona »

mohrt

  • Administrator
  • Sr. Member
  • *****
  • Posts: 275
    • View Profile
Re: Unknown controller method 'index.php'
« Reply #10 on: August 27, 2012, 10:12:47 am »
yeah that would be the problem. So, is there a variable that gives the info ONLY after index.php in all cases? examples:

http://www.domain.com/index.php/FOO/BAR   --> /FOO/BAR
http://www.domain.com/applications/index.php/FOO/BAR   --> /FOO/BAR
http://www.domain.com/index.php   --> (empty)
http://www.domain.com/applications/index.php  --> (empty)
http://www.domain.com/   --> (empty)
« Last Edit: August 27, 2012, 10:14:31 am by mohrt »

mohrt

  • Administrator
  • Sr. Member
  • *****
  • Posts: 275
    • View Profile
Re: Unknown controller method 'index.php'
« Reply #11 on: August 27, 2012, 10:17:54 am »
If you want you can setup phpinfo.php script on your server (that just executes phpinfo(); ) and PM me the URL, and I'll take a  look myself.

sabuwona

  • Newbie
  • *
  • Posts: 16
    • View Profile
Re: Unknown controller method 'index.php'
« Reply #12 on: August 27, 2012, 12:09:05 pm »
That won't do any good, it's not accessable from the evil side.... (dmz dev server)

I could email you the output of both http://localhost/phpinfo.php and http://localhost/sub-application/phpinfo.php

sabuwona

  • Newbie
  • *
  • Posts: 16
    • View Profile
Re: Unknown controller method 'index.php'
« Reply #13 on: August 27, 2012, 12:17:17 pm »
yeah that would be the problem. So, is there a variable that gives the info ONLY after index.php in all cases? examples:

http://www.domain.com/index.php/FOO/BAR   --> /FOO/BAR
http://www.domain.com/applications/index.php/FOO/BAR   --> /FOO/BAR
http://www.domain.com/index.php   --> (empty)
http://www.domain.com/applications/index.php  --> (empty)
http://www.domain.com/   --> (empty)

http://www.domain.com/   --> FOO/BAR
http://www.domain.com/index.php   --> FOO/BAR
http://www.domain.com/applications/ -> (empty) -> tinyMVC Error
http://www.domain.com/applications/index.php  --> (empty) -> tinyMVC Error[/u]
http://www.domain.com/applications/index.php/  --> FOO/BAR

mohrt

  • Administrator
  • Sr. Member
  • *****
  • Posts: 275
    • View Profile
Re: Unknown controller method 'index.php'
« Reply #14 on: August 27, 2012, 12:19:19 pm »
That won't do any good, it's not accessable from the evil side.... (dmz dev server)

I could email you the output of both http://localhost/phpinfo.php and http://localhost/sub-application/phpinfo.php

yes, and the output of phpinfo.php/foo/bar too.