Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
3rd party functions and classes?
  • Hi,what is the best way to include and use a 3rd party classes, and functions inside a fuel project? and is there any tips to create or load functions inside views to handle script repetitions, this is an example  : 

    i have to write ths script every time i want to show thumbs:

    foreach($data as $row){
    $link_url = Uri::create('controller/method/:id', array('id'=>$row->id));
    $thumb_url = Uri::create('path/to/images/:name', array('name'=>$row->image));
    $img = Html::img($thumb_url, Str::truncate($row->desc,Config::get('thumbs.max_chars')));
    echo Html::anchor($link_url,$img);}
    instead how can i just do : show_thumbs($data) so i can handle repetitions and make script modification easier.

  • HarroHarro
    Accepted Answer
    The best location for the definition of custom functions is in your app/bootstrap.php. Add them at the bottom, or use an include to load them.

    For third party classes, store them in app/vendor. How you load them greatly depends on what they are, how they are written, if they are namespaced, etc. Most likely you will have to include them too, which you can do in the app bootstrap as well.
  • thank you,  its all what am looking for.

Howdy, Stranger!

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

In this Discussion