Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Using classes in public folder php files..?
  • Hi, 

    Apologies if this is either a stupid question or been posted before. I tried to search for it but I couldn't think of the correct key words in order to hit it.

    Anyway, I have started helping out on a site 90% of which is built with .php files in the public folder. However, I have now run into a snag that I want to get the latest form entry from the database and echo it into the sidebar of one of these static .php pages. 

    Can (and how can) you call a custom class function from the public folder, or would the whole page need to run through the classes system?

    Thanks in advance,

    Dan
  • HarroHarro
    Accepted Answer
    You have a non-Fuel application, and from a php script of that application, you want to call a Fuel class?
  • That's correct Harro, is that possible or would it be easier to convert the static PHP to a template file?
  • HarroHarro
    Accepted Answer
    I can't comment, I don't know the non-Fuel application. It depends on what that PHP code does...

    Some Fuel helper classes can be used stand-alone, but it means you have to load them manually (you don't have the Fuel autoloader), and you'll need to use the \Fuel\Core namespace (as there is no global aliassing), but most require the framework to be booted...
  • The php doesn't really do anything, it is really just HTML with includes for the headers etc.

    As I suspected then, it sounds like it is going to be easier to take what we have and make it a template/view then call whatever Fuel classes I need. I have proposed this with my colleagues who built the site as I also believe it to be beneficial to have clean urls without the .php extension anyway.

    Thanks for your input, makes the decision a lot easier.

    :)
  • HarroHarro
    Accepted Answer
    if it's plain HTML, and only contains some php to aid the static pages, conversion would be very simple.

Howdy, Stranger!

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

In this Discussion