Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Package Working on Localhost but not on server
  • For some reason a package that works perfectly fine on a localhost gives me a 404 error on the server.
    any pointers as to where i should start looking?
    thank you.
    ps: I didnt touch the config/routes file...
  • Fuel only loads the defined 404 page if the requested controller, or the controller method can not be located. If you have established that the controller method is correctly called, it is not Fuel that loads the 404 view, it must be related to your application code.
  • Harro Verton wrote on Wednesday 20th of July 2011:
    Fuel only loads the defined 404 page if the requested controller, or the controller method can not be located. If you have established that the controller method is correctly called, it is not Fuel that loads the 404 view, it must be related to your application code.

    This has to be server related, the trouble is , I don't even know where to start. the controller & package work fine on a Mamp installation locally . I will call hosting support and dig a bit more, I will be sure to share my finding, hopefully its nothing embarrassing. thanks for looking into it
  • Start debugging the application. If you can establish (for example by placing a die() before your if) that on the server your controller and action method is correctly called, you can rule out any issue with Fuel, with routing, and with rewriting. If you then get the 404 if you move that die() to after the call to your package class, this issue must be related to the package. So next step is to dive into the package class, and debug the code of the method called. Also enable all logging, so you can see in the logfile what the sequence of request object creation is when you request the page. Maybe that will shed some light on what's going on.
  • Harro Verton wrote on Wednesday 20th of July 2011:
    Start debugging the application. If you can establish (for example by placing a die() before your if) that on the server your controller and action method is correctly called, you can rule out any issue with Fuel, with routing, and with rewriting. If you then get the 404 if you move that die() to after the call to your package class, this issue must be related to the package. So next step is to dive into the package class, and debug the code of the method called. Also enable all logging, so you can see in the logfile what the sequence of request object creation is when you request the page. Maybe that will shed some light on what's going on.

    I did exactly that, and everything points to the package being the problem but if that was truly the case, why would the same package work fine on my Mamp installation?
    first thing, I do with the package is Location::check() which basically only checks if a 'location' cookie is set , and that triggers the 404 error!
     public static function check() {
    
     
      if (\Cookie::get('location', null)==null)  {
      
       return true;
      
      }
      
      return false; 
     }
     
    
    it is very odd. I am sure there is a very logical explanation to this 404 error that i get but so far, I don't have any leads.
    as you mentioned, a 404 would be generated if a controller is not found..i fail to see how a package can cause it ...but it does!
    I don't think it is a FUEL issue at all, but something in the server settings. At any case, it would be good to find out , which i will :)
  • Most of the time problems like these are caused by a case insensitive testing environment and a case sensitive server. Check if all your filenames & direnames within the Fuel dirs are fully lowercase.
  • Jelmer Schreuder wrote on Wednesday 20th of July 2011:
    Most of the time problems like these are caused by a case insensitive testing environment and a case sensitive server. Check if all your filenames & direnames within the Fuel dirs are fully lowercase.

    Jelmer, you are a life saver...As simple as that :
    the problem was in the bootstrap file of the package :
     'Location\\Location'     => __DIR__.'/classes/Location.php',
    

    needed to be changed to this
     'Location\\Location'     => __DIR__.'/classes/location.php',
    

    hope this saves someone else hours of frustration :) thanks again Jelmer!
  • Is your local environment windows by any chance? Microsoft trying to be helpful and failing again.
  • No it is Mac actually.
    the hosting server where i was having trouble is linux i believe.
  • Oh I thought macs used a case sensitive file system. Learn something new every day :)
  • I believe u can run either on Mac :)
  • Best turn your on then he he. Seriously I use windows and it's caught me out a couple of times with images in themes etc... Can't turn it on or off in windows though :(
  • A package can't contain controllers, and therefore routing to it is not possible. What are you trying to do? What do you expect should happen? And what does? Any errors?
  • Harro Verton wrote on Tuesday 19th of July 2011:
    A package can't contain controllers, and therefore routing to it is not possible. What are you trying to do? What do you expect should happen? And what does? Any errors?

    The package I made does not have any controllers.
    the particular package that is not working is one that detects the location via IP. I called it "Location"
    and the way I call it is this : if (Location::check())
    { $location=Location::instance()->detect()->set(); }
    If i remove this bit of code from the controller i am calling , it works fine, otherwise, it gives me a 404 error.
    Other packages i wrote work fine. just this one causes a problem. which is puzzling to me. I suspect it has to do with the server since the package works fine on an local installation. Trouble is , I don't know what to look for.
  • Who or what gives you a 404 error? Your application? Fuel? Your webserver?
  • Harro Verton wrote on Tuesday 19th of July 2011:
    Who or what gives you a 404 error? Your application? Fuel? Your webserver?

    Let say I use that package in a controller ... for example the index.php controller which calls the index page.
    that page would load just fine if I remove the call to the package ( in the way I showed previously) , if i leave that call however, for some reason I get redirected to the 404 page. ( the url is still the same but I get the 404 view, the way fuel normally does it )

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion