There are two ways you could do this
1. Using your start files
you could register it in app/start/global.php
From the laravel docs
Your application's start files are stored at app/start. By default, three are included with > your application: global.php, local.php, and artisan.php.
But I prefer using the global.php for including other files so as not to populate the global.php
In this context (registering view composers), you could create a file 'app/composers.php' and include it in your global.php file like so:
require app_path() . '/composers.php';
2. Using Service Providers
Create a service Provider. (Sample code below)
class ComposerServiceProvider extends ServiceProvider
{
public function register()
{
$this->registerUserComposer();
}
protected function registerUserComposers()
{
$this->app['view']->composers([
'UserComposer@currentUser' => [
'view1', 'view2'
],
]);
}
}
Then add an entry into the 'providers' array of your app/config/app.php
'providers' => array(
....
'ComposerServiceProvider'
)