将应用程序初始化代码放在laravel中的位置

I'm creating an app that uses the facebook php sdk, and it requires some config:

require_once("facebook.php");

  $config = array(
      'appId' => 'YOUR_APP_ID',
      'secret' => 'YOUR_APP_SECRET',
      'fileUpload' => false, // optional
      'allowSignedRequest' => false, // optional, but should be set to false for non-canvas apps
  );

  $facebook = new Facebook($config);

Where do I put this so that I can use $facebook in my models and controllers?

In this case you better use the Laravel IoC container.

Create a Service Provider

<?php

require_once("facebook.php");

use Illuminate\Support\ServiceProvider;

class FacebookServiceProvider extends ServiceProvider {

    public function register()
    {
        $app = $this->app;

        $app->bind('facebook', function() 
        {
            $config = array(
              'appId' => 'YOUR_APP_ID',
              'secret' => 'YOUR_APP_SECRET',
              'fileUpload' => false, // optional
              'allowSignedRequest' => false, // optional, but should be set to false for non-canvas apps
            );

            return new Facebook($config);
        });
    }

}

Add it to your app/config/app.php

'FacebookServiceProvider',

And now, anywhere in your application, you have access to it by doing:

App::make('facebook')->whateverMethod();

If you need it to instantiate only once, you can use a singleton:

$app->singleton('facebook', function() 
{
     ....
}

You can put it in the app/controllers/BaseController.php However I wouldn't recommend using it in your models though, they should strictly only represent data programatically.