Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8868135
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T17:11:41+00:00 2026-06-14T17:11:41+00:00

In using the laravel framework, how can I call a function defined in base_controller,

  • 0

In using the laravel framework, how can I call a function defined in base_controller, in a view. For exacmple:

class Base_Controller extends Controller {

    public static function format_something()
    {
         return something;
    }
}

How can i call format_something() in a view file?

Usually the error I get looks something like this:
Method [link_to_action] is not defined on the View class.

Probably a silly question, but thanks in advance!

Edit

Okay! First the correct place to do something like this is in the libraries folder.
Second, problem is that your class cannot have underscores.

So in application/libraries I made file AppHelper.php with class

class AppHelper {

    public static function format_something()
    {
        return something;
    }
}

And can call it like:

$formated = AppHelper::format_something;

Thanks for the help and the good forum find Boofus McGoofus.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T17:11:44+00:00Added an answer on June 14, 2026 at 5:11 pm

    This answer was written for Laravel 3. For Laravel 4 and after, Lajdák Marek’s answer using Composer’s autoloader is better.

    Functions like format_something() don’t belong in the controller. The controller should just be about collecting data from various sources and passing it to the view. It’s job is mostly just routing.

    I’ve created a folder called “helpers” in the application folder for all my little helpery functions. To make sure all my controllers, views, and models have access to them, I’ve included the following in my start.php file:

    foreach(glob(path('app').'helpers/*.php') as $filename) {
        include $filename;
    }
    

    I suspect that there’s a better way to do that, but so far it has worked for me.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just started using Laravel. When I use codeigniter or zend framework, I can
Using Spring MVC, do interceptors only intercept defined controller mappings or can they also
new to Laravel (coming from Java spring), while using Route::get('/', function() { return Hello
Using Delphi 2010. I am looking for (possibly) a function or procedure which can
Hello i started using Laravel framework for my Facebook apps lateley and i created
I am using Laravel PHP framework's Fluent query builder to move rows from one
Hi I am using Laravel PHP framework on CentOS 6.3. I have PostgreSQL 9.1
I currently have an application that is built w/ PHP/MySQL using the Laravel Framework
How can a MySQL clause INSERT DELAYED be done using Laravel's Fluent?
I'm using the Laravel Lang class for localization of my web app. I've added

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.