# Calling Controller (App.php) functions from setup.php (and other controllers)

**URL:** https://discourse.roots.io/t/calling-controller-app-php-functions-from-setup-php-and-other-controllers/13564
**Category:** sage
**Tags:** webpack, sage9
**Created:** 2018-09-10T09:56:22Z
**Posts:** 15
**Showing post:** 6 of 15

## Post 6 by @alwaysblank — 2018-09-10T17:07:42Z

Here’s a reply I wrote a bit ago that might help you out with understanding namespaces: [Controller namespace issue, different behavior on localhost and development server (solved?)](https://discourse.roots.io/t/controller-namespace-issue-different-behavior-on-localhost-and-development-server-solved/11821/2)

Finding out what namespace a class, method, or function is in is generally pretty simple:

- Find the file where the function/method/class is defined
- Go to the top of the file and look for `namespace`
- If you’re looking for a…
  - **function** then that’s it, just prepend the namespace when calling the function
  - **class** then that’s it, just prepend the namespace when calling the class
  - **method** then you’ll need to prepend the namespace, then class, when calling the method

Take the example file below:

```
<?php

namespace Roots;

class Sage {
    public static function hello()
    {
        return 'hello from a method';
    }
}

function goodbye()
{
    return 'goodbye from a function';
}
```

To instantiate this class in another file, you would write:

```
$class = new Roots\Sage();
```

To call the static method `hello()` from another file, you would write:

```
$greeting = Roots\Sage::hello();
```

To call the function `goodbye()` from another file, you would write:

```
$farewell = Roots\goodbye();
```

If the other file has a namespace, and that namespace is _not_ `Roots`, then you need to prepend a slash to all of your calls, i.e.:

```
$greeting = \Roots\Sage::hello();
```

That should be enough info to get you started.

---

_[View the full topic](https://discourse.roots.io/t/calling-controller-app-php-functions-from-setup-php-and-other-controllers/13564)._
